![](/img/trans.png)
[英]How to get xml response as String from SOAP webservice using axis2
[英]Extract cookies from SOAP response using AXIS2
我正在使用AXIS2存根使用第三方Web服务。 我使用的主要方法是FINE,并且具有以下签名:
boolean isValidUser(username, password);
Web服务应该在响应标头中以cookie形式返回字符串(令牌):-WSToken
但是我找不到任何方法来从响应中提取标题和cookie。 实际上,没有HTTPResponse对象来获取cookie!。
我已经试过这段代码:
MessageContext context = stub._getServiceClient().getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Object response = context.getProperty("response");
但是它返回一个空值,因为上下文中没有这样的属性。 上下文具有以下属性:
transport.http.statusCode
CHARACTER_SET_ENCODING
TRANSPORT_HEADERS
org.apache.axiom.om.util.DetachableInputStream
messageType
ContentType
TRANSPORT_IN
如何使用存根从响应中获取名为“ WSToken”的cookie?
TRANSPORT_HEADERS属性应该为您提供HTTP标头。 然后,您可以查找Set-Cookie
标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.