[英]How to enable pretty logging of SOAP messages in JBoss 7
I have enabled SOAP logging by adding following in standalone.xml as described in Jboss Advanced User Guide : 我已经通过在standalone.xml中添加以下内容来启用SOAP日志记录,如Jboss高级用户指南中所述 :
<system-properties>
<property name="org.apache.cxf.logging.enabled" value="true"/>
</system-properties>
This configuration does not pretty print XML messages. 此配置并不能完全打印XML消息。 I am sure that CXF supports pretty printing since there is a
AbstractLoggingInterceptor.setPrettyLogging()
method in the library. 我确信CXF支持漂亮的打印,因为库中有一个
AbstractLoggingInterceptor.setPrettyLogging()
方法。
How can I enable pretty printing of SOAP requests and responses in JBoss 7. 如何在JBoss 7中启用SOAP请求和响应的漂亮打印。
Even though Serdal's answer is correct, it does not look practical to me. 虽然塞尔达尔的答案是正确的,但对我来说这看起来并不实用。
My solution 我的解决方案
I removed org.apache.cxf.logging.enabled
system property and used following code to enable SOAP logging: 我删除了
org.apache.cxf.logging.enabled
系统属性并使用以下代码启用SOAP日志记录:
Client client = ClientProxy.getClient(port);
LoggingInInterceptor inInterceptor = new LoggingInInterceptor();
inInterceptor.setPrettyLogging(true);
client.getInInterceptors().add(inInterceptor);
LoggingOutInterceptor outInterceptor = new LoggingOutInterceptor();
outInterceptor.setPrettyLogging(true);
client.getOutInterceptors().add(outInterceptor);
Using org.apache.cxf.logging.enabled property is the right way, it accepts value "pretty" for nicely formatted xml output 使用org.apache.cxf.logging.enabled属性是正确的方法,它接受值“漂亮”的格式很好的xml输出
<system-properties>
<property name="org.apache.cxf.logging.enabled" value="pretty"/>
</system-properties>
For details see https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java#L68-L72 有关详细信息,请参阅https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java#L68-L72
I was able to pretty print and also to increase limit size of XML response from Webservice by doing the following: 通过执行以下操作,我能够打印并且还可以通过Webservice增加XML响应的限制大小:
wsdlLocationURL = new URL(productServiceURLStr);
ServiceFacadeBeanService serviceFacade =
new ServiceFacadeBeanService(wsdlLocationURL, SERVICE_FACADE_QNAME);
ServiceFacade sfPort = serviceFacade.getServiceFacadeBeanPort();
Client client = ClientProxy.getClient(sfPort);
List<Interceptor<? extends Message>> ics = client.getBus().getOutInterceptors();
for (Interceptor ic: ics) {
if (ic instanceof LoggingOutInterceptor) {
LoggingOutInterceptor out = (LoggingOutInterceptor) ic;
out.setPrettyLogging(true);
out.setLimit(1024 * 1024 *1024);
}
}
Use below mentioned annotations with your web service . 在您的Web服务中使用下面提到的注释。
@InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor")
@OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor")
@InFaultInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor")
@OutFaultInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor")
@Logging(pretty = true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.