You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Wei Hsu <wh...@openharbor.com> on 2004/04/28 22:09:45 UTC

namespace question

Hi all,

 

I have a question on how namespaces are assigned when running AXIS's
WSDL2Java tool on the WSDL.  I seem to have come across an inconsistency,
and I was hoping maybe some of you can clear this up for me.  

 

So since I am trying to create a doc/literal wrapped service, I realize I
need to create the "request and response" elements for my messages.  At
first, I try to declare them within a separate "wrapper.xsd" file with the
namespace="urn:Creator".  Inside "wrapper.xsd," I declared them as follow:

 

<element name="createSalesOrder">

  <complexType>

    <sequence>

      <element name="SalesOrder" type="so:SalesOrder"/>

    </sequence>

  </complexType>

</element>

<element name="createSalesOrderResponse">

  <complexType>

    <sequence>

      <element name="SalesOrderID" type="so:SalesOrderID"/>

    </sequence>

  </complexType>

</element>

 

Where let's say namespace "so" points to "ns.salesorder", where SalesOrder
and SalesOrderID are defined.  Within my WSDL, I imported the "wrapper.xsd"
file and used them as parts for my request/response messages.  

 

<wsdl:types>

  <xsd:schema targetNamespace="urn:Creator">

    <xsd:import namespace="urn:Creator" schemaLocation="wrapper.xsd"/>

  </xsd:schema>

</wsdl:types>

 

When I try to call the service using the WSDL2Java stubs, I get the
following SOAP body:

 

<createSalesOrder xmlns="urn:Creator">

  <SalesOrder>

    <ns1:Stuff xmlns:ns1="ns.salesorder" />

  </SalesOrder>

</createSalesOrder>

 

Note how SalesOrder belongs to the "urn:Creator" namespace.  However, if I
declare those two request/response elements inside the WSDL file instead of
importing a "wrapper.xsd" as follows:

 

<wsdl:types>

  <xsd:schema targetNamespace="urn:Creator">

    <xsd:element name="createSalesOrder">

      <xsd:complexType>

        <xsd:sequence>

          <xsd:element name="SalesOrder" type="so:SalesOrder"/>

        </xsd:sequence>

      </xsd:complexType>

    </xsd:element>

    <xsd:element name="createSalesOrderResponse">

      <xsd:complexType>

        <xsd:sequence>

          <xsd:element name="SalesOrderID" type="so:SalesOrderID"/>

        </xsd:sequence>

      </xsd:complexType>

    </xsd:element>

  </xsd:schema>

</wsdl:types>

 

I get the following SOAP body instead:

 

<createSalesOrder xmlns="urn:Creator">

  <SalesOrder xmlns="">

    <ns1:Stuff xmlns:ns1="ns.salesorder" />

  </SalesOrder>

</createSalesOrder>

 

Note the SalesOrder belongs to the empty space.  

 

So is there any reason why the namespaces for SalesOrder should be different
in the two scenarios that I've described?  In both cases, all the elements
used by the WSDL belonged to "urn:Creator".  Or did I miss something?

 

-Wei