2012-10-26 45 views
0

在標準eclipse java項目中,cxf.xml配置文件的正確位置在哪裏?我試圖啓用肥皂消息登錄獨立的jar格式客戶端消費者。使用wsdltojava實用程序生成工件,並使用自動生成的起點測試客戶端,它工作得很好。 我根據文檔創建了配置文件,但是在我的軟件中我看不到任何內容。 這是我的cxf.xml文件內容:CXF:無法記錄肥皂信息

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

<bean id="abstractLoggingInterceptor" abstract="true"> 
    <property name="prettyLogging" value="true"/> 
</bean> 
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" parent="abstractLoggingInterceptor"/> 
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" parent="abstractLoggingInterceptor"/> 

<cxf:bus> 
    <cxf:inInterceptors> 
     <ref bean="loggingInInterceptor"/> 
    </cxf:inInterceptors> 
    <cxf:outInterceptors> 
     <ref bean="loggingOutInterceptor"/> 
    </cxf:outInterceptors> 
    <cxf:outFaultInterceptors> 
     <ref bean="loggingOutInterceptor"/> 
    </cxf:outFaultInterceptors> 
    <cxf:inFaultInterceptors> 
     <ref bean="loggingInInterceptor"/> 
    </cxf:inFaultInterceptors> 
</cxf:bus> 

</beans> 

我試圖把它放在項目的根目錄下src,卻一無所獲。我錯過了什麼?

我的客戶端代碼是這樣的:

公共final類ClientMHttps {

private static final QName SERVICE_NAME = new  QName("http://thecompany/service-b", "myendpoint-v1"); 

private myendpointPortType port ; 

public ClientMHttps() throws java.lang.Exception { 
    URL wsdlURL = myendpointV1.WSDL_LOCATION; 

    myendpointV1 ss = new myendpointV1(wsdlURL, SERVICE_NAME); 
    port = ss.getmyendpointPortTypeEndpointHttpsM(); 




} 

    public DeleteMarkedStatusResponse do_DeleteMarkedStatus(DeleteMarkedStatusRequest _deleteMarkedStatus_body) throws java.lang.Exception 
    { 
    System.out.println("Invoking deleteMarkedStatus..."); 
    javax.xml.ws.Holder<HeaderType> _header = this.HeaderFarm(); 
    DeleteMarkedStatusResponse _deleteMarkedStatus__return = port.deleteMarkedStatus(_deleteMarkedStatus_body, _header); 
    System.out.println("deleteMarkedStatus.result=" + _deleteMarkedStatus__return); 
    return _deleteMarkedStatus__return; 


    } 

回答

0

我相信只是bean的名字和需要修復的cxf.xml位置。

在SRC /主/資源/ cxf.xml可以使用cxf.xml文件中像這樣記錄所有CXF消息:

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

    <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/> 
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> 

    <cxf:bus> 
     <cxf:inInterceptors> 
      <ref bean="logInbound"/> 
     </cxf:inInterceptors> 
     <cxf:outInterceptors> 
      <ref bean="logOutbound"/> 
     </cxf:outInterceptors> 
     <cxf:outFaultInterceptors> 
      <ref bean="logOutbound"/> 
     </cxf:outFaultInterceptors> 
     <cxf:inFaultInterceptors> 
      <ref bean="logInbound"/> 
     </cxf:inFaultInterceptors> 
    </cxf:bus> 
</beans> 
+0

沒辦法!我試圖移動cxf.xml everyware,但不工作!請記住,我創建了一個獨立的客戶端,而不是一個servlet。所以在src下我只有我的應用程序包(it.bla.etc。)。 – Muflo

+0

我也有一個獨立的客戶端,它的日誌很好,您是否嘗試將cxf.xml移動到src/main/resources /?您可以創建文件夾並將文件放在那裏,然後它應該記錄。 –

+0

我做到了,但沒有。肥皂消息記錄與缺省日誌級別有關?我的日誌記錄級別設置爲FINE – Muflo

0

一個<jaxws:client>元素應該被添加到您的Spring配置文件(CXF .xml)將創建一個CXF Web服務客戶端。然後,您需要在代碼中使用此客戶端bean來調用Web服務。

根據您要使用的日誌框架,您可能需要按照here所述配置META-INF/cxf/org.apache.cxf.Logger

我已經創建了博客文章,解釋如何更詳細地配置CXF log4jlogbacklog4j2

請注意,您還可以使用CXF日誌記錄功能,該功能不那麼冗長。

0

嘗試爲'org.apache.cxf.services'添加過濾器。

<logger level="INFO" name="org.apache.cxf.services"/> 

對於執行服務類的包,而不是爲自定義位置生成日誌記錄。