简体   繁体   English

并非所有属性都在WCF调用中发送或接收

[英]Not all properties are being sent or received in a WCF call

I am having a frustrating time debugging my new WCF service. 我在调试新的WCF服务时遇到了令人沮丧的困难。 Issue is with a certain DataContract. 问题出在某个DataContract上。 Seems like on de-serialization on the server side after a certain property something happens and the rest are not set. 看起来像某个属性发生后服务器端的反序列化,其余的都没有设置。 I have looked at the generated xsd schemas generated from the metadata and all seems ok. 我已经查看了从元数据生成的生成的xsd模式,一切似乎都没问题。 I have used Fiddler to snoop the soap packet sent and leaving the client all data is present. 我使用Fiddler监听发送的soap数据包,并留下客户端所有数据都存在。 I have even set the Order parameter to the DataContract attribute to see if i could see a pattern but never did. 我甚至将Order参数设置为DataContract属性,以查看我是否可以看到模式但从未这样做过。 I have also compared the DataMember name with the one in the message and they all match. 我还将DataMember名称与消息中的名称进行了比较,它们都匹配。 The only pattern i found was this: 我发现的唯一模式是:

Here is the xsd definition for the DataContract object in question: 以下是有问题的DataContract对象的xsd定义:

<xs:complexType name="Attachment">
 <xs:sequence>
  <xs:element minOccurs="0" name="dateTime" type="xs:dateTime"/>
  <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="fileName" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="guid" type="ser:guid"/>
  <xs:element minOccurs="0" name="obsDate" type="xs:dateTime"/>
  <xs:element minOccurs="0" name="operation" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="originalFileName" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="title" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
 </xs:sequence>
</xs:complexType>

Here is the DataContract object: 这是DataContract对象:

[DataContract(Namespace="http://www.myns.com")]
public class Attachment
{
    public enum AttachmentSortOrder { Date, FileType }

    [DataMember]
    public Guid guid;
    [DataMember]
    public DateTime dateTime;
    [DataMember]
    public string operation;
    [DataMember]
    public DateTime obsDate;
    [DataMember]
    public string originalFileName;
    [DataMember]
    public string fileName;
    [DataMember]
    public string title;
    [DataMember]
    public string type;
    [DataMember]
    public string description;
}

Seems like all properties after obsDate does not get set for some reason. 看起来像obsDate因某些原因没有设置后的所有属性。

WHY? 为什么?

启用WCF错误日志记录并通过SvcTraceViewer.exe查找根本原因

It would help to see the SOAP and also know whether the client is .NET. 有助于查看SOAP并了解客户端是否为.NET。

I've seen something like this happen using a non .NET client. 我已经看到使用非.NET客户端发生这样的事情。 Your xsd specifies a sequence - which is be determined using the Order attribute or defaulting to alphabetical order. 您的xsd指定一个sequence - 使用Order属性确定或默认为字母顺序。 Some clients seem to treat this as an all element; 一些客户似乎将此视为一个all元素; they appear to take the view that "it's all the same XML" (see In XML, is order important? ). 他们似乎认为“它是完全相同的XML”(参见XML,秩序很重要吗? )。

So in summary, check whether the SOAP elements are in the correct sequence matching your XSD. 总而言之,检查SOAP元素是否与您的XSD匹配正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# HttpWebRequest - 为什么没有收到所有 cookies 在后续请求中被发回? - C# HttpWebRequest - Why aren't all received cookies being sent back on subsequent requests? WCF是否调用处理发送和接收的对象? - Does WCF call dispose on transmitted and received objects? 找出WCF主机发送和接收的数据量? - Find out the amount of data sent and received by a WCF host? 发送给WCF服务的字符串“ 7 \\ aAZEA \\ 0 \\ a \\ rPV”被接收为“ 7 \\ aAZEA \\ 0 \\ a \\ nPV” - string “7\aAZEA\0\a\rPV” sent to a WCF service is received as “7\aAZEA\0\a\nPV” json 数据在发送到 mvc 控制器时被接收为空 - json data being received as null when sent to mvc controller 使用 mailkit 发送的多部分 email 的文本/纯文本版本未正确接收 - text/plain version of multipart email sent with mailkit not being received correctly 表单中未收到从视图中发送的数据 - Data sent from form in view is not being received in the form Web套接字消息未全部收到 - Web Socket messages not all being received WCF:服务在发送完整字符串后接收“null”字符串 - WCF : Service receiving “null” string after being sent a full string WCF服务客户端:未在线路上发送自定义肥皂信封 - WCF service client: Customized soap envelope not being sent on the wire
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM