Skip to Content

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2012 at 11:26 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.