File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Setting cookies on Axis2 client request for Exchange server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Setting cookies on Axis2 client request for Exchange server" Watch "Setting cookies on Axis2 client request for Exchange server" New topic

Setting cookies on Axis2 client request for Exchange server

nDilip Gupta

Joined: May 06, 2011
Posts: 1

I have generated classes using Axis2 1.4 tool for Exchange 2007 Web services. Now I am connecting Exchange server using Exchange server credentials which are working fine and able to get the results from Exchange server.

Now, I have to implement SSO for the same. In this case we are retrieving cookies from server (In my case IBM portal server) and pass these on Axis2 generated classes. What I found in research, we can set the cookies in two places.

First place at org.apache.axis2.context.ConfigurationContext configurationContext which used the code below,

String cookie = "LtpaToken="+cookieLtpaToken+"; JSESSIONID="+cookieJSessionID+"; PD-S-SESSION-ID="+cookiePDSessionID;
configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
configurationContext.setProperty("cookie", cookie);

Second place at org.apache.axis2.client.Options which used the code below,

Options options = m_EWSservice._getServiceClient().getOptions();
HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
List authScheme = new ArrayList();
authScheme.add(exchangeAuth);// DIGEST, NTLM, BASIC
// authenticator.setPassword(password);

options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);

// Managing the session using the service client
options.setProperty("cookie", cookie);


In the given code lines, we are not setting password as I have to achieve SSO.

Once we use this code and run our application, we are getting error. That is,

[5/5/11 18:12:36:422 IST] 0000003f SystemOut O EWS url ****:::::::::::::::
[5/5/11 18:12:36:422 IST] 0000003f SystemOut O EWS port :::::::::::::::443
[5/5/11 18:12:48:969 IST] 0000003f HttpMethodDir W org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge Unable to respond to any of these challenges: {basic=Basic realm=""}
[5/5/11 18:12:49:109 IST] 0000003f HTTPSender I org.apache.axis2.transport.http.HTTPSender sendViaPost Unable to sendViaPost to url[]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(
at org.apache.axis2.transport.http.HTTPSender.send(
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(

Please suggest me if anyone is having some idea for the same.
I agree. Here's the link:
subject: Setting cookies on Axis2 client request for Exchange server
It's not a secret anymore!