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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 17:13:16  来源:igfitidea点击:

How to get SOAP message while using a Axis 1.4 wsdl2java-generated client

javaaxisweb-serviceswebservice-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 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.

Callorg.apache.axis.client.Call的,你知道。