Hi.
I am writing a Java client to a .NET web service. I call an
authentication service and then I get a cookie in the response. I need
to set the cookie in all subsequent outgoing requests to other web
services available on the same server. I tried using the
"setManageSession(true)" , but it is not setting the cookie. I verified
this on the TCP Monitor. I am attaching my code. Can somebody help me
with how to get this working or point me to some other thread on the
same problem.
Thanks,
Rajat
package almconnectorserver;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.omg.CORBA.TIMEOUT;
public class ClientTrial {
private static EndpointReference targetEPR1 = new EndpointReference("http://localhost:81/pwa/_vti_bin/psi/LoginForms.asmx");
private static EndpointReference targetEPR2 = new EndpointReference("http://localhost:81/pwa/_vti_bin/psi/Project.asmx");
private static long TIMEOUT = 10000;
public ClientTrial() {
}
public static void main(String[] args) throws Exception{
OMElement loginRequest;
OMElement projectList;
ServiceClient sender = new ServiceClient();
try{
loginRequest = loginProject("Srinivasan Raman","[EMAIL PROTECTED]");
Options options = new Options();
options.setTo(targetEPR1);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setAction("http://schemas.microsoft.com/office/project/server/webservices/LoginForms/Login");
options.setTimeOutInMilliSeconds(TIMEOUT);
sender.setOptions(options);
sender.getOptions().setManageSession(true);
OMElement result = sender.sendReceive(loginRequest);
String response = result.getFirstElement().getText();
System.out.println(response);
}
catch(Exception ex){
ex.printStackTrace();
}
try{
projectList = createProjectList();
Options options = new Options();
options.setAction("http://schemas.microsoft.com/office/project/server/webservices/Project/ReadProjectList");
options.setTo(targetEPR2);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setTimeOutInMilliSeconds(TIMEOUT);
sender.setOptions(options);
OMElement result = sender.sendReceive(projectList);
}
catch(Exception ex){
ex.printStackTrace();
}
}
public static OMElement createProjectList() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNS = fac.createOMNamespace("http://schemas.microsoft.com/office/project/server/webservices/Project/","tns");
OMElement method = fac.createOMElement("ReadProjectList",omNS);
return method;
}
public static OMElement loginProject(String uname,String passwd) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNS = fac.createOMNamespace("http://schemas.microsoft.com/office/project/server/webservices/LoginForms/","tns");
OMElement method = fac.createOMElement("Login",omNS);
OMElement value1 = fac.createOMElement("username",omNS);
value1.addChild(fac.createOMText(value1,uname));
method.addChild(value1);
OMElement value2 = fac.createOMElement("password",omNS);
value2.addChild(fac.createOMText(value2,passwd));
method.addChild(value2);
return method;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]