In my solution I have a create a WCF service which takes message contract class as parameter.
[ServiceContract]
public interface IServiceClass
{
[OperationContract]
Employee AddEmployee(Employee employee);
}
public class ServiceClass : IServiceClass
{
public Employee AddEmployee(Employee employee)
{
//do something
}
}
[MessageContract]
public class Employee
{
[MessageHeader]
public string EmployeeNumber { get; set; }
[MessageBodyMember]
public string FirstName { get; set; }
[MessageBodyMember]
public string LastName { get; set; }
[MessageBodyMember]
public DateTime DOB { get; set; }
}
Then I am adding this service to my client application using Add service reference option. The service added successfully. Then in my client program I used this method. But the method signature has been changed. It changed as follows.
public void AddEmployee(ref string EmployeeNumber,
ref System.DateTime DOB, ref string FirstName, ref string LastName)
I am using the service in the client as follows.
TcpServiceReference.ServiceClassClient service =
new TcpServiceReference.ServiceClassClient();
NOTE:TcpServiceReference is the service name
I cant understand the reason.
Not exactly sure why WCF does this some times, but if you use the service interface, you'll get the "correct" method signatures:
TcpServiceReference.IServiceClass service =
new TcpServiceReference.ServiceClassClient();
(this is assuming that IServiceClass
is the client-side name of the service interface that svcutil (Add Service Reference) has generated for you.)