[英]Debug C# webservice client
I ran into a strange problem using a C# webservice client to call a ASP.NET 2.0 webservice. 使用C#Web服务客户端调用ASP.NET 2.0 Web服务时遇到一个奇怪的问题。 The service is a simple product search and returns an array of products matching a search term - see the relevant part of the WSDL file below.
该服务是一个简单的产品搜索,并返回与搜索词匹配的产品数组-请参阅下面的WSDL文件的相关部分。
My C# client is simply generated by adding a web reference in VS2010 (non-WCF) and for comparison I'm using an Axis 1.4 Java client. 我的C#客户端是通过在VS2010(非WCF)中添加Web引用而简单生成的,为了进行比较,我使用的是Axis 1.4 Java客户端。
Using the same search paramaters in both the C# and the Java client the call returns 50 products but in the C# client the result array has length 1 while the Java client shows up the correct 50 elements. 在C#和Java客户端中使用相同的搜索参数,调用将返回50个产品,但是在C#客户端中,结果数组的长度为1,而Java客户端显示了正确的50个元素。
I am looking for suggestions how to locate the problem - I've tried the following: 我正在寻找有关如何解决问题的建议-我尝试了以下方法:
Any suggestions are highly appreciated. 任何建议都将受到高度赞赏。
EDIT: Full WSDL and generated code (Reference.cs) can be found here: 编辑:完整的WSDL和生成的代码(Reference.cs)可以在这里找到:
http://timmay.dk/Reference.txt http://timmay.dk/Reference.txt
http://timmay.dk/Wsdl.txt http://timmay.dk/Wsdl.txt
Simplified WSDL part: 简化的WSDL部分:
<s:element name="Search">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SearchTerm" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="StartFrom" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="NumberToBeReturned" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SearchResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SearchResult" type="tns:SearchResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="SearchResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Products" type="tns:ArrayOfResponseProduct" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfResponseProduct">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="ResponseProduct" nillable="true" type="tns:ResponseProduct" />
</s:sequence>
</s:complexType>
<s:complexType name="ResponseProduct">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Fields" type="tns:ArrayOfResponseField" />
</s:sequence>
<s:attribute name="id" type="s:string" />
</s:complexType>
From the WSDL I gather that the maxOccurs
is 1. So it seems that you should receive indeed only one SearchResult
. 从WSDL中,我发现
maxOccurs
为1。因此,看来您应该只收到一个SearchResult
。 However, that result itself should contain an object of type ArrayOfReponseProduct
, which contains an unbounded amount of `ResponseProduct items. 但是,该结果本身应包含
ArrayOfReponseProduct
类型的对象,该对象包含无限制的`ResponseProduct项目。 Maybe you are not looking deep enough? 也许您看起来不够深?
Have you tried to check inside the debugger with the variable inspectors (Local, Auto, Immediate etc)? 您是否尝试使用变量检查器(本地,自动,即时等)在调试器中进行检查? Is the object typed, or untyped, in which case you may need to cast it first to see the contents?
是键入对象还是未键入对象,在这种情况下,您可能需要先强制转换对象才能查看内容?
It turned out that the culprit was the type of the return values - Response field 原来,罪魁祸首是返回值的类型-响应字段
< s:complexType name="ResponseField">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Value">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
This was pr default converted to a System.Data.DataSet - changing this to a simple string solved the problem. pr默认将其转换为System.Data.DataSet-将其更改为简单字符串即可解决此问题。 It seems that the unmarshalling failed in this case.
在这种情况下,解组似乎失败了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.