查找创建的确切肥皂请求和响应xml

时间:2019-05-23 06:26:40

标签: java soap jax-ws

如何找到确切的肥皂​​请求和生成的响应。 这是我正在使用的示例代码:

@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);

    }

这由以下代码段调用

ResponseType response = serviceSoap.sampleRequest(str);

我想找到确切的肥皂​​请求/响应是什么。

1 个答案:

答案 0 :(得分:0)

如果您使用的是Apache CXF,则可以使用类LoggingOutInterceptorLoggingInInterceptor

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();