I want to use an interface in both the webservice and its client. For
example, the web service implements an interface and then the client cast
that webservice to the inteface. It seems impossible, but I am wondering if
there is a way.
The code below shows how I want it:
/*INTERFACE*/
public interface IEmployee
{
String GetName();
Int32 GetID();
}
/* WEBSERVICE*/
public class Employee : System.Web.Services.WebService,IEmployee
{
public Employee()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string GetName()
{
return "Ali";
}
[WebMethod]
public Int32 GetID()
{
return 2333;
}
}
/*Windows Client*/
//but this code is not casting, return null
public IEmployee GetEmployee()
{
//WSEmployee is the webservice reference
return new WSEmployee.Employee() as IEmployee;
}
--
Mike