1

我尝试使用axis2 1.6(和nightly 1.7)使用以下命令从WSDL(本页最底部)生成Java代码:

$ export JAVA_HOME=/usr/java/default
$ wsdl2java.sh -uri test.wsdl -d adb -u -S src/ -p mypackage --noBuildXML

这适用于一些输出的警告:

[警告] 没有用于导入http://microsoft.com/wsdl/types/的 schemaLocation ;编译可能失败
[WARN] No schemaLocation for import of ; 编译可能会失败
[WARN] 类型 TimeZone 缺失!
[警告] 类型 EnumeratedValue 缺失!
...

然后代码编译并运行良好,没有任何异常。然而,当我调用#ListDispatches()(或#GetDispatch())时,它会得到一个包含5个dispatch的数组,但是每个dispatch中的所有数据都会有空值,特别是#getIdentifier()、#getClient()、每次调度的#getSupplier() 等都将为空。

我相信这与在模式中使用“任何”类型的 BaseModel(以及 EnumeratedValue 和 FlagValue)有关。这个WSDL是客户提供给我们的,所以我们想走阻力最小的路。我们需要对 WSDL/等进行的最少更改是多少?让它工作?原始 XML 中确实包含值,使用此方法获取原始 XML 数据:

responseItem.getOMElement(Response.MY_QNAME,OMAbstractFactory.getOMFactory()).toStringWithConsume();

我尝试将“任何”类型(3 行)更改为 anyType/String 类型的元素并完全删除它们——但没有骰子。我尝试过使用 xmlbeans 而不是 adb,但是当我调用 wsdl2java 时,它只会引发关于格式错误的属性的异常。我也尝试将 -Eosv 和 -b 传递给 wsdl2java。最后,我尝试设置各种选项:

stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.SERVICE_TCCL,Constants.TCCL_COMPOSITE);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_REST,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.CONTENT_TYPE,"application/x-www-form-urlencoded");
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE,"application/x-www-form-urlencoded");

请帮忙!谢谢!

test.wsdl(删除部分文件以制作字符上限):

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/">
      <s:import namespace="http://microsoft.com/wsdl/types/" />
      <s:import />
      <s:complexType name="Response">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Code" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Data" type="tns:ArrayOfDataItem" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ArrayOfDataItem">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="DataItem" nillable="true" type="tns:DataItem" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="DataItem">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Value" type="s:string" />
        </s:sequence>
        <s:attribute name="Key" type="s:string" />
      </s:complexType>
      <s:element name="GetDispatch">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="id" type="s1:guid" />
            <s:element minOccurs="0" maxOccurs="1" name="authNo" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="GetDispatchResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetDispatchResult" type="tns:DispatchResponseItem" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="DispatchResponseItem">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Response" type="tns:Response" />
          <s:element minOccurs="0" maxOccurs="1" name="Dispatch" type="tns:Dispatch" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="Dispatch">
        <s:complexContent mixed="false">
          <s:extension base="tns:BaseModel">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="1" name="Identifier" type="tns:Identifier" />
              <s:element minOccurs="0" maxOccurs="1" name="ParentDispatch" type="tns:Identifier" />
              <s:element minOccurs="0" maxOccurs="1" name="Client" type="tns:ClientItem" />
              <s:element minOccurs="0" maxOccurs="1" name="Supplier" type="tns:SupplierItem" />
              <s:element minOccurs="0" maxOccurs="1" name="VanBase" type="tns:VanBaseItem" />
              <s:element minOccurs="0" maxOccurs="1" name="TimeZone" type="TimeZone" />
              <s:element minOccurs="0" maxOccurs="1" name="Profile" type="tns:DispatchProfile" />
              <s:element minOccurs="0" maxOccurs="1" name="Communication" type="tns:CommuniqueList" />
              <s:element minOccurs="0" maxOccurs="1" name="Legs" type="tns:LegList" />
              <s:element minOccurs="0" maxOccurs="1" name="Authorizations" type="tns:AuthorizationList" />
              <s:element minOccurs="0" maxOccurs="1" name="Events" type="tns:EventList" />
              <s:element minOccurs="0" maxOccurs="1" name="SupplierProfile" type="tns:SupplierProfile" />
              <s:element minOccurs="0" maxOccurs="1" name="Cancellation" type="tns:CancelInfo" />
              <s:element minOccurs="0" maxOccurs="1" name="Created" type="tns:CreationInfo" />
              <s:element minOccurs="0" maxOccurs="1" name="Modified" type="tns:ModifiedInfo" />
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
      <s:complexType name="BaseModel" abstract="true">
        <s:sequence>
          <s:any minOccurs="0" maxOccurs="unbounded" />
        </s:sequence>
        <s:attribute name="Type" type="s:string" />
      </s:complexType>
      <s:complexType name="Identifier">
        <s:complexContent mixed="false">
          <s:extension base="tns:BaseModel">
            <s:sequence>
              <s:element minOccurs="1" maxOccurs="1" name="Id" type="s1:guid" />
              <s:element minOccurs="0" maxOccurs="1" name="AuthNo" type="s:string" />
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
      <s:element name="ListDispatches">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="utcModifiedSince" type="s:dateTime" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ListDispatchesResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="ListDispatchesResult" type="tns:DispatchListResponseItem" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="DispatchListResponseItem">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Response" type="tns:Response" />
          <s:element minOccurs="0" maxOccurs="1" name="Dispatches" type="tns:ArrayOfDispatch" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ArrayOfDispatch">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="Dispatch" nillable="true" type="tns:Dispatch" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="FlagInfo">
        <s:complexContent mixed="false">
          <s:extension base="tns:BaseModel">
            <s:sequence>
              <s:element minOccurs="1" maxOccurs="1" name="Id" type="s1:guid" />
              <s:element minOccurs="0" maxOccurs="1" name="SortCode" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
    </s:schema>
    <s:schema elementFormDefault="qualified" targetNamespace="http://microsoft.com/wsdl/types/">
      <s:simpleType name="guid">
        <s:restriction base="s:string">
          <s:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
        </s:restriction>
      </s:simpleType>
    </s:schema>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" id="EnumeratedValue" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="EnumeratedValue">
        <xs:sequence>
          <xs:any minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Value" type="xs:int" use="required" />
      </xs:complexType>
      <xs:complexType name="FlagValue">
        <xs:sequence>
          <xs:any minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Value" type="xs:int" use="required" />
      </xs:complexType>
      <xs:complexType name="TimeZone">
        <xs:sequence>
          <xs:element minOccurs="1" maxOccurs="1" name="Index" type="xs:int" />
          <xs:element minOccurs="0" maxOccurs="1" name="Name">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:maxLength value="64" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element minOccurs="0" maxOccurs="1" name="DisplayName">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:maxLength value="64" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element minOccurs="0" maxOccurs="1" name="Info" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="GetDispatchSoapIn">
    <wsdl:part name="parameters" element="tns:GetDispatch" />
  </wsdl:message>
  <wsdl:message name="GetDispatchSoapOut">
    <wsdl:part name="parameters" element="tns:GetDispatchResponse" />
  </wsdl:message>
  <wsdl:message name="ListDispatchesSoapIn">
    <wsdl:part name="parameters" element="tns:ListDispatches" />
  </wsdl:message>
  <wsdl:message name="ListDispatchesSoapOut">
    <wsdl:part name="parameters" element="tns:ListDispatchesResponse" />
  </wsdl:message>
  <wsdl:portType name="DispatchSoap">
    <wsdl:operation name="GetDispatchId">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;dd&gt;Returns a unique identifier for a dispatch by its authorization number.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Parameters&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;authNo:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;String representing the authorization number that is a human readable identifier&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Returns&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td colspan='3'&gt;&lt;i&gt;Response Code:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;200 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;OK.  Response will contain the a unique identifier for the dispatch.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;403 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Forbidden.  Assigned to a different supplier or is unassigned.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;404 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Not Found.  Dispatch was not found.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;500 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Internal Server Error.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;DispatchId:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;The dispatch's unique identifier if successful.  An empty unique identifier (00000000-0000-0000-0000-000000000000) in case of exception.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;</wsdl:documentation>
      <wsdl:input message="tns:GetDispatchIdSoapIn" />
      <wsdl:output message="tns:GetDispatchIdSoapOut" />
    </wsdl:operation>
    <wsdl:operation name="GetDispatch">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;dd&gt;Returns a dispatch based on the dispatch's unique identifier or authorization number.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Parameters&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;id:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;The dispatch unique identifier&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;authNo:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;String representing the authorization number that is a human readable identifier&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Returns&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td colspan='3'&gt;&lt;i&gt;Response Code:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;200 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;OK.  Response will contain the dispatch.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;403 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Forbidden.  Assigned to a different supplier or is unassigned.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;404 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Not Found.  Dispatch was not found.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;500 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Internal Server Error.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;Dispatch:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;The associated dispatch if successful.  Null (or Nothing) in case of exception.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;</wsdl:documentation>
      <wsdl:input message="tns:GetDispatchSoapIn" />
      <wsdl:output message="tns:GetDispatchSoapOut" />
    </wsdl:operation>
    <wsdl:operation name="ListDispatches">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;dd&gt;Returns a list of active dispatches that have been modified since the provided date and time.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Parameters&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;lastUtcModifiedTime:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;The UTC date and time that a dispatch was last modified.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Returns&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td colspan='3'&gt;&lt;i&gt;Response Code:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;200 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;OK.  Response will contain the list of dispatches.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width='20'&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;500 - &lt;/i&gt;&lt;/td&gt;&lt;td&gt;Internal Server Error.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;&lt;dd&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;Dispatches:&amp;nbsp;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;The list of dispatches if successful.  Null (or Nothing) in case of exception.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/dd&gt;</wsdl:documentation>
      <wsdl:input message="tns:ListDispatchesSoapIn" />
      <wsdl:output message="tns:ListDispatchesSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="DispatchSoap" type="tns:DispatchSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetDispatch">
      <soap:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/GetDispatch" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ListDispatches">
      <soap:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/ListDispatches" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="DispatchSoap12" type="tns:DispatchSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetDispatch">
      <soap12:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/GetDispatch" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ListDispatches">
      <soap12:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/ListDispatches" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Dispatch">
    <wsdl:port name="DispatchSoap" binding="tns:DispatchSoap">
      <soap:address location="https://demo.ljkco.com/webservices/suppliers/coachusa/dispatch.asmx" />
    </wsdl:port>
    <wsdl:port name="DispatchSoap12" binding="tns:DispatchSoap12">
      <soap12:address location="https://demo.ljkco.com/webservices/suppliers/coachusa/dispatch.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
4

1 回答 1

0

最终,我只是让客户适当地更改他们的 WSDL 以删除“任何”类型,它现在可以工作了。

但是,我认为我可以使用 JAXB 数据绑定来解决这个问题,因为我已经读过它具有“任何”类型的“最佳”实现,但是因为已经有很多开发依赖于 ADB 数据绑定,所以我没有想改变这一点。

于 2012-06-25T15:24:03.630 回答