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

人走茶凉 提交于 2020-01-03 10:52:45

问题


This is probably an easy question for anyone with any moderate expertise with web services using Apache Axis.

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)

How can I retrieve the actual SOAP message from a response from the service?

From what I can gather from searching around is that I have to get the MessageContext. I have tried something along these lines...

MessageContext mc = MessageContext.getCurrentContext(); String message = mc.getCurrentMessage().getSOAPPartAsString();

But mc is null in this case....

Any help is appreciated!


回答1:


This is how it's done.

http://users.skynet.be/pascalbotte/rcx-ws-doc/jaxrpchandler.htm




回答2:


When _call object is filled calling the line below gives it.

String request=_call.getMessageContext().getRequestMessage() .getSOAPPart().getEnvelope().toString();

For response use the below one

_call.getMessageContext().getResponseMessage() .getSOAPPart().getEnvelope().toString()

Call is a org.apache.axis.client.Call as you know.



来源:https://stackoverflow.com/questions/1596586/how-to-get-soap-message-while-using-a-axis-1-4-wsdl2java-generated-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!