How to enable beautiful SOAP message recording in JBoss 7

I enabled SOAP writing by adding the following to the standalone.xml file as described in the Advanced Jboss User Guide :

<system-properties>
  <property name="org.apache.cxf.logging.enabled" value="true"/>
</system-properties>

      

This configuration doesn't print XML messages very well. I'm pretty sure CXF supports pretty printable as there is a method in the library AbstractLoggingInterceptor.setPrettyLogging()

.

How to enable fine printing of SOAP requests and responses in JBoss 7.

+3


source to share


4 answers


While Serdal's answer is correct, it doesn't seem practical to me.

My decision



I removed the system property org.apache.cxf.logging.enabled

and used the following code to enable SOAP registration:

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

      

+1


source


Using the org.apache.cxf.logging.enabled property is the correct way, it takes the value "pretty" for nicely formatted XML output

<system-properties>
  <property name="org.apache.cxf.logging.enabled" value="pretty"/>
</system-properties>

      



See https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java#L68-L72 for details

+1


source


I was able to quite print and also increase the size limit of the XML response from the Webservice by doing the following:

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

      

0


source


Use the below annotations with web service.

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

      

0


source







All Articles