[jboss-user] [JBossWS] - Share JSESSIONID between multiple services

nias do-not-reply at jboss.com
Tue Oct 7 09:51:14 EDT 2008


i'm trying to share a session between more then one webservice endpoint for statefull webservices (via seam to use conversations).

i've tried to get each port via:


  | URL wsdlLocation = new URL("...");
  | QName serviceName = new QName(..., ...); 
  | Service service = Service.create(wsdlLocation, serviceName);
  | port1 res = (port1)service.getPort(port1.class);
  | BindingProvider bp = (BindingProvider)res;
  | bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "admin");
  | bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "admin");
  | bp.getRequestContext().put(StubExt.PROPERTY_AUTH_TYPE, StubExt.PROPERTY_AUTH_TYPE_WSSE);
  | URL securityURL = new File("src/test/webservices/META-INF/jboss-wsse-client.xml").toURL();
  | ((StubExt)bp).setSecurityConfig(securityURL.toExternalForm());
  | ((StubExt)bp).setConfigName("Standard WSSecurity Client"); 	
  | bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
  | 
all calls from one port are working fine inside the session but now i wan't to take the JSESSIONID from port1 after first call and use them for port2 with the following code:


  | final Map responseMap = ((BindingProvider)port1).getResponseContext();
  | final Map headerValues = (Map)responseMap.get(MessageContext.HTTP_RESPONSE_HEADERS);
  | final List<String> cookieHeaders = (List<String>) headerValues.get("Set-Cookie");
  | for(String x : cookieHeaders) {
  | if(xl[0].equals("JSESSIONID")) {
  |     Map<String, List<String>> headers = (Map<String, List<String>>) ((BindingProvider)port2).getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
  |     if (headers == null) {
  |         headers = new HashMap<String, List<String>>();
  | ((BindingProvider)port2).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
  |     } else { System.out.println("headers exists"); }
  | 
  |     List<String> cookie = headers.get("Cookie");
  |     if (cookie == null) {
  |         cookie = new ArrayList<String>();
  |         headers.put("Cookie", cookie);
  |     } else { System.out.println("cookies exists"); }
  |     cookie.add("JSESSIONID="+xl[1]);
  | 

The cookie would be extracted but ignored on first call for port2, therefore a new session starts on port2.
how can i solve this?



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4180783#4180783

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4180783



More information about the jboss-user mailing list