I am consuming a third party webservice using AXIS2 stub. The primary method which I use works FINE and has below signature:
boolean isValidUser(username, password);
The webservice is supposed to return a String (token) in the response headers as cookie :- WSToken
But I cannot find ANY method to extract the headers and cookies from the response. In fact there is no HTTPResponse object to fetch the cookies !.
I have tried this code:
MessageContext context = stub._getServiceClient().getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Object response = context.getProperty("response");
But it returns a null value as there is no such property in the context. The context has below properties:
transport.http.statusCode
CHARACTER_SET_ENCODING
TRANSPORT_HEADERS
org.apache.axiom.om.util.DetachableInputStream
messageType
ContentType
TRANSPORT_IN
How can I get the cookie called 'WSToken' from the response using the stub ?
The TRANSPORT_HEADERS property should give you the HTTP headers you got. You can then look for Set-Cookie
headers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.