I am building Java
application for Online Web Services
and let's call it 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
.
From the WSDL
file I generate the Java
classes needed which are Requests
and Responses
classes. Application A
will send some request
object after setting the needed parameters and excepting response
object from application B
.
The connection is established and both applications A and B
are communicating with each other.
Question:
From application A
how can I get the xml
data(file or text) for the request
object before sending it to application B
?
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. 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
我没有什么好发表评论的名声,所以这是我的回答:如果您尚未使用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.
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
is a variable of type org.apache.axis.client.Cal
and it is auto generated by Axis
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.