How to make a Web service implement an interface

G

Guest

I have a Web service and I want it to implement an interface that I specified, say IService. So my Web service class looks like this

public class Service1 : System.Web.Services.WebService, IServic

public Service1(

InitializeComponent()


[WebMethod
...


On the client-side I want to use this Web service using my Interface

IService service = new WebService.Service1()

Unfortunately the last code line doesn't work because I get an error message saying that the conversion from WebService.Service1 to IService is not possible. Also an explicit type cast isn't possible
I think the problem is that my automatically generated proxy class for my Web service doesn't implement the interface IService. Do I have to make my proxy class implement the interface? And if yes how (doing it manually works, but my changes are lost the next time I refresh the reference)? Or is there another solution for my problem?
 
I

ilPostino

I don't think what you're tyring is possible. The attribute [WebMethod]
defines your external method but thats it, it doesn't define classes or
interfaces. If you want to use an interface on your client, create a wrapper
class around the web service class and impliment your interface there.

-p

sys said:
I have a Web service and I want it to implement an interface that I
specified, say IService. So my Web service class looks like this:
public class Service1 : System.Web.Services.WebService, IService
{
public Service1()
{
InitializeComponent();
}

[WebMethod]
....
}

On the client-side I want to use this Web service using my Interface:

IService service = new WebService.Service1();

Unfortunately the last code line doesn't work because I get an error
message saying that the conversion from WebService.Service1 to IService is
not possible. Also an explicit type cast isn't possible.
I think the problem is that my automatically generated proxy class for my
Web service doesn't implement the interface IService. Do I have to make my
proxy class implement the interface? And if yes how (doing it manually
works, but my changes are lost the next time I refresh the reference)? Or is
there another solution for my problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top