删除WCF SOAP消息中额外的名称空间定义

本文关键字:空间 定义 WCF SOAP 消息 删除 | 更新日期: 2023-09-27 17:51:08

我已经得到了这个WSDL(服务不是我的):http://soaptest.webapi-beta.gratka.pl/dom.html?wsdl

当我使用WCF生成的代理时,请求soap消息中的方法标记获得额外的名称空间定义,如:

<q1:zaloguj xmlns:q1="http://soaptest.webapi-beta.gratka.pl/dom.html">

当我使用PHP或wsdl.exe生成的代理时,这不会发生。

我想问,为什么WCF这样做,是否有可能改变这种行为(不使用beforeendrequest中的手工消息修改)

下面我粘贴PHP和WCF生成的消息:

PHP:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soaptest.webapi-beta.gratka.pl/dom.html" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:zaloguj>
            <login xsi:type="xsd:string">login</login>
            <haslo xsi:type="xsd:string">password</haslo>
            <klucz_webapi xsi:type="xsd:string">key</klucz_webapi>
            <id_kategoria xsi:type="xsd:int">382a</id_kategoria>
            <wersja_webapi xsi:type="xsd:int">2</wersja_webapi>
        </ns1:zaloguj>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WCF:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <q1:zaloguj xmlns:q1="http://soaptest.webapi-beta.gratka.pl/dom.html">
            <login xsi:type="xsd:string">login</login>
            <haslo xsi:type="xsd:string">password</haslo>
            <klucz_webapi xsi:type="xsd:string">key</klucz_webapi>
            <id_kategoria xsi:type="xsd:int">382</id_kategoria>
            <wersja_webapi xsi:type="xsd:int">2</wersja_webapi>
        </q1:zaloguj>
    </s:Body>
</s:Envelope> 

删除WCF SOAP消息中额外的名称空间定义

你遇到什么问题了吗?就xml而言,两者是等价的。PHP代码在根元素声明命名空间(xmlns:ns1="http://soaptest.webapi-beta.gratka.pl/dom.html"),而WCF在需要它的地方声明——我相信这就是WSDL的实现——其中似乎没有任何错误。