Not all properties are being sent or received in a WCF call
I am having a frustrating time debugging my new WCF service. Issue is with a certain 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. I have used Fiddler to snoop the soap packet sent and leaving the client all data is present. I have even set the Order parameter to the DataContract attribute to see if i could see a pattern but never did. I have also compared the DataMember name with the one in the message and they all match. The only pattern i found was this:
Here is the xsd definition for the DataContract object in question:
<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(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.
WHY?
It would help to see the SOAP and also know whether the client is .NET.
I've seen something like this happen using a non .NET client. Your xsd specifies a sequence
- which is be determined using the Order
attribute or defaulting to alphabetical order. Some clients seem to treat this as an all
element; they appear to take the view that "it's all the same XML" (see In XML, is order important?).
So in summary, check whether the SOAP elements are in the correct sequence matching your XSD.
Enable WCF Error logging and findout the root cause via SvcTraceViewer.exe
精彩评论