在模式(WSDL)中定义不同的命名空间

时间:2018-05-18 17:31:43

标签: xml xsd namespaces wsdl schema

我一直在寻找这个问题的答案,但我无法在任何地方找到它。想知道是否有人可以帮助我。

我有这样的WSDL:

<ws:types>
    <xs:schema targetNamespace="http://tempuri.org/" xmlns:ww="http://ww"
             elementFormDefault="qualified">
        <xs:element name="GenericNode">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="request">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="Message" minOccurs="0" maxOccurs="1"/>
                                <xs:element name="ServiceID" minOccurs="0" maxOccurs="1"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
</ws:types>

(由于机密性,一些名称被更改)

我收到以下SoapUI消息:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GenericNode>
         <tem:request>
            <!--Optional:-->
            <tem:Message>anyType</tem:Message>
            <!--Optional:-->
            <tem:ServiceID>anyType</tem:ServiceID>
         </tem:request>
      </tem:GenericNode>
   </soapenv:Body>
</soapenv:Envelope>

我的问题是,我不想要这些元素&#34; Message&#34;和&#34; ServiceID&#34;拥有命名空间tem:我希望他们有命名空间ww:。

如何在不更改其他任何名称空间的情况下执行此操作?

提前致谢

1 个答案:

答案 0 :(得分:0)

只需替换架构的目标命名空间即可。也就是说,替换

<xs:schema targetNamespace="http://tempuri.org/" ...

通过

<xs:schema targetNamespace="http://ww" ...

现在可以肯定的是,这并不一定会将ww作为命名空间前缀,但它会导致http://ww被用作命名空间 URI

这样的名称空间前缀在XML中是无关紧要的,只要它映射到正确的名称空间URI并在文档实例中一致地使用;它可以是任何东西,例如ns0

相关问题