Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Supplied userRef is not a valid UserBOHandle

Hi,

I am using SDK 2.1 to create a custom web service.

When running the web-service I get the following faultstring "Supplied userRef is not a valid UserBOHandle"

and when debugging it is the function RunAsServiceLocator that throws the exception.

My code snippet looks like this:

 

  ShopOrderBasicConfiguration soBasic = null;
  ResourceBasicConfiguration reBasic = null;
  try {
     String user = wsContext.getUserPrincipal().getName();
    
        if ((null == site)||"".equals(site)) {
            SimpleLogger.log(Severity.ERROR,Category.SYS_SERVER, loc,
              "MESDK:setupResource WebService:Exception Set Resource", "No Site defined in request");
        }


  //Find Shop Order object. Use Service locator to run using a specific user and site
     ServiceReference serviceRef = new ServiceReference(COM_SAP_ME_DEMAND, SHOPORDER_SERVICE);
     RunAsServiceLocator serviceLocator = new RunAsServiceLocator(user, site, null);
     soService = serviceLocator.getService(serviceRef, ShopOrderServiceInterface.class);
  FindShopOrderByKeyFieldsRequest soKeyReq = new FindShopOrderByKeyFieldsRequest(shopOrder);
        soBasic = soService.findShopOrderByKeyFields(soKeyReq);

 

How can I change the user to be a valid UserRef?

Br,

Johan

Tags:
Former Member replied

Hi,

According to the snippet, the "user" is actually name of the user, while RunAsServiceLocator expects user as a reference to user (string like "UserBO:SITE,USERNAME"). Building and passing such string should solve your immediate issue.

On other hands, you could use com.sap.me.extension.Services and not worry about user at all. The purpose of RunAsServiceLocator is to support integration with machines, when there is no wsContext.getUserPrincipal(). In other cases, ME will be able to get user from principal itself.

Thanks,

Bakhtiyar

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question