cancel
Showing results for 
Search instead for 
Did you mean: 

Supplied userRef is not a valid UserBOHandle

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (0)