views:

34

answers:

1

I am using eclipse and axis2 1.4.1 facet to generate a webservice. My problem is that in the generation process, the namespaces are being repeated in all nodes. As you can see below, ns4 is repeated instead of being declared in NewOperationResponse node.

How can I make java2wdsl (or eclipse) generate that automatically (only in parent node or top node) ? Do I have to change anything on wsdl or xsd ?

Thanks!

WS Response

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<soapenv:Body>
<NewOperationResponse xmlns="http://www.example.org/Test"&gt;
<out>
  <ns4:areaCode xmlns:ns4="http://www.example.org/Test/Simple"&gt;0&lt;/ns4:areaCode&gt; 
  <ns4:exchange xmlns:ns4="http://www.example.org/Test/Simple"&gt;0&lt;/ns4:exchange&gt; 
  <ns4:number xmlns:ns4="http://www.example.org/Test/Simple"&gt;12&lt;/ns4:number&gt; 
</out>
</NewOperationResponse>
</soapenv:Body>
</soapenv:Envelope>

WSDL

 <wsdl:types>

  <xsd:schema targetNamespace="http://www.example.org/Test"
   xmlns:simple="http://www.example.org/Test/Simple" 
   elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.1">

   <xsd:import namespace="http://www.example.org/Test/Simple" schemaLocation="Simple.xsd" />
   <xsd:element name="NewOperation">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="in" type="xsd:string" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

   <xsd:element name="NewOperationResponse">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="out" type="simple:Phone" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

  </xsd:schema>
 </wsdl:types>

 <wsdl:message name="NewOperationRequest">
  <wsdl:part element="tns:NewOperation" name="parameters" />
 </wsdl:message>
 <wsdl:message name="NewOperationResponse">
  <wsdl:part element="tns:NewOperationResponse" name="parameters" />
 </wsdl:message>

 <wsdl:portType name="Test">
  <wsdl:operation name="NewOperation">
   <wsdl:input message="tns:NewOperationRequest" />
   <wsdl:output message="tns:NewOperationResponse" />
  </wsdl:operation>
 </wsdl:portType>
 <wsdl:binding name="TestSOAP" type="tns:Test">
  <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="NewOperation">
   <soap:operation soapAction="" />
   <wsdl:input>
    <soap:body use="literal" />
   </wsdl:input>
   <wsdl:output>
    <soap:body use="literal" />
   </wsdl:output>
  </wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="Test">
  <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
   <soap:address location="http://localhost:8084/WSDLProject/services/Test" />
  </wsdl:port>
 </wsdl:service>
</wsdl:definitions>

simple.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.example.org/Test/Simple"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" 
 elementFormDefault="qualified"
 attributeFormDefault="qualified">

 <xs:complexType name="Phone">
  <xs:sequence>
   <xs:element name="areaCode" type="xs:int" />
   <xs:element name="exchange" type="xs:int" />
   <xs:element name="number" type="xs:int" />
  </xs:sequence>
 </xs:complexType>
</xs:schema>
A: 

In your wsdl schema declaration switch to using elementFormDefault="uqualified" as opposed to using elementFormDefault="qualified"

Alex Khvatov
Thanks for the answer. Unfortunately that does not solve the issue. The desired response needs to be with xmlns:ns4="http://www.example.org/Test/Simple" above and not in every element. Any suggestions? Example:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><NewOperationResponse xmlns="http://www.example.org/Test" xmlns:ns4="http://www.example.org/Test/Simple"><out> <ns4:areaCode>0</ns4:areaCode> <ns4:exchange>0</ns4:exchange> <ns4:number>12</ns4:number> </out></NewOperationResponse></soapenv:Body></soapenv:Envelope>
nerlijma