This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Web Services and the fly likes how to set cookies (jsessionid) in web service client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "how to set cookies (jsessionid) in web service client" Watch "how to set cookies (jsessionid) in web service client" New topic

how to set cookies (jsessionid) in web service client

Ravikanth Reddy Bapathi

Joined: Apr 13, 2007
Posts: 29

The below is my client code.

public static void main(String[] args) {
TestService ts = new TestService();
try {

SecurityEndpointImplServiceLocator loc = new SecurityEndpointImplServiceLocator();

SecurityEndpointImpl impl = loc.getWSSecurityService();

SOAPHeaderElement header = new SOAPHeaderElement("", "Security");
SOAPElement node = header.addChildElement("UsernameToken");
SOAPElement userNode = node.addChildElement("Username");

SOAPElement passwordNode = node.addChildElement("Password");

WSSecurityServiceSoapBindingStub stub = new WSSecurityServiceSoapBindingStub();

UserContext context = new UserContext();

* SOAPHeaderElement header= new SOAPHeaderElement();
* stub.setHeader(header)

((WSSecurityServiceSoapBindingStub) impl).setHeader(header);

SecurityParamResponse response = impl.getSecurityParam(context);
} catch (Exception e) {
// TODO Auto-generated catch block

how can i set cookies in this code.
i was able to set SOAPHeaders.

i need to set jsession id value which i would be recieving from other service.

Thanks in advance.

R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. Please see if this helps.
I agree. Here's the link:
subject: how to set cookies (jsessionid) in web service client
jQuery in Action, 3rd edition