you could try something like this...
First, add the class below to the client.
namespace EmployeeProxy
{
public class Employee : ServiceReference1.Employee
{
public new string Name
{
get
{
return base.Name;
}
set
{
using (var client = new ServiceReference1.Service1Client())
{
client.SetName(this, value);
}
base.Name = value;
}
}
}
}
Secondly, make the following change to the client code:
try
{
EmployeeProxy.Employee employee = new EmployeeProxy.Employee();
employee.Name = "";
employee.PhoneNo = "123456789";
employee.Address = "ABC TEMP ADD";
}
catch (Exception)
{
throw;
}
Thirdly, add the following method to the service:
[WebMethod]
public void SetName(Employee e, string name)
{
e.Name = name;
}
And finally, update the Service Reference on the Client.
NOTE: This is not a very good way to use web services however, and a better method would be:
- Create a Type Library with the Employee class.
- Reference the Type Library from the Client project.
- Ensure the Service Reference is configured to 'Reuse types in referenced assemblies...' on Configure Service Reference dialog box.
Then you can ignore the service part altogether when working with the Employee type, and exceptions will be thrown where indicated above without making a service call