0

How can I find the exact soap request and response generated. Here is the sample code I am using:

@WebService(targetNamespace = "", name = "")
@XmlSeeAlso({ObjectFactory.class})
public interface ServiceSoap {

    @WebMethod(action = "")
    @RequestWrapper(localName = "", targetNamespace = "", className = "")
    @ResponseWrapper(localName = "", targetNamespace = "", className = "")
    @WebResult(name = "", targetNamespace = "")

    public ResponseType sampleRequest(@WebParam(name = "", targetNamespace = "")java.lang.String str);

    }

This is invoked by the following code snippet

ResponseType response = serviceSoap.sampleRequest(str);

I want to find what is the exact soap request/response generated.

NaN
  • 101
  • 9
  • Have a look at [Tracing XML request/responses with JAX-WS](https://stackoverflow.com/questions/1945618/tracing-xml-request-responses-with-jax-ws). – Sascha May 23 '19 at 11:46

1 Answers1

0

If you are using Apache CXF you can use the classes LoggingOutInterceptor and LoggingInInterceptor:

StringWriter soapMessageWriter=new StringWriter();
LoggingOutInterceptor loi=new LoggingOutInterceptor(new PrintWriter(soapMessageWriter));
loi.setPrettyLogging(true);
ClientProxy.getClient(serviceSoap).getOutInterceptors().add(loi);
LoggingInInterceptor lii=new LoggingInInterceptor(new PrintWriter(soapMessageWriter));
lii.setPrettyLogging(true);
ClientProxy.getClient(serviceSoap).getInInterceptors().add(lii);


//do your stuff

String soapContent=soapMessageWriter.getString();
Sascha
  • 1,320
  • 10
  • 16