on 11-04-2009 7:26 AM
hi
i tried create a web dynpro project, and access uwl, like the document
Accessing UWL Notifications from Web Dynpro Using UWL API
but doesn't matter i tried
IUser loggedinuser = UMFactory.getLogonAuthenticator().getLoggedInUser();
or
IUser loggedinuser = WDClientUser.getCurrentUser().getSAPUser();
it always hit UWLException: (Default) Logged in users context or session doesn't exist
my code like follows:
public void getInbox() {
IWDMessageManager messageManager = wdComponentAPI.getMessageManager();
wdContext.nodeInboxData().invalidate();
try {
IUWLService uwlService = (IUWLService) WDPortalUtils.getServiceReference(IUWLService.ALIAS_KEY);// PortalRuntime.getRuntimeResources().getService(IUWLService.ALIAS_KEY);//
UWLContext uwlContext = new UWLContext();
IUser loggedinuser =UMFactory.getLogonAuthenticator().getLoggedInUser();
uwlContext.setAllowBackEndConnections(true);
uwlContext.setUser(loggedinuser);
uwlContext.setLocale(loggedinuser.getLocale());
IUWLSession uwlSession = uwlService.beginSession(uwlContext, 600);
uwlContext.setSession(uwlSession);
IUWLItemManager itemManager = uwlService.getItemManager(uwlContext);
QueryResult result = itemManager.getItemsForItemType(uwlContext, ItemType.UWL_ITEM_NOTIFICATION, null, null);
ItemCollection coll = result.getItems();
List l = coll.list();
Iterator iter = l.iterator();
while (iter.hasNext()) {
Item item = (Item) iter.next();
if (item.getExternalType().equals("UWLNotification") && !item.getStatus().equals(StatusEnum.COMPLETED)) {
IPrivateMyToDoCompView.IInboxDataElement data = wdContext.nodeInboxData().createInboxDataElement();
data.setItem(item);
data.setSubject(item.getSubject());
data.setDescription(item.getDescription());
data.setStatus(item.getStatus().getText());
data.setCreatorId(item.getCreatorId());
data.setCreatedDate(item.getCreatedDate().toString());
wdContext.nodeInboxData().addElement(data);
}
}
uwlService.endSession(uwlContext);
} catch (Exception e) {
e.printStackTrace();
messageManager.reportException(" Cause:" + e.getCause() + "\n Message:" + e.getMessage());
}
}
can any one tell me why? and i develop with nwce 7.1 ehp1.
thank you
My System: CE 7.1
Hi, it's me again. Now I found the error by myself - DAMN!
As I have seen we have got the same error. I guess your template was also this tutorial: [Accessing UWL Notifications from Web Dynpro Using UWL API|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/802bfda2-8a85-2b10-9290-d67da32d0c01]
The error message (in my case - maybe in yours too) was NOT due to missing user context or session. The error was thrown because
QueryResult result = itemManager.getItemsForItemType(uwlContext, ItemType.UWL_ITEM_NOTIFICATION, null, null);
returned nothing.
Solution:
Replace the tutorial code of the getInbox() method with this: [How to use UWL API for NetWeaver BPM Tasks|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/16356] [original link is broken]; and everything works fine.
Maybe that will be your solution too!
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Mr.Martin B.
thank you very much, and so sorry about that i did not update the thread.
but the issue is not be solved.
the real problem is, i cannot get the item info with IUser get by
IUser loggedinuser = UMFactory.getUserFactory().getUserByLogonID("xxx");
only current user like: WDClientUser.getCurrentUser().getSAPUser();
work.
i got same message of UWLException.
but i have to get tasks(not belog to current user) info.
br and heva nice day.
Hm ok,
maybe it helps when you look at the whole user context. Try this:
IUserFactory userFactory = UMFactory.getUserFactory();
IUserSearchFilter searchFilter = userFactory.getUserSearchFilter();
searchFilter.setDisplayName("*",ISearchAttribute.LIKE_OPERATOR, false);
ISearchResult searchResult = userFactory.searchUsers(searchFilter);
while (searchResult.hasNext()) {
String uniqueid = (String) searchResult.next();
IUser user = userFactory.getUser(uniqueid);
wdComponentAPI.getMessageManager().reportWarning(user.getUniqueName() + " ");
}
This code gives you, in the WebDynpro, an overview about all user contexts in the background.
Regards
I been struggling with the same problem for some days now. I am on EP7 SP18 Patch5 of UWLJWF
The code works fine if i try on Webdynpro, but the moment i move on to an EJB and try to expose it as a webservice.
QueryResult result = itemManager.getItemsForItemType(uwlContext, ItemType.UWL_ITEM_NOTIFICATION, null, null);
my user source is LDAP.
Do we have a solution to this?
~Nitin
Martin, I am at Client Site and due to confidentiality agreement, i cannot give you the number.
I however have not received any response from SAP yet and we are targeting on moving through our SAP Anchors here at the client site.
Will update you once i get something from SAP on this.
Regards,
Nitin
Hi Nitin / martin ,
I am facing the same issue now. I am using the below code for User Identification.
IAuthentication ia = UMFactory.getAuthenticator();
IUser user = ia.getLoggedInUser();
uwlContext.setUser(user);
uwlContext.setLocale(Locale.getDefault());
which is not happening and as a result the IUWLItemManager itemManager =
uwlService.getItemManager(uwlContext);
is throwing a UWLException.
But all this code works fine with JAVA web dynpro. When a java class with this code is exposed as a web service this error is seen.
Please guide me if you have found the issue as I see from the thread that this same problem was raised to SAP .
Hi Nitin / Martin
Could you resolve your issue? I am also facing similar problem. I have created one portal service which takes userid as input and should return UWL task count as output. After deploying the service in SAP WAS
when I test it from wsnavigator providing userId as input I get below error in response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><rpl:getUwlCountsResponse xmlns:rpl='urn:TestUwlSvcVi'><rpl:Response xsi:type='tns:ArrayList' xmlns:tns='java:sap/standard'><tns:List xsi:type='xs:string'>Line -2</tns:List><tns:List xsi:type='xs:string'>Line -1</tns:List><tns:List xsi:type='xs:string'>Line 0</tns:List><tns:List xsi:type='xs:string'>Line 1</tns:List><tns:List xsi:type='xs:string'>Line 2: USER.CORP_LDAP.mss02</tns:List><tns:List xsi:type='xs:string'>Line 3</tns:List><tns:List xsi:type='xs:string'>Line 4: itemManager: com.sap.netweaver.bc.uwl.core.ItemManager@7a4227c6</tns:List><tns:List xsi:type='xs:string'>Line 5: view: com.sap.netweaver.bc.uwl.config.UWLView@4a7fcbf2</tns:List><tns:List xsi:type='xs:string'>Line 6 : uwlContext: com.sap.netweaver.bc.uwl.UWLContext@24ee5934</tns:List><tns:List xsi:type='xs:string'>exception occured: Thu Apr 01 16:33:19 BST 2010
(Default) Logged in users context or session doesn't exist null</tns:List></rpl:Response></rpl:getUwlCountsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
I tried also using the user passed in http request to the service, still get the same error.
Please let me know if you got any resolution to this.
Thanks
Sudip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I can not believe it but I got my UWL web service running.
My code fails on the server, because I executed the web service with user that has no locale set in Identity Management of the portal. In order the code to pass, I either have to set the locale of the user, or change the code that sets the default locale of the UWL context from:
context.setLocale(user.getLocale());
to:
Locale loc = new Locale("en");
context.setLocale(loc);
This way even if the web service is executed with user without locale, the default locale that is set to the UWL context will be used (in this case English locale).
Before executing the web service you have to set security settings for web service at Single Serve Administration to
- User ID/Password OR
- Logon Ticket
I will give you my code below!
Class Task:
public class Task {
String subject;
String taskid;
String url;
String error;
public Task() {
}
public Task(String subject, String taskid, String url, String error) {
super();
this.subject = subject;
this.taskid = taskid;
this.url = url;
this.error = error;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getTaskid() {
return taskid;
}
public void setTaskid(String taskid) {
this.taskid = taskid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
Class UwlBean:
(UwlTasks class is not formatted right. Only the forum god knows why, grrrrrrrr)
Edited by: Martin B. on Apr 13, 2010 3:08 PM
public class UwlTasks implements UwlTasksLocal {
public UwlTasks() {}
public List<Task> getTasks() throws Exception {
IUser user = null;
String output = "";
String error = "errortest";
List<Task> tasklist = new ArrayList<Task>();
int totals[] = null;
try {
user = com.sap.security.api.UMFactory.getAuthenticator().getLoggedInUser(getHttpRequest(), null);
IUWLService uwlService = findService();
if (uwlService == null) {
throw new Exception("Cannot get UWL Service");
}
UWLContext context = new UWLContext();
if (user == null) {
throw new Exception("No user");
}
context.setUser(user);
// context.setLocale(user.getLocale());
Locale loc = new Locale("en");
context.setLocale(loc);
IUWLSession session = uwlService.beginSession(context, 200);
context.setSession(session);
context.setAllowBackEndConnections(true);
IUWLItemManager itemManager = uwlService.getItemManager(context);
UWLView view = uwlService.getViewManager(context).getView("DefaultView", context);
if (view != null) {
QueryProperties properties = new QueryProperties();
properties.setMaxNumberOfItemsToFetch(0);
totals = itemManager.getTotalAndEmphasizedItemCountForView(context, view, "", null);
}
QueryResult result = itemManager.getItems(context, null, null);
ItemCollection items = result.getItems();
Item item = null;
String executionURLbase = "http://localhost:50000/webdynpro/resources/sap.com/tc~bpem~wdui~taskinstance/ATaskExecution?";
String taskid = "";
for (int i = 0; i < items.size(); i++) {
item = items.get(i);
String externalid = item.getExternalId();
HashMap<String, String> params = new HashMap<String, String>();
// Remove the @ symbol
params.put("taskId", externalid.split("@")[0]);
taskid = params.toString().replace("{", "").toString().replace("}", "");
tasklist.add(new Task(item.getSubject(), taskid, executionURLbase + taskid, ""));
}
} catch (Exception e) {
String username = user == null ? "unknown" : user.getName();
error = "A problem occurred: " + e.getLocalizedMessage();
error += " user name: " + username;
tasklist.add(new Task("","","",error));
}
if (totals != null) {
output = Integer.toString(totals.length);
tasklist.add(new Task("COUNT",output,"",""));
} else {
output = "no items";
tasklist.add(new Task("COUNT",output,"",""));
}
return tasklist;
}
// look up UWL service
private IUWLService findService() throws NamingException {
Properties env = new Properties();
env.put(InitialContext.INITIAL_CONTEXT_FACTORY,"com.sapportals.portal.prt.registry.PortalRegistryFactory");
// create initial context
InitialContext ctx = new InitialContext(env);
// retrieve UWL service
IUWLService uwlService = (IUWLService) ctx
.lookup(IUWLService.ALIAS_KEY);
return uwlService;
}
public HttpServletRequest getHttpRequest() throws Exception {
Properties props = new Properties();
props.put("domain", "true");
InitialContext initialContext = new InitialContext(props);
ApplicationWebServiceContext wsContext = (ApplicationWebServiceContext) initialContext.lookup(" /wsContext/ApplicationWebServiceContext");
HttpServletRequest req = wsContext.getHttpServletRequest();
return req;
}
}
Thanks Martin,
Funny side, I did see the locale returning null and tried setting it up in the UME. Tried different values and it didn't help. Printed the logs and had the same error returned each time.
I'll however try this code.
Lets see what happens.
Thanks again for taking time and sharing your findings.
Regards,
Nitin
Hi,
I have the same problems.
Did you already solved it?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.