SOAP-抛出ServerSOAPFaultException而不是相应的@WebFault异常 [英] SOAP - ServerSOAPFaultException is thrown instead of appropriate @WebFault exception

查看:1154
本文介绍了SOAP-抛出ServerSOAPFaultException而不是相应的@WebFault异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从WSDL模式生成了POJO,但是错误似乎并未映射到适当的 @Webfault 异常。我没有收到 AXLError ,而是收到了 ServerSOAPFaultException

I have generated POJO's from WSDL schema, but errors don't seem to be mapped to appropriate @Webfault exception. Instead of getting AXLError I receive ServerSOAPFaultException.

Generated例外文件:

Generated exception file:

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

Could you please point me why I never receive an AXLError?

推荐答案

这是CXF映射 @WebFault 。如果尝试/捕获接收到WebFault的WebService方法,它将引发 AXLError 异常,该异常将在 com中包含故障的详细信息。 cisco.axl.api._11.AXLError getFaultInfo()。

This is CXF's standard way to map a @WebFault. If you try/catch a WebService method which receives a WebFault, it will raise a AXLError exception, which will contain the details of the fault in com.cisco.axl.api._11.AXLError getFaultInfo().

我看不到在堆栈跟踪中调用的CXF类。看来您的客户正在使用JDK中包含的JAX-WS的内部实现。也许您忘记了将CXF jar添加到运行时依赖项?如果您使用maven,则可以使用以下代码段将它们添加到类路径中:

I do not see the CXF classes being invoked in stack trace. Seems your client is using the internal implementation of JAX-WS included in JDK. Perhaps you have forgotten to add the CXF jars to the runtime dependencies? If you use maven, you can add them to your classpath with the following snippet:

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

这篇关于SOAP-抛出ServerSOAPFaultException而不是相应的@WebFault异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆