Hi,
 
I'm having a problem with wsdl2java generating client stubs when the return value has an array.  When I make a call to the service, I get the exception:
 
org.xml.sax.SAXException: Invalid element in test.array.Role - item
 at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:227)
 at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:1001)
 at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:159)
 at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1050)
 
I'm running wsdl2java on the following wsdl:
 
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:array.test" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:array.test" xmlns:intf="urn:array.test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2beta
Built on Mar 31, 2004 (12:47:03 EST)-->
 <wsdl:types>
  <schema targetNamespace="urn:array.test" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="role">
    <sequence>
     <element name="roleValue" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="ArrayOfrole">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:role[]"/>
     </restriction>
    </complexContent>
   </complexType>
   <complexType name="person">
    <sequence>
     <element name="roles" nillable="true" type="impl:ArrayOfrole"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>
   <wsdl:message name="getPersonRequest">
   </wsdl:message>
   <wsdl:message name="getPersonResponse">
      <wsdl:part name="getPersonReturn" type="impl:person"/>
   </wsdl:message>
   <wsdl:portType name="ArrayTestWebService">
      <wsdl:operation name="getPerson">
         <wsdl:input message="impl:getPersonRequest" name="getPersonRequest"/>
         <wsdl:output message="impl:getPersonResponse" name="getPersonResponse"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="ArrayTestSoapBinding" type="impl:ArrayTestWebService">
      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="getPerson">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getPersonRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="getPersonResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:array.test" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="ArrayTest">
      <wsdl:port binding="impl:ArrayTestSoapBinding" name="ArrayTest">
         <wsdlsoap:address location="http://localhost:8080/axis/services/ArrayTest"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>
 
 
The constructor of the generated stub (ArrayTestSoapBindingStub.java)  has the code:
 
qName = new javax.xml.namespace.QName("urn:array.test", "ArrayOfrole");
cachedSerQNames.add(qName);
cls = test.array.Role[].class;
cachedSerClasses.add(cls);
cachedSerFactories.add(arraysf);
cachedDeserFactories.add(arraydf);
 
I believe this is incorrect and should instead be:
 
qName = new javax.xml.namespace.QName("urn:array.test", "roles");
cachedSerQNames.add(qName);
cls = test.array.Role[].class;
cachedSerClasses.add(cls);
cachedSerFactories.add(arraysf);
cachedDeserFactories.add(arraydf);
 
If I make that change, I am able to call the webservice with no problems.  I'd like to not have to "manually" make that change as I am generating the stubs as part of a build process. 
 
For reference, this is the SOAP response that comes from the server:
 
HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Date: Wed, 01 Sep 2004 17:22:00 GMT
Server: Apache-Coyote/1.1
Connection: close
 
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <ns1:getPersonResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://DefaultNamespace">
   <getPersonReturn href=""/>
  </ns1:getPersonResponse>
  <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:array.test">
   <roles soapenc:arrayType="ns2:role[2]" xsi:type="ns2:roles">
    <item href=""/>
    <item href=""/>
   </roles>
  </multiRef>
  <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:role" xmlns:ns3="urn:array.test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <roleValue xsi:type="soapenc:string">user</roleValue>
  </multiRef>
  <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:role" xmlns:ns4="urn:array.test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <roleValue xsi:type="soapenc:string">admin</roleValue>
  </multiRef>
 </soapenv:Body>
</soapenv:Envelope>
 
Is this a known bug or am I missing something obvious?  I'm using Axis1.2beta3.
Thanks in advance for any ideas.
 
-Brian


Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Reply via email to