[英]WCF XML deserialization fail
I've got this WSDL(the service is not mine): http://soaptest.webapi-beta.gratka.pl/dom.html?wsdl 我有这个WSDL(服务不是我的): http : //soaptest.webapi-beta.gratka.pl/dom.html?wsdl
When I get response from method "pobierz_kategorie" I get exception like that 当我从方法“ pobierz_kategorie”获得响应时,我得到了类似的异常
CommunicationException Error in deserializing body of reply message for operation 'pobierz_kategorie'. CommunicationException将操作'pobierz_kategorie'的回复消息反序列化时出错。 {"There is an error in XML document (2, 501)."} {"The specified type was not recognized: name='kategoria_drzewo', namespace='http://soap.webapi-beta.gratka.pl/dom.html', at ."}
{“ XML文档(2,501)中存在错误。”} {“无法识别指定的类型:name ='kategoria_drzewo',namespace ='http://soap.webapi-beta.gratka.pl/dom .html',位于。“}
I would like to ask how to modify WSDL or WCF configuration or generated proxy to make it working. 我想问一下如何修改WSDL或WCF配置或生成的代理以使其工作。 When I use PHP to call that method it works so I guess that must be some XMLSerializer problem.
当我使用PHP调用该方法时,它可以工作,因此我想那一定是XMLSerializer的问题。
This the response message I get: 这是我得到的响应消息:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soap.webapi-beta.gratka.pl/dom.html" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:pobierz_kategorieResponse>
<drzewo_kategorii SOAP-ENC:arrayType="ns1:kategoria_drzewo[48]" xsi:type="ns1:drzewo_kategorii">
<item xsi:type="ns1:kategoria_drzewo">
<id xsi:type="xsd:int">382</id>
<nazwa xsi:type="xsd:string">Dom</nazwa>
<dane xsi:type="xsd:string">0</dane>
<id_rodzic xsi:type="xsd:int">1</id_rodzic>
<poziom xsi:type="xsd:int">0</poziom>
<id_prasa xsi:type="xsd:int">2</id_prasa>
</item>
<item xsi:type="ns1:kategoria_drzewo">
<id xsi:type="xsd:int">8251</id>
<nazwa xsi:type="xsd:string">Pokoje</nazwa>
<dane xsi:type="xsd:string"/>
<id_rodzic xsi:type="xsd:int">382</id_rodzic>
<poziom xsi:type="xsd:int">1</poziom>
<id_prasa xsi:type="xsd:int">0</id_prasa>
</item>
</drzewo_kategorii>
</ns1:pobierz_kategorieResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
That is the request: 那是要求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q1="http://soaptest.webapi-beta.gratka.pl/dom.html">
<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:pobierz_kategorie>
<sesja xsi:type="xsd:string">ad9e730460e334b916c95533c8da320003ac7e14</sesja>
<id_kategoria xsi:type="xsd:int">382</id_kategoria>
</q1:pobierz_kategorie>
</s:Body>
</s:Envelope>
I've retrieved that WSDL and the response message name does not match what you have above. 我已经检索到WSDL,并且响应消息名称与上面的内容不匹配。 Where you have
pobierz_kategorieResponse
in the wsdl, it is pobierz_kategorie_wyjscie
in the WSDL definition. wsdl中有
pobierz_kategorieResponse
的pobierz_kategorie_wyjscie
,WSDL定义中就是pobierz_kategorie_wyjscie
。
Message ... 留言 ...
<message name="pobierz_kategorie_wyjscie">
<part name="drzewo_kategorii" type="tns:drzewo_kategorii"/>
</message>
Operation ... 操作 ...
<operation name="pobierz_kategorie">
<input message="tns:pobierz_kategorie_wejscie"/>
<output message="tns:pobierz_kategorie_wyjscie"/>
</operation>
Maybe you need to regenerate your service reference or point it at a different endpoint. 也许您需要重新生成服务引用或将其指向其他端点。
EDIT 编辑
You may have to customize your reference.cs file (your generated WCF client code) to handle the soap array. 您可能必须自定义reference.cs文件(您生成的WCF客户端代码)来处理soap数组。 I haven't done this myself but there is an SO article about it:-
我自己还没有做过,但是有一篇SO文章:-
Why won't .NET deserialize my primitive array from a web service? .NET为什么不从Web服务反序列化我的原始数组?
I'm not 100% sure if this is the same issue as what you are having. 我不确定100%是否与您遇到的问题相同。 It looks like you need to tell WCF explicitly - for this element, this is how you de-serialize the array.
看来您需要明确地告诉WCF-对于此元素,这就是您对数组进行反序列化的方式。 Sorry I can't be of more help.
抱歉,我没有更多帮助。
EDIT #2 编辑#2
There is a mismatch between the wsdl published to you 'soaptest' and the actual implementation. 发布给您“肥皂测试”的wsdl与实际实现之间不匹配。 Note the namespaces.
注意名称空间。 Or, you've generated your code of a test wsdl endpoint and pointed it at a prod endpoint.See the namespaces below.
或者,您已经生成了测试wsdl端点的代码并将其指向prod端点。请参见下面的名称空间。
Your request's namespaces looked like this:- 您请求的名称空间如下所示:
But the response's namespaces looked like this:- 但是响应的名称空间看起来像这样:
That ain't gonna work! 那是行不通的!
Try generating your WCF client off 尝试关闭您的WCF客户端
instead of off 而不是关闭
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.