This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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
Author

Setting cookies on Axis2 client request for Exchange server

nDilip Gupta
Greenhorn

Joined: May 06, 2011
Posts: 1
Hi,

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.setAuthSchemes(authScheme);
authenticator.setUsername(userName);
// authenticator.setPassword(password);
authenticator.setHost(exchangeHost);
authenticator.setDomain(exchangeDomain);
authenticator.setPort(Integer.parseInt(urlAndPort[1]));

options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);

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

m_EWSservice._getServiceClient().setOptions(options);

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 ****:::::::::::::::https://cdc.testmail.testyash.com/EWS/exchange.asmx
[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="cdc.testmail.testyash.com"}
[5/5/11 18:12:49:109 IST] 0000003f HTTPSender I org.apache.axis2.transport.http.HTTPSender sendViaPost Unable to sendViaPost to url[https://cdc.testmail.testyash.com/EWS/exchange.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:296)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:364).

Please suggest me if anyone is having some idea for the same.
 
jQuery in Action, 2nd edition
 
subject: Setting cookies on Axis2 client request for Exchange server