Why does Axis2 return null values for “any” types in a complex/sequence structure when using wsdl2java?

StackOverflow https://stackoverflow.com/questions/7813419

  •  26-10-2019
  •  | 
  •  

Question

I tried using axis2 1.6 (and nightly 1.7) to generate Java code from the WSDL (very bottom of this page) using the following command:

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

This works with some outputted warnings:

[WARN] No schemaLocation for import of http://microsoft.com/wsdl/types/; compilation may fail
[WARN] No schemaLocation for import of ; compilation may fail
[WARN] Type TimeZone missing!
[WARN] Type EnumeratedValue missing!
...

Then the code compiles and runs fine without any exceptions. However, when I call #ListDispatches() (or #GetDispatch()), it will get an array of 5 dispatches, but all of the data in each dispatch will have null values, specifically #getIdentifier(), #getClient(), #getSupplier(), etc. for each dispatch will be null.

I believe this has to do with the BaseModel (and EnumeratedValue and FlagValue) using "any" types in the schema. This WSDL was provided to us by the customer, so we would like to take the path of least resistance. What are the least amount of changes we would need to make to the WSDL/etc. to get this to work? The raw XML does have values in it, using this method to get the raw XML data:

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

I've tried changing the "any" types (3 lines) to be elements of types anyType/String and removing them completely -- but no dice. I've tried using xmlbeans instead of adb, but it just throws an exception about malformed attributes when I call wsdl2java. I've also tried passing -Eosv and -b to wsdl2java. Lastly, I've tried setting various options:

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

Please help! Thanks!

test.wsdl (removed parts of file in order to make character cap):

<?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>
Was it helpful?

Solution

Ultimately, I ended up just having the customer change their WSDL appropriately to remove the "any" types, and it now works.

However, I think I could have resolved this using the JAXB databinding as I've read it has the "best" implementation of "any" types, but because there was already a lot of development relying on the ADB databinding, I didn't want to change this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top