1.Message Contract Declaration
[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
string UpdateStatus(string text);
[OperationContract]
void TestContract(Customer cust);
}
[MessageContract]
public class Customer
{
[MessageBodyMember]
public int Id { get; set; }
[MessageBodyMember]
public string Name { get; set; }
[MessageBodyMember]
public string[] AddressList{get;set;}
}
XML Format
<s:Body>
<Customer xmlns="http://tempuri.org/">
<AddressList xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:string>a</b:string>
<b:string>b</b:string>
</AddressList>
<Id>123</Id>
<Name>Sweep</Name>
</Customer>
</s:Body>
1.1 Message Contract Declaration (with Header)
[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
string UpdateStatus(string text);
[OperationContract]
void TestContract(Customer cust);
}
[MessageContract]
public class Customer
{
[MessageHeader]
public int Id { get; set; }
[MessageBodyMember]
public string Name { get; set; }
[MessageBodyMember]
public string[] AddressList{get;set;}
}
XML Format
<s:Header>
<a:Action s:mustUnderstand="1">http://tempuri.org/ISocialStatus/TestContract</a:Action>
<h:Id xmlns:h="http://tempuri.org/">123</h:Id>
<a:MessageID>urn:uuid:aa9a057c-1e6a-42a3-abbf-1045f373379f</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://localhost:12345/GetMessage</a:To>
</s:Header>
<s:Body>
<Customer xmlns="http://tempuri.org/">
<AddressList xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:string>a</b:string>
<b:string>b</b:string>
</AddressList>
<Name>Sweep</Name>
</Customer>
</s:Body>
2.Data Contract Declaration
[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
string UpdateStatus(string text);
[OperationContract]
void TestContract(Customer cust);
}
[DataContract]
public class Customer
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string[] AddressList{get;set;}
}
XML Format
<s:Body>
<TestContract xmlns="http://tempuri.org/">
<cust xmlns:b="http://schemas.datacontract.org/2004/07/Service" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:AddressList xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:string>a</c:string>
<c:string>b</c:string>
</b:AddressList>
<b:Id>123</b:Id>
<b:Name>Sweep</b:Name>
</cust>
</TestContract>
</s:Body>
3.XmlSerializer Declaration
[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
string UpdateStatus(string text);
[OperationContract]
void TestContract(Customer cust);
}
[XmlSerializerFormat]
public class Customer
{
[XmlAttribute]
public int Id { get; set; }
[XmlAttribute]
public string Name { get; set; }
[XmlAttribute]
public string[] AddressList{get;set;}
}
XML Format
<s:Body>
<TestContract xmlns="http://tempuri.org/">
<cust xmlns:b="http://schemas.datacontract.org/2004/07/Service" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:AddressList xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:string>a</c:string>
<c:string>b</c:string>
</b:AddressList>
<b:Id>123</b:Id>
<b:Name>Sweep</b:Name>
</cust>
</TestContract>
</s:Body>