Dears,
I am trying to use message contracts in WCF and i have a parent object with two sub objects in some method and after consuming the service from a test client, the method accepts only the sub objects as input and ignores the parent object!
Example:
WCF Method:
public GetEmployeeResponse GetEmployee_MessageContract(GetEmployeeRequest getEmployeeRequest)
{
}
GetEmployeeRequest:
[MessageContract(IsWrapped =true, WrapperName = "GetEmployeeRequestObjectWrapped", WrapperNamespace ="http://www.test.com")]
public class GetEmployeeRequest
{
[MessageHeader(Namespace = "http://www.test.com", Name = "AuthenticationHeaderObject")]
public AuthenticationHeader AuthenticationHeader { get; set; }
[MessageBodyMember(Namespace = "http://www.test.com", Name = "EMPID")]
public int Id { get; set; }
}
AuthenticationHeader:
[DataContract]
public class AuthenticationHeader
{
[DataMember(Name = "KEY", Order =1)]
public string UserName { get; set; }
[DataMember(Name = "PASSWORD", Order = 2)]
public string Password { get; set; }
}
The MAIN issue now is that while consuming this method from a client app i am getting the following in the service reference.cs file:
Method header is as following:
GetEmployee_MessageContract(EmployeeService_Client.EmployeeService.AuthenticationHeader AuthenticationHeaderObject, int EMPID)
I expect it to be like
GetEmployee_MessageContract(EmployeeService_Client.EmployeeService.GetEmployeeRequest GetEmployeeRequest)
So what is the problem with the above code?
What I have tried:
i tried using serializable in stead of DataContract but still the issue there?