Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5443

WSDL2C: incomplete code in axis2_extension_mapper.c for xsd choice type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6.0, 1.6.1, 1.6.2
    • 1.5.6
    • codegen, databinding
    • None
    • MacOS X 10.7.5

      $ java -version
      java version "1.6.0_37"
      Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
      Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

    Description

      I'm trying to build an ANSI C xml (de)serializer for an xml schema using axis2c and axis2.
      The xml schema contains serveral choice elements.

      The xml deserializer build by axis2 WSDL2C has problems parsing these choice elements.

      The root cause is missing internal choice types in the generated axis2_extension_mapper.c file.

      Here's an example which reproduces the problem:

      bug.xsd schema file (contains a choice element)
      --------------------------------------------------------------------------------
      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <xs:schema xmlns="urn:axis2:choice:bug" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:axis2:choice:bug">
      <xs:element name="Document" type="Document"/>

      <xs:complexType name="Document">
      <xs:sequence>
      <xs:choice>
      <xs:element name="IBAN" type="IBAN2007Identifier"/>
      <xs:element name="Othr" type="GenericAccountIdentification1"/>
      </xs:choice>
      </xs:sequence>
      </xs:complexType>

      <xs:complexType name="GenericAccountIdentification1">
      <xs:sequence>
      <xs:element name="Id" type="Max34Text"/>
      </xs:sequence>
      </xs:complexType>

      <xs:simpleType name="IBAN2007Identifier">
      <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z]

      {2,2}[0-9]{2,2}

      [a-zA-Z0-9]

      {1,30}

      "/>
      </xs:restriction>
      </xs:simpleType>

      <xs:simpleType name="Max34Text">
      <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:maxLength value="34"/>
      </xs:restriction>
      </xs:simpleType>
      </xs:schema>
      --------------------------------------------------------------------------------

      bug.wsdl, references the bug.xsd schema file
      --------------------------------------------------------------------------------
      <definitions targetNamespace="http://localhost/bug/wsdl"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="http://localhost/bug/wsdl"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:types="urn:axis2:choice:bug"
      >

      <import namespace="urn:axis2:choice:bug" location="bug.xsd" />

      <message name="getReq">
      <part name="parameters" element="types:Document" />
      </message>

      <message name="getResp">
      <part name="parameters" element="types:Document" />
      </message>

      <portType name="PortType">
      <operation name="get">
      <input message="tns:getReq" />
      <output message="tns:getResp" />
      </operation>
      </portType>

      <binding name="SOAPBinding" type="tns:PortType">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
      <operation name="get">
      <soap:operation style="document" soapAction="get" />
      <input>
      <soap:body use="literal" />
      </input>
      <output>
      <soap:body use="literal" />
      </output>
      </operation>
      </binding>

      <service name="Service">
      <port name="SOAPPort" binding="tns:SOAPBinding">
      <soap:address location="http://localhost:8080/axis2/services/Service" />
      </port>
      </service>

      </definitions>
      --------------------------------------------------------------------------------

      And a sample xml document, bug.xml
      --------------------------------------------------------------------------------
      <Document xmlns="urn:axis2:choice:bug" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:axis2:choice:bug bug.xsd">
      <IBAN>DE1234</IBAN>
      </Document>
      --------------------------------------------------------------------------------

      Now I generate the ANSI C xml (de)serializer code using WSDL2C,
      axis2c-bin-1.7.0-linux/bin/tools/wsdl2c/WSDL2C.sh -uri bug.wsdl -d adb -u -S bug

      And finally a simple test program to call the generated xml deserializer for the <Document> root element:
      --------------------------------------------------------------------------------
      #include <stdio.h>
      #include <axiom.h>
      #include <axis2_util.h>
      #include <axiom_stax_builder.h>
      #include "adb_Document.h"

      int
      main(int argc, char **argv)
      {
      char *filename = "bug.xml";
      const axutil_env_t *env = NULL;
      axis2_status_t st;
      axiom_node_t* parent = NULL;
      axis2_bool_t is_early_node_valid;
      axiom_xml_reader_t *parser;
      axiom_stax_builder_t *builder;
      axiom_document_t *doc;
      adb_Document_t* Document;

      env = axutil_env_create_all("/tmp/axis.log", AXIS2_LOG_LEVEL_TRACE);

      if (argv[1] != NULL)
      filename = argv[1];

      parser = axiom_xml_reader_create_for_file(env, filename, AXIS2_UTF_8);
      if (parser == NULL)

      { fprintf(stderr, "failed to create parser for %s\n", filename); exit(1); }

      builder = axiom_stax_builder_create(env, parser);
      doc = axiom_stax_builder_get_document(builder, env);
      parent = axiom_document_get_root_element(doc, env);

      Document = adb_Document_create(env);
      st = adb_Document_deserialize(Document, env, &parent, &is_early_node_valid, 0);

      if (st == AXIS2_SUCCESS)
      printf("OK\n");
      else
      printf("status=%d\n", st),

      exit(0);
      }
      --------------------------------------------------------------------------------

      The parser fails with the following error message:

      $ cat /tmp/axis.log
      [Sun Oct 28 15:15:36 2012] [error] adb_Document.c(263) failed in building adb object for element DocumentChoice_type0
      [Sun Oct 28 15:15:36 2012] [error] adb_Document.c(273) failed in setting the value for DocumentChoice_type0

      When I look at the generated axis2_extension_mapper.c file, I notice that there are several places
      that handle the "adb_Document" type, but the internal "adb_DocumentChoice_type0" type is missing.

      As soon as I manually add "adb_DocumentChoice_type0" to the generated file
      axis2_extension_mapper.c I get a working xml deserializer.

      Workaround: Use axis2 1.5.6 - the old axis2 1.5.6 WSDL2C is able to produce a working xml
      deserializer

      Attachments

        1. test.c
          1 kB
          Jürgen Keil
        2. bug.xsd
          1 kB
          Jürgen Keil
        3. bug.xml
          0.2 kB
          Jürgen Keil
        4. bug.wsdl
          1 kB
          Jürgen Keil

        Activity

          People

            Unassigned Unassigned
            jkeil Jürgen Keil
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: