How to make CXF Logging function work with SOAP messages?

I have a registration for CXF. It is successfully registered using log4j. As a test, I changed the settings in log4j.properties , where the root log is set to INFO .

Adding log4j.logger.org.apache.cxf=DEBUG, C forces CXF to be logged in the log file. However, SOAP messages are not logged when they reach the server. I configured cxf.xml as a guide . The file is as follows:

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <cxf:bus> <cxf:features> <cxf:logging /> </cxf:features> </cxf:bus> </beans> 

This file, packaged in .war, is located in /WEB-INF/classes/cxf.xml . Based on my reading, this is all that is needed for CXF to start registering incoming and outgoing messages.

I have:

  • Successfully replaced log4j as the default CXF logger.
  • Added logging function to cxf bus.
  • Ensure that CXF components can register.
  • In addition, specific registrars are indicated as valid:

     log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=DEBUG, C log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=DEBUG, C 

However, crude soap messages do not want to register. What am I doing wrong?

edit: add web.xml and applicationContext.xml on request

web.xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>cxf</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cxf</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <session-config> <session-timeout>60</session-timeout> </session-config> </web-app> 

applicationContext.xml

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd" default-dependency-check="none" default-lazy-init="false"> <!-- Load the needed resources that are present in the cxf* jars --> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <!--Endpoint Info is below here --> </beans> 
+4
source share
1 answer

Have you tried adding it to your WEB-INF / cxf-servlet.xml? The following configuration works for logging messages on the server side.

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <cxf:bus> <cxf:features> <cxf:logging /> </cxf:features> </cxf:bus> <jaxws:endpoint ... /> </beans> 

This assumes that you are declaring your services according to CXF Writing a Service Using Spring .

As for cxf.xml, I believe that this could be for client configuration, although I could not find supporting documentation.

+3
source

Source: https://habr.com/ru/post/1481057/


All Articles