on 08-30-2012 10:24 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.