C# 删除WCF SOAP消息中的其他命名空间定义
我有这个WSDL(服务不是我的): 当我使用WCF生成的代理时,请求soap消息中的方法标记会获得额外的命名空间定义,如:C# 删除WCF SOAP消息中的其他命名空间定义,c#,wcf,C#,Wcf,我有这个WSDL(服务不是我的): 当我使用WCF生成的代理时,请求soap消息中的方法标记会获得额外的命名空间定义,如: <q1:zaloguj xmlns:q1="http://soaptest.webapi-beta.gratka.pl/dom.html"> 当我使用PHP或wsdl.exe生成的代理时,这不会发生 我想问,为什么WCF会这样做,是否有可能改变这种行为(在BeforeSendRequest中不使用手工修改消息) 下面我粘贴由PHP和WCF生成的消息: PH
<q1:zaloguj xmlns:q1="http://soaptest.webapi-beta.gratka.pl/dom.html">
当我使用PHP或wsdl.exe生成的代理时,这不会发生
我想问,为什么WCF会这样做,是否有可能改变这种行为(在BeforeSendRequest中不使用手工修改消息)
下面我粘贴由PHP和WCF生成的消息:
PHP one:
<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>
登录
密码
钥匙
382a
2.
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>
登录
密码
钥匙
382
2.
您是否面临任何问题?就xml而言,两者是等价的。PHP代码正在声明命名空间(xmlns:ns1=”http://soaptest.webapi-beta.gratka.pl/dom.html“
)在根元素上,当WCF在需要它的地方声明时—我相信这就是WSDL的实现—似乎没有任何错误。是的,不幸的是,webservice是一堆垃圾,返回505,带有soap错误,消息为“Element”{}zaloguj”:验证根没有匹配的全局声明可用。当我在BeforeSendRequest中将命名空间定义从方法标记手动移动到body标记时works@user1121956,事实上,我打算建议进行变通——修改生成的soap消息。它不漂亮,但是。。。