ProtectionLevel
You can mention the MessageHeader or MessageBodyMember to be signed or Encrypted using ProtectionLevel property.
Example
In the above type definition, we have made the different protection
level for body. But the protection level of the body is determind by the
highest ProtectionLevel property. By default if you are not
specifying the protection level it takes 'EncryptAndSign'. So it good if
you specify minimum ProtectionLevel required.
Example
using System.Net.Security; [MessageContract] public class EmployeeDetails { [MessageHeader(ProtectionLevel=ProtectionLevel.None)] public string EmpID; [MessageBodyMember(ProtectionLevel = ProtectionLevel.Sign )] public string Name; [MessageBodyMember(ProtectionLevel = ProtectionLevel.Sign )] public string Designation; [MessageBodyMember(ProtectionLevel=ProtectionLevel.EncryptAndSign)] public int Salary; }
Name and Namespace:
SOAP representation of the message element can be change by mentioning Name and Namespace property of the Header and Body member. By default namespace is the same as the namespace of the service contract that the message is participating. In the below example, I have mention the Name property to the EmpID and Name.[MessageContract] public class EmployeeDetails { [MessageHeader(Name="ID")] public string EmpID; [MessageBodyMember(Name="EmployeeName")] public string Name; [MessageBodyMember()] public string Designation; [MessageBodyMember()] public int Salary; }
<EmployeeDetails> <ID>45634</ID> <EmployeeName>Sam</EmployeeName> <Designation>Software Engineer</Designation> <Salary>25000</Salary> </EmployeeDetails>
Order
The order of the body elements are alpehabetical by default. But you can control the order, usiing Order property in the MessageBody attribute.[MessageContract] public class EmployeeDetails { [MessageHeader()] public string EmpID; [MessageBodyMember(Order=2)] public string Name; [MessageBodyMember(Order=3)] public string Designation; [MessageBodyMember(Order=1)] public int Salary; }
No comments:
Post a Comment