2016-06-13 24 views
0

サーバーからの発信SOAPメッセージのログに問題があります。 handleMessageメソッドは、メッセージの内容を期待どおりに上書きしません。送信SOAPをメッセージにどのように格納するのですか?CXFログSOAP出力

public class OutgoingSoapInterceptor extends AbstractPhaseInterceptor<Message> { 
    private static final Logger logger = LoggerFactory.getLogger(OutgoingSoapInterceptor.class.getName()); 

    public OutgoingSoapInterceptor() 
    { 
     super(Phase.PRE_STREAM); 
    } 

    @Override 
    public void handleMessage(Message message) throws Fault { 
     logger.debug("outbound soap handleMessage"); 

     OutputStream os = message.getContent (OutputStream.class); 
     CacheAndWriteOutputStream cwos = new CacheAndWriteOutputStream (os); 
     message.setContent (OutputStream.class, cwos); 

     cwos.registerCallback (new LoggingOutCallBack ()); 
    } 
} 

答えて

1

<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" /> 

    <cxf:bus> 
     <cxf:features> 
      <cxf:logging /> 
     </cxf:features> 
    </cxf:bus> 

    <jaxws:endpoint ... />   
</beans> 

How to log Apache CXF Soap Request and Soap Response using Log4j

でより多くの例を参照してください春に <cxf:bus>にCXF LoggingInInterceptorLoggingOutInterceptor

LogUtils.setLoggerClass(org.apache.cxf.common.logging.Log4jLogger.class); 

    yourService = new YourService(wsdlURL, SERVICE_NAME); 
    port = yourService.getServicePort(); 

    Client client = ClientProxy.getClient(port); 
    client.getInInterceptors().add(new LoggingInInterceptor()); 
    client.getOutInterceptors().add(new LoggingOutInterceptor()); 

または設定インターセプタを使用してSOAPメッセージをログに記録する簡単な方法があります

+0

これは私をriに置いたghtパス。このプロセスで、私はこのシステムプロパティを実行しました:https://docs.jboss.org/author/display/WFLY8/Advanced+User+Guide#AdvancedUserGuide-Systemproperty – Jim

+0

私はそのプロパティを知らなかった。私はそれがcxfまたは自分のjbossの標準であるかどうかわからない – pedrofb

関連する問題