Adding web reference to a windows service

C

CyberLotus

Hi,

I've created a windows service (basically a polling service involving MSMQ)
and created a web service too in C#. Now in the windows service, I want to
give a reference to the web service.

I tried in usual manner, as described below:
1. In the solution explorer of windows service, I added a reference to the
web service.
2. Then, in the using section of windows service, I added, "using
<namespace>.<web ref name>". (though the web ref name was not showing after
putting the dot).
3. I created an object of the web service's class in windows service and
tried to access the web methods.

But this didn't work. It gave me the following build error: "The type or
namespace name 'GetFilesWS' does not exist in the class or namespace
'Knot.WeddingWarehouse.Interface.MSMQWindowsService' (are you missing an
assembly reference?)".

where 'GetFilesWS' is the <web ref name> and
'Knot.WeddingWarehouse.Interface.MSMQWindowsService' is the <namespace>.

Can anybody give me any clue on this.
TIA.
- CyberLotus
 
D

Dan Rogers

Did you reference the service class via add-reference? Or as
add-web-reference?

If you want to make a web service call, you use add-web-reference. This
creates a proxy which has it's own namespace.

If you used add-reference (to make a direct link), then you just need to
make sure the reference got added, is spelled correctly, etc.

Hope this helps

Dan Rogers
Microsoft Corporation
--------------------
 
C

CyberLotus

How do I reference the service class of the web service to the windows service?

So far my knowledge is concerned, I can only add the URL of my web service
not the class.

Please let me know. I'm stuck at this point for past 2 days.
TIA.
- CyberLotus
 
M

Mujtaba Syed

Hi:

The web service will be in an ASP.NET project, so it will be available as a
URL (for eg. http://your-server.com/app-name/webservice1.asmx)
In your VS.NET windows service project when you add web reference, you will
need to provide this same URL. VS.NET will download the WSDL of this service
and create a proxy (a class). This proxy resides in a file called
Reference.cs. You can use the web service from the windows service by
instantiating this class and invoking its methods.

Hope this helps,
Mujtaba.
 
D

Dan Rogers

Hi,

I have no idea what you just said...

How do I reference the service class of the web service to the windows service?

But, there are only two kinds of references. One is including a strong
link to the dll where the implementation is. The other is by using a proxy
to reference the remote implementation via an XML wire based interchange.

For the former, you would do "add reference". For the latter, you would do
"add web reference".

I wish I could say it in a clearer way to help you (I know, I already wrote
this).

Dan
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top