如何找到确切的肥皂请求和生成的响应。 这是我正在使用的示例代码:
@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);
我想找到确切的肥皂请求/响应是什么。
答案 0 :(得分:0)
如果您使用的是Apache CXF,则可以使用类LoggingOutInterceptor
和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();