【发布时间】:2013-09-04 16:13:16
【问题描述】:
我正在使用标准 wsdl(位于 here)与服务 (OpenXDS) 进行通信。我从中创建了一个服务引用,它生成了一个非常大的 Reference.cs 文件。文件中有一个类型层次结构,如下所示:
public partial class ExtrinsicObjectType : RegistryObjectType
。 . .
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ExtrinsicObjectType))]
public partial class RegistryObjectType : IdentifiableType
。 . .
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RegistryObjectType))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ExtrinsicObjectType))]
public partial class IdentifiableType : object
所有三种类型都有相同的 XmlType:
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")]
IdentifiableType对象的Response类型中有一个集合:
[System.Xml.Serialization.XmlArrayAttribute(Namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", Order=0)]
[System.Xml.Serialization.XmlArrayItemAttribute("Identifiable", IsNullable=false)]
public IdentifiableType[] RegistryObjectList {
当服务真正响应时,它会给出一个 ExtrinsicObject 元素的集合:
<rim:RegistryObjectList xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
<ns1:ExtrinsicObject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...
<ns1:ExtrinsicObject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...
<ns1:ExtrinsicObject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...
<ns1:ExtrinsicObject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...
<ns1:ExtrinsicObject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...
</rim:RegistryObjectList>
我在跟踪日志中看到了这些元素,并且可以在 SoapUI 中得到相同的答案。但是当我从客户端代理返回反序列化响应时,RegistryObjectList 是空的。它完全忽略了 ExtrinsicObject 元素。
无法更改服务器,客户端是VS2012生成的。看来这应该可以正常工作,但我缺少一些设置或其他东西。
这是我目前的理论:
- 服务参考上有一些设置,如果我检查它并更新代码,一切都会正常工作。
- 我使用的 wsdl 与他们同意的 wsdl 不同。
- 我将不得不弄清楚如何手动反序列化响应。
感谢任何帮助。我尝试包含我认为相关的内容,但由于 wsdl、xsd 和 Reference.cs 都相当大,因此进行了很多编辑。
【问题讨论】:
-
在这种情况下,我尝试从 WSDL 自己构建一个存根 C# 服务器,看看它发送的响应与真实服务器发送的响应有何不同。
-
wsdl 的链接失效了....
标签: c# wcf soap wsdl deserialization