473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to make a Web service implement an interface

sys
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?
Nov 22 '05 #1
2 2758
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" <an*******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
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?
Nov 22 '05 #2
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" <an*******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
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?
Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sys | last post by:
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...
1
by: Larry Page | last post by:
Greetings, I'm using remoting to execute commands on a remote machine. My original testing used basic console client and server apps containing a common interface, which I built as a seperate...
2
by: Yi | last post by:
Hi, I am implementing a scheduler that will fire a command every 15 or 30 minutes. I would like to use web service interface to control the timer (start, stop, etc). I think a workable solution is...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
3
by: Rob R. Ainscough | last post by:
I have a Windows Service with a timer that use the .NET 2.0 Shell command. The Shell command returns a non-zero number but Task Manager shows the shelled exe running but there is NO visible...
6
by: dotNeter | last post by:
The services, talked here, are things used in IServiceContainer, IServiceProvider, etc. In my opinion, everything can be a service, and a service is generally used for providing specific features...
8
by: semedao | last post by:
Hi , I need to develop some feature of web service that can notify client - "Push" operation - and fast somebody know if it's possible , and how? When I say "Push" I mean - pure push :) , not...
0
by: =?Utf-8?B?RGlvZ28gQWx2ZXM=?= | last post by:
Greeting Nicholas, Thanks for your answer but I'm pretty new in this stuff.... I already have a class that inherits the MArshalByRefObject and I use it to get answers from the server like...
0
by: archana | last post by:
Hi all, I want to developed plug-in architecture in windows service. What i want is to develop one windows service which will monitor some folders and as soon as it gets any file on folder it...
0
by: ahk3wl | last post by:
Hi all, I am consuming two web services that are identical but on different servers. The WSDL is the same except for URL and namespace. Normally I could just add a web reference and swap URL at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.