Axis2 Java2WSDL不必要地包装异常

时间:2013-11-23 01:12:13

标签: java wsdl axis2

我正在将Web服务从Axis迁移到Axis2,并遇到Java2WSDL没有以预期方式处理方法异常的问题。我构建了一个简单的示例服务来显示问题:

package ws.hello;

public interface HelloService
{
    public String sayHello(String name) throws Exception;
}

在Axis中使用Java2WSDL我得到了一个相当简单的WSDL。我将继续使用该WSDL,但Axis2不会从中生成客户端 - 它会抛出一个错误,它无法解析WSDL。

在Axis2中使用Java2WSDL我得到了更复杂的东西。这是有趣的部分:

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://hello.webservices" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://hello.webservices">
    <wsdl:types>
        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://hello.webservices">
            <xs:element name="HelloServiceException">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="HelloServiceException" nillable="true" type="ns:Exception"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:complexType name="Exception">
                <xs:sequence>
                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>

具体来说,问题是例外。抛出的异常与命名空间相关联,似乎包装了原始异常复杂类型。这会破坏现有客户端的任何向后兼容性。

在各种命令行参数中是否有一些东西会阻止这种情况?

0 个答案:

没有答案