WCF Tutorial | MessageHeaderArray Attribute
Consider the Message contract type definition as shown below.
public class Department
public string DepartmentID;
public string DepartmentName;
public Employees Employee();
In this we are having array of Employee type as message header. When this converted to SOAP Header it looks as shown below.
Suppose you want to show the all employee detail in same level. We can use MessageHeaderArray attribute which will serialize the array element independently. If you use the MessageHeaderArray attribute of Employees, SOAP message will look as shown below.
MessageHeaderArray Attribute is applicable only for Array, not for collection.
Comments on this article
- Always create the service with Interface->Implementation format, mention the contract in Interface.
- Define the service in Class library and refer the class library in Host project. Donâ€™t use service class in host project.
- Change the instance mode to per call as default.
- Always catch exception using try/catch block and throw exception using FaultException < T >.
- Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.