Todd,

I don't think this is a bug in Axis2. Your schema is not valid.

Your error is not a function of anonymous simple types. The error is
that you are defining the "firstName" and "lastName" elements more
than once in the same namespace. (first within the "Person"
complexType, and second within the "AddressBookEntry".

If you want to define these elements with the same name, but you want
to define them as having different types, then you have the following
options:

- specify elementFormDefault="unqualified" in the <xsd:schema> declaration
- specify form="unqualified" in the "firstName" and "lastName" element
declarations
- define the "Person" and "AddressBookEntry" complexTypes in separate namespaces

If these elements should be of the same type, then you should define
"firstName" and "lastName" as global elements and reference them from
the type definitions

You may not like to hear this, but your current practice of generating
schema from code is not a good one. You should expect to encounter
these types of issues on a regular basis if you continue with this
practice.

Anne


On 11/28/06, Doolittle, Todd <[EMAIL PROTECTED]> wrote:



I just found a very major bug in Axis 2 that I'm going to file a JIRA for.
My company is not willing to use nightlies or non-released versions of
software.  Yet this bug is big enough that we will probably not be able to
use Axis 2.  Is it going to be another 6 months before the next release or
is there some plan to do "point" releases more often?

In case anyone is interested here is the bug…

Here is a snippet of a schema that returns an object that contains a first
name and last name.  The problem is that WSDL2JAVA fails when there is more
than 1 anonymous simple type.  If the schema defined in the WSDL includes 1
anonymous simple type, everything works fine (like this)…

<xsd:element name="firstName">

  <xsd:simpleType>

    <xsd:restriction base="xsd:string">

      <xsd:maxLength value="10" />

    </xsd:restriction>

  </xsd:simpleType>

</xsd:element>

<xsd:element name="lastName" type="xsd:string" />


As soon as you add more than one anonymous simple type (like below)
WSDL2JAVA throws an exception.

<xsd:element name="firstName">

  <xsd:simpleType>

    <xsd:restriction base="xsd:string">

      <xsd:maxLength value="10" />

    </xsd:restriction>

  </xsd:simpleType>

</xsd:element>

<xsd:element name="lastName">

  <xsd:simpleType>

    <xsd:restriction base="xsd:string">

      <xsd:maxLength value="20" />

    </xsd:restriction>

  </xsd:simpleType>

</xsd:element>

The exception is listed at the bottom of this email.  We can work around
this problem by pulling out all the anonymous simple types and creating
named types.  However we are not the ones generating the service code and
WSDL.  It is being generated by another language and it uses these anonymous
simple (and complex) types extensively.  So we would have to do this for
some very complex WSDL across a lot of services and hundreds of operations.
And each time a service or operation was changed we have to do it by hand
all over again which would be very tedious and error prone.

Exception in thread "main"
org.apache.axis2.wsdl.codegen.CodeGenerationException

: java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException

        at
org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGener

ationEngine.java:224)

        at
org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)

        at
org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)

Caused by: java.lang.RuntimeException:
java.lang.reflect.InvocationTargetExcepti

on

        at
org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(Simp

leDBExtension.java:52)

        at
org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGener

ationEngine.java:177)

        ... 2 more

Caused by: java.lang.reflect.InvocationTargetException

        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:324)

        at
org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(Simp

leDBExtension.java:49)

        ... 3 more

Caused by:
org.apache.axis2.schema.SchemaCompilationException:
java.lang.NullPoi

nterException

        at
org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:25

7)

        at
org.apache.axis2.schema.ExtensionUtility.invoke(ExtensionUtility.java

:72)

        ... 8 more

Caused by: java.lang.NullPointerException

        at
org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.

java:592)

        at
org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.

java:489)

        at
org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:14

88)

        at
org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler

.java:1450)

        at
org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompi

ler.java:950)

        at
org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(

SchemaCompiler.java:909)

        at
org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.j

ava:864)

        at
org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.

java:527)

        at
org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.

java:499)

        at
org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:33

6)

        at
org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:24

8)

        ... 9 more

Full WSDL

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";

  name="AddressBook" targetNamespace="http://sears.org/";

  xmlns:sears="http://sears.org/";

  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";

  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

  <wsdl:types>

    <xsd:schema elementFormDefault="qualified"

      targetNamespace="http://sears.org/"; xmlns:s1="http://sears.org/";>

      <xsd:complexType name="Person">

        <xsd:sequence>

          <xsd:element name="firstName" type="xsd:string" />

          <xsd:element name="lastName" type="xsd:string" />

        </xsd:sequence>

      </xsd:complexType>

      <xsd:complexType name="AddressBookEntry">

        <xsd:sequence>

          <xsd:element name="firstName">

            <xsd:simpleType>

              <xsd:restriction base="xsd:string">

                <xsd:maxLength value="10" />

              </xsd:restriction>

            </xsd:simpleType>

          </xsd:element>

          <xsd:element name="lastName">

            <xsd:simpleType>

              <xsd:restriction base="xsd:string">

                <xsd:maxLength value="20" />

              </xsd:restriction>

            </xsd:simpleType>

          </xsd:element>

          <xsd:element name="streetAddress" type="xsd:string" />

          <xsd:element name="city" type="xsd:string" />

          <xsd:element name="state" type="xsd:string" />

          <xsd:element name="zipCode" type="xsd:int" />

          <xsd:element name="phoneNumber" type="xsd:string" />

        </xsd:sequence>

      </xsd:complexType>

      <xsd:element name="addressLookupRequest" type="Person" />

      <xsd:element name="addressLookupResponse"

        type="AddressBookEntry" />

    </xsd:schema>

  </wsdl:types>

  <wsdl:message name="AddressLookupIn">

    <wsdl:part element="sears:addressLookupRequest"

      name="parameters" />

  </wsdl:message>

  <wsdl:message name="AddressLookupOut">

    <wsdl:part element="sears:addressLookupResponse"

      name="parameters" />

  </wsdl:message>

  <wsdl:portType name="AddressBookPortType">

    <wsdl:operation name="AddressLookup">

      <wsdl:input message="sears:AddressLookupIn"

        name="addressLookupRequest" />

      <wsdl:output message="sears:AddressLookupOut"

        name="addressLookupResponse" />

    </wsdl:operation>

  </wsdl:portType>

  <wsdl:binding name="AddressBookBinding"

    type="sears:AddressBookPortType">

    <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"; />

    <wsdl:operation name="AddressLookup">

      <soap:operation soapAction="AddressLookup" style="document" />

      <wsdl:input name="addressLookupRequest">

        <soap:body use="literal" />

      </wsdl:input>

      <wsdl:output name="addressLookupResponse">

        <soap:body use="literal" />

      </wsdl:output>

    </wsdl:operation>

  </wsdl:binding>

  <wsdl:service name="AddressBook">

    <wsdl:port binding="sears:AddressBookBinding"

      name="AddressBookPortType">

      <soap:address


location="http://localhost:8080/axis2/services/AddressBook";
/>

    </wsdl:port>

  </wsdl:service>

</wsdl:definitions>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to