2016-11-23 6 views
0

WSDLスキーマからPOJOを生成しましたが、エラーは適切な@Webfault例外にマップされていないようです。 AXLErrorの代わりにServerSOAPFaultExceptionが届きます。SOAP - 適切な@WebFault例外の代わりにServerSOAPFaultExceptionがスローされる

生成された例外ファイル:

package com.cisco.axlapiservice; 

import javax.xml.ws.WebFault; 


/** 
* This class was generated by Apache CXF 3.1.8 
* 2016-11-13T14:30:37.692+02:00 
* Generated source version: 3.1.8 
*/ 

@WebFault(name = "axlError", targetNamespace = "http://www.cisco.com/AXL/API/11.5") 
public class AXLError extends Exception { 

    private com.cisco.axl.api._11.AXLError axlError; 

    public AXLError() { 
     super(); 
    } 

    public AXLError(String message) { 
     super(message); 
    } 

    public AXLError(String message, Throwable cause) { 
     super(message, cause); 
    } 

    public AXLError(String message, com.cisco.axl.api._11.AXLError axlError) { 
     super(message); 
     this.axlError = axlError; 
    } 

    public AXLError(String message, com.cisco.axl.api._11.AXLError axlError, Throwable cause) { 
     super(message, cause); 
     this.axlError = axlError; 
    } 

    public com.cisco.axl.api._11.AXLError getFaultInfo() { 
     return this.axlError; 
    } 
} 

応答は、サーバから返さ:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
     <soapenv:Fault> 
     <faultcode>soapenv:Client</faultcode> 
     <faultstring>Cannot insert or update pattern. A DN exists with the same pattern and partition.</faultstring> 
     <detail> 
      <axlError> 
       <axlcode>4052</axlcode> 
       <axlmessage>Cannot insert or update pattern. A DN exists with the same pattern and partition.</axlmessage> 
       <request>addLine</request> 
      </axlError> 
     </detail> 
     </soapenv:Fault> 
    </soapenv:Body> 
</soapenv:Envelope> 

次の例外がスローされます。私は受信しない理由

com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Cannot insert or update pattern. A DN exists with the same pattern and partition. Please see the server log to find more detail regarding exact cause of the failure. 
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178) 
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:124) 
    at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238) 
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189) 
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147) 
    at com.sun.proxy.$Proxy135.addLine(Unknown Source) 
    at com.company.product.provisioning.AxlApi.addLine(AxlApi.java:243) 
... 

あなたは私をポイントしてもらえAXLError

+1

これは、@ WebFaultをマップするCXFの標準的な方法です。 WebFaultを受け取るWebServiceメソッドを試してみると、 'AXLError'例外が発生します。この例外には、' com.cisco.axl.api._11.AXLError getFaultInfo() 'の詳細が含まれます。何が問題ですか? – pedrofb

+0

残念ながら、それは 'AXLError'の代わりに' ServerSOAPFaultException'をスローします。 –

+0

スタックトレースを投稿すると便利です – pedrofb

答えて

1

これは@WebFaultをマッピングするCXFの標準的な方法です。 WebFaultを受け取るWebServiceメソッドを試してみると、エラーの詳細が含まれるAXLError例外が発生します。

スタックトレースで呼び出されるCXFクラスが表示されません。クライアントがJDKに含まれるJAX-WSの内部実装を使用しているようです。おそらくCXF jarをランタイム依存関係に追加するのを忘れていたでしょうか? mavenを使用している場合は、次のスニペットでクラスパスに追加できます。

<properties> 
    <cxf.version>3.1.8</cxf.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxws</artifactId> 
     <version>${cxf.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http</artifactId> 
     <version>${cxf.version}</version> 
    </dependency> 
    <!-- Jetty is needed if you're are not using the CXFServlet --> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http-jetty</artifactId> 
     <version>${cxf.version}</version> 
    </dependency> 
</dependencies> 
関連する問題