【问题标题】:How get http response headers via axis2 stub如何通过axis2 stub获取http响应头
【发布时间】:2016-01-09 01:37:59
【问题描述】:

我使用由 axis2 创建的 adb-stubs 访问 SOAP 服务,我应该从响应中获取 sessionId 和 cookie,然后使用另一个请求发送...

我需要获取您可以在图片中看到的这些参数

http://www.imageup.ru/img36/1635686/skrinshot-2014-01-23-104646.png

MessageContext msgCtx = serviceStub._getServiceClient().getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
msgCtx.getProperty(HTTPConstants.HTTP_HEADERS);
SOAPHeader  soapHeader = msgCtx.getEnvelope().getHeader();

我试过这些,但我能得到结果:( 我还将 manageSession 参数设置为 true。

当我调试请求和响应时,我得到以下日志:

2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Cache-Control: private, max-age=0[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Content-Length: 505[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Content-Type: text/xml; charset=utf-8[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Server: Microsoft-IIS/7.5[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "X-AspNet-Version: 2.0.50727[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "Set-Cookie: ASP.NET_SessionId=agj1njnpvoerup45tqnmsz45; path=/; HttpOnly[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "X-Powered-By: ASP.NET[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "Date: Thu, 23 Jan 2014 06:35:59 GMT[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] CookieSpec - Unrecognized cookie attribute: name=HttpOnly, value=null
2014/01/23 12:35:55:382 ALMT [DEBUG] HttpMethodBase - Cookie accepted: "$Version=0; ASP.NET_SessionId=agj1njnpvoerup45tqnmsz45; $Path=/"

请帮帮我。

【问题讨论】:

    标签: java soap axis2


    【解决方案1】:

    经过千辛万苦,我找到了答案…… 我使用以下代码从axis2存根响应中检索cookie:

    CommonsTransportHeaders cth = (CommonsTransportHeaders) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS); String cookie = (String) cth.get(WSConstants.SET_COOKIE);

    我希望这对其他人有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-31
      相关资源
      最近更新 更多