5 Replies Latest reply: Feb 21, 2012 10:32 AM by Patcha RSS

    [Eclipse - Axis] Generate Client from wsld, wrong type for unbounded elemen

    Patcha
      Hi all!
      I'm not expert on wsdl format, but in my work activities I have to take wsdl they send to me and generate Java code in Eclipse.

      One of last wsdl they sent to me contains the following element:
      <xs:element ref="ns0:CodicePraticaDistributore" minOccurs="0" maxOccurs="unbounded"/>
      where ns0:CodicePraticaDistributore is:
      <xs:element name="CodicePraticaDistributore" type="ns0:CodPratica"/>
      and ns0:CodPratica is:
      <xs:simpleType name="CodPratica">
           <xs:restriction base="xs:string">
                <xs:maxLength value="15"/>
           </xs:restriction>
      </xs:simpleType>
      (Sorry I don't report whole wsdl... but it's VERY long!)

      When I do right click on the wsdl and follow Web Services - Generate Client and so on... the generated class contain following lines:
      elemField.setXmlName(new javax.xml.namespace.QName("http://xmlns.a2a.eu/Unbundling/documentum/schema/DocumentalePrestazione", "CodicePraticaDistributore"));
      elemField.setXmlType(new javax.xml.namespace.QName("http://xmlns.a2a.eu/Unbundling/documentum/schema/DocumentalePrestazione", "CodicePraticaDistributore"));
      Which are wrong, 'cause the second argument for setXmlType should be CodPratica and not CodicePraticaDistributore.
      The right one should be:
      elemField.setXmlName(new javax.xml.namespace.QName("http://xmlns.a2a.eu/Unbundling/documentum/schema/DocumentalePrestazione", "CodicePraticaDistributore"));
      elemField.setXmlType(new javax.xml.namespace.QName("http://xmlns.a2a.eu/Unbundling/documentum/schema/DocumentalePrestazione", "CodPratica"));
      This makes Axis generate wrong xml, with addition of xsi:type="xsd:string" which makes the other system (where I send xml) to return me an error for bad xml format.
      The generated xml code for this data is:
      <CodicePraticaDistributore xsi:type="xsd:string">PN100000000110E</CodicePraticaDistributore>
      While it should be simply:
      <CodicePraticaDistributore>PN100000000110E</CodicePraticaDistributore>
      I can't understand how to resolve this behaviour on Java generation (other than modifying the final generated Java Class).
      Can you help me?