java 如何在使用 Axis 1.4 wsdl2java 生成的客户端时获取 SOAP 消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1596586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get SOAP message while using a Axis 1.4 wsdl2java-generated client
提问by rshepherd
This is probably an easy question for anyone with any moderate expertise with web services using Apache Axis.
对于具有使用 Apache Axis 的 Web 服务的中等专业知识的任何人来说,这可能是一个简单的问题。
I have a web service client that was generated by wsdl2java in Axis 1.4. I am writing unit tests that need to access the actual SOAP message itself, and do a comparison to the client side java classes which are generated by Axis. (don't ask)
我有一个由 Axis 1.4 中的 wsdl2java 生成的 Web 服务客户端。我正在编写需要访问实际 SOAP 消息本身的单元测试,并与 Axis 生成的客户端 java 类进行比较。(不要问)
How can I retrieve the actual SOAP message from a response from the service?
如何从服务的响应中检索实际的 SOAP 消息?
From what I can gather from searching around is that I have to get the MessageContext. I have tried something along these lines...
从我可以通过搜索收集到的信息是,我必须获得 MessageContext。我已经尝试了这些方面的东西......
MessageContext mc = MessageContext.getCurrentContext(); String message = mc.getCurrentMessage().getSOAPPartAsString();
MessageContext mc = MessageContext.getCurrentContext(); 字符串消息 = mc.getCurrentMessage().getSOAPPartAsString();
But mc is null in this case....
但是在这种情况下 mc 为空....
Any help is appreciated!
任何帮助表示赞赏!
采纳答案by rshepherd
This is how it's done.
这就是它的完成方式。
http://users.skynet.be/pascalbotte/rcx-ws-doc/jaxrpchandler.htm
http://users.skynet.be/pascalbotte/rcx-ws-doc/jaxrpchandler.htm
回答by Davut Gürbüz
When _callobject is filled calling the line below gives it.
当_call对象被填充时,调用下面的行给出它。
String request=_call.getMessageContext().getRequestMessage()
.getSOAPPart().getEnvelope().toString();
String request=_call.getMessageContext().getRequestMessage()
.getSOAPPart().getEnvelope().toString();
For response use the below one
对于响应使用下面的一个
_call.getMessageContext().getResponseMessage()
.getSOAPPart().getEnvelope().toString()
_call.getMessageContext().getResponseMessage()
.getSOAPPart().getEnvelope().toString()
Callis a org.apache.axis.client.Callas you know.
Call是org.apache.axis.client.Call的,你知道。

