lunedì 5 marzo 2012

Axis 1.x client jsession management

Step 1: retrieving jsessionid from server first response
Sample code here:
//Create My serviceLocator recuperando l'interfaccia del service
BWProvisioningServiceServiceLocator serviceLocator =
new BWProvisioningServiceServiceLocator();//Set session enabled
BWProvisioningService service = serviceLocator.getProvisioningService();
//1th service Call
String result = service.processOCIMessage(request);
* recupero nonce x password
String nonce =
nonce = result.substring(result.indexOf(
"";"<nonce>")+ 7, result.indexOf("</nonce>"));/** retrieve of session id **/
Stub stub = (Stub) service;
org.apache.axis.client.Call call = stub._getCall();
org.apache.axis.MessageContext msgContext = call.getMessageContext();
String prp = (String)msgContext.getProperty(
String jSessionId = prp.substring(prp.indexOf(
"Cookie");"=") + 1);out.println(jSessionId);/** end of jsessionid retrieve process**/

Step2:  setting jsession id for each  call
Sample code

// for each following request
((javax.xml.rpc.Stub)service)._setProperty( HTTPConstants.
HEADER_COOKIE, "JSESSIONID=" + jSessionId);//2th service Call
String result2 = service.processOCIMessage(loginRequest);

Nessun commento:

Posta un commento