[英]Extract cookies from SOAP response using AXIS2
I am consuming a third party webservice using AXIS2 stub. 我正在使用AXIS2存根使用第三方Web服务。 The primary method which I use works FINE and has below signature:
我使用的主要方法是FINE,并且具有以下签名:
boolean isValidUser(username, password);
The webservice is supposed to return a String (token) in the response headers as cookie :- WSToken Web服务应该在响应标头中以cookie形式返回字符串(令牌):-WSToken
But I cannot find ANY method to extract the headers and cookies from the response. 但是我找不到任何方法来从响应中提取标题和cookie。 In fact there is no HTTPResponse object to fetch the cookies !.
实际上,没有HTTPResponse对象来获取cookie!。
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 ? 如何使用存根从响应中获取名为“ WSToken”的cookie?
The TRANSPORT_HEADERS property should give you the HTTP headers you got. TRANSPORT_HEADERS属性应该为您提供HTTP标头。 You can then look for
Set-Cookie
headers. 然后,您可以查找
Set-Cookie
标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.