【发布时间】:2013-04-16 14:17:15
【问题描述】:
如何打印发送到 Web 服务 (CXF2) 的 SOAP 请求消息?我正在使用 Eclipse。
我想查看它包含哪些字段并按照这个结构构建一个 SOAP 消息。
【问题讨论】:
-
消息是否在 SOAPMessage 对象中?
标签: java web-services soap cxf soap-client
如何打印发送到 Web 服务 (CXF2) 的 SOAP 请求消息?我正在使用 Eclipse。
我想查看它包含哪些字段并按照这个结构构建一个 SOAP 消息。
【问题讨论】:
标签: java web-services soap cxf soap-client
您只需添加一个 LoggingInterceptor :参见cxf documentation
Object implementor = new GreeterImpl();
EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service", implementor);
ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor())
或者如果你使用Springframework
<bean id="quickFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.misc.PortType"/>
<property name="address" value="${service.url}"/>
<property name="inInterceptors">
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</property>
<property name="outInterceptors">
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
</property>
</bean>
【讨论】: