WSDL2Java recurses infinitely in the SchemaCompiler when it encounters
recursion in the type definitions, e.g. for this single type:

    <xsd:schema targetNamespace="test">
      <xsd:element name="recursiveElement" type="recursive"/>
      <xsd:complexType name="recursive">
        <xsd:sequence>
          <xsd:element name="sub" type="test:recursive" minOccurs="0"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>

This definition validly describes a data strcuture like this one:

<recursive>
    <sub>
        <sub/>
    </sub>
</recursive>

The attached WSDL file is a simple standalone example that causes the
infinite recursion.

Is there any way to do this, or is this a bug in axis2, or am I somehow
confused?  It looks to me like the fix could be as simple as adding the
name of the complexType being processed to the processedTypemap in
SchemaCompiler.processNamedComplexSchemaType() before it is processed,
rather than waiting until after it is processed, but I'm not sure if
that woudl really work and what other consequences it might have.  There
seem to be similar issues with other recursion control mechanisms in
SchemaCompiler, e.g. in processElement().

Thanks for any help,

Chuck

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Test" targetNamespace="test" xmlns="http://schemas.xmlsoap.org/wsdl/";
                                                xmlns:xsd="http://www.w3.org/2001/XMLSchema";
                                                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
                                                xmlns:test="test">

  <types>
    <xsd:schema targetNamespace="test">
      <xsd:element name="recursiveElement" type="recursive"/>
      <xsd:complexType name="recursive">
        <xsd:sequence>
          <xsd:element name="sub" type="test:recursive" minOccurs="0"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </types>

  <message name="foo">
    <part name="arg" element="test:recursiveElement"/>
  </message>
  <message name="fooResponse">
    <part name="response" element="test:recursiveElement"/>
  </message>

  <portType name="testPort">
    <operation name="foo">
      <input message="test:foo" name="foo"/>
      <output message="test:fooResponse" name="fooResponse"/>
    </operation>
  </portType>

  <binding name="testBinding" type="test:testPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="foo">
      <input name="foo">
        <soap:body use="literal" namespace="test"/>
      </input>
      <output name="fooResponse">
        <soap:body use="literal" namespace="test"/>
      </output>
    </operation>
  </binding>

  <service name="testService">
    <port name="testPort" binding="test:testBinding">
      <soap:address location="http://foo.com"/>
    </port>
  </service>
  

</definitions>

Reply via email to