Monday, 4 January 2016

XML : Why XML namespace is not unwanted in this XML SOAP request?

I don't understand why the following XML (built from a WSDL request) is invalid:

  <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">      <soap:Header />      <soap:Body xmlns:m="https://test.com/schemas/Plat/">            <m:TestRequest>                   <m:transactId>TRANS_46151</m:transactId>                   <m:param1>paramvalue1</m:param1>           </m:TestRequest>      </soap:Body>   </soap:Envelope>    

And why it becomes valid once the "m" namespace is removed from the "TestRequest" parameters, as below:

  <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">      <soap:Header />      <soap:Body xmlns:m="https://test.com/schemas/Plat/">            <m:TestRequest>                   <transactId>TRANS_46151</m:transactId>                   <param1>paramvalue1</m:param1>           </m:TestRequest>      </soap:Body>   </soap:Envelope>    

Notice: the XSD is:

  <?xml version="1.0" encoding="UTF-8"?>  <xsd:schema attributeFormDefault="qualified"  xmlns:xsd="http://www.w3.org/2001/XMLSchema"      targetNamespace="https://test.com/schemas/Plat/"        <xsd:complexType name="EnteteMessageType">      <xsd:sequence>          <xsd:element name="transactId" type="xsd:string" minOccurs="0" />          <xsd:element name="param1" type="xsd:string" />      </xsd:sequence>  </xsd:complexType>    <xsd:element name="TestRequest" type="EnteteMessageType" />  </xsd:schema>    

Thanks for your help.

No comments:

Post a Comment