【问题标题】:Defining a different namespace inside a schema (WSDL)在模式中定义不同的命名空间 (WSDL)
【发布时间】:2018-05-19 23:13:38
【问题描述】:

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

我有一个这样的 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>

我的问题是,我不希望元素“Message”和“ServiceID”具有命名空间 tem:。我希望他们有命名空间 ww:.

如何在不更改其他名称空间的情况下做到这一点?

提前致谢

【问题讨论】:

    标签: xml xsd namespaces wsdl schema


    【解决方案1】:

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

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

    通过

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 2021-06-27
      • 2014-09-14
      • 2015-03-16
      • 1970-01-01
      • 2015-06-02
      相关资源
      最近更新 更多