0

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

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

我怎样才能在不更改其他任何名称空间的情况下做到这一点?

提前致谢

4

1 回答 1

0

只需替换模式的目标命名空间。也就是说,更换

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

经过

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

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

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

于 2018-05-19T15:00:13.377 回答