[英]How to get XML file from Java Request object before sending. Web services SOAP
I am building Java
application for Online Web Services
and let's call it application A
. 我正在为Online Web Services
构建Java
应用程序,我们称之为application A
I got the WSDL
file form the second party so I can communicate with their application and let's call it application B
. 我从第二方获得了WSDL
文件,因此我可以与他们的应用程序通信,我们称之为application B
From the WSDL
file I generate the Java
classes needed which are Requests
and Responses
classes. 从WSDL
文件中,我生成了所需的Java
类,即Requests
和Responses
类。 Application A
will send some request
object after setting the needed parameters and excepting response
object from application B
. Application A
将发送一些request
设置所需要的参数和后除外对象response
从对象application B
。
The connection is established and both applications A and B
are communicating with each other. 建立连接,并且applications A and B
相互通信。
Question: 题:
From application A
how can I get the xml
data(file or text) for the request
object before sending it to application B
? 从application A
发送到application B
之前,如何获取request
对象的xml
数据(文件或文本)?
As described the connection is done by passing Java
object as request
and I know that in some point this request
will be converted to xml
file. 如前所述,通过将Java
对象作为request
传递来完成连接,我知道在某些情况下此request
将转换为xml
文件。 How to get it? 如何获得?
--- EDIT ---- -编辑-
Important Information is missing that may cause confusion. 重要信息丢失,可能导致混乱。
I am generated the Java
Classed have been generated using Axis
framework 我生成的Java
Classed已使用Axis
框架生成
我没有什么好发表评论的名声,所以这是我的回答:如果您尚未使用Apache CXF框架,并且希望在发送应用程序之前捕获该请求,则可以在其中使用cxf拦截器一些内置的拦截器可以做到这一点,或者您可以创建一个具有正确相位的自定义拦截器(例如,元帅后)
The problem is solved by adding the following statements in the bindingStub
class that has been auto generated from the WSDL
file for the web-services
you are trying to access. 通过在已从WSDL
文件为您要访问的web-services
自动生成的bindingStub
类中添加以下语句来解决该问题。
String request = _call.getMessageContext().getRequestMessage().getSOAPPartAsString();
String response = _call.getMessageContext().getResponseMessage().getSOAPPartAsString();
These statements should be placed after the following method call _call.invoke
otherwise you will get NullPointerException
. 这些语句应放在以下方法调用_call.invoke
否则您将获得NullPointerException
。
_call
is a variable of type org.apache.axis.client.Cal
and it is auto generated by Axis
_call
是org.apache.axis.client.Cal
类型的变量,由Axis
自动生成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.