Accessing XML Request/Responses with JAX-WS without Proxy
In JAX-WS, accessing the raw request and response XML during webservice communication can be achieved by enabling detailed logging. Here's how it can be done:
Set the following system properties in your code or environment:
System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true"); System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true"); System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true"); System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold", "999999");
The properties enable logging of all communication to the console. The "dumpTreshold" property ensures that the entire request and response XML is logged, regardless of its size.
Alternatively, you can also set these properties as command-line parameters using the "-D" flag or as environment variables.
Note that while this method is straightforward and less overhead-intensive than using frameworks like Axis or CXF, it does not provide additional features such as request interception or response modification.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3