How to enforce a namespace in wsdl for inner elements
Posted
by wsxedc
on Stack Overflow
See other posts from Stack Overflow
or by wsxedc
Published on 2010-05-14T04:47:21Z
Indexed on
2010/05/14
4:54 UTC
Read the original article
Hit count: 282
I am looking at an example WSDL
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://mypackage/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://mypackage/" name="HelloService">
<types>
<xsd:schema>
<xsd:import namespace="http://mypackage/"
schemaLocation="http://localhost:8081/HelloWebService/HelloService?xsd=1">
</xsd:import>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"></part>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"></part>
</message>
<portType name="Hello">
<operation name="sayHello">
<input message="tns:sayHello"></input>
<output message="tns:sayHelloResponse"></output>
</operation>
</portType>
<binding name="HelloPortBinding" type="tns:Hello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>
<operation name="sayHello">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="HelloService">
<port name="HelloPort" binding="tns:HelloPortBinding">
<soap:address location="http://localhost:8081/HelloWebService/HelloService">
</soap:address>
</port>
</service>
and the referenced xsd is
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://mypackage/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
targetNamespace="http://mypackage/">
<xs:element name="sayHello" type="tns:sayHello"></xs:element>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse">
</xs:element>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
When I use SoapUI to generate a request message, it looks like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myp="http://mypackage/">
<soapenv:Header/>
<soapenv:Body>
<myp:sayHello>
<arg0>?</arg0>
</myp:sayHello>
</soapenv:Body>
</soapenv:Envelope>
My question is, why doesn't arg0 need a namespace like ??
I am just using this as an example as the element that are children of soapenv always have a namespace prefix, however, the children of these children do not have any prefix. This is the case with soapUI and message sent by Axis2 generated stubs.
My questions are: 1. Why aren't there any namespace for arg0? 2. Is there a way to enforce myp prefix on arg0 from WSDL? If so, how? If not, why can't it be done?
© Stack Overflow or respective owner