HOWTO: Calling a web service from Windows Service?

I have a c# class that is invoked from a windows service, I am trying to call an web service from this class, I'm a bit confused with the web references..

I have the class which the windows services calls. I need to put this class into the directory where the windows service runs, in regards to the web references.. how do I reference the web service located at without hard coding this into the class?

thanks in advance

Rodney HelsensAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

tomasX2Connect With a Mentor Commented:
you could add the necessary configuration settings to the app.config thats already there....
in other words you share the app.config file.

Just put the settings into the app.config file.
you don;t want to do...

project -> add web reference -> and enter

in visual

God_AresConnect With a Mentor Commented:
do you or don't you want to make a proxy class? like praneetha is describing. Dou you want to call the same service from other locations/urls? Or should nothing be known of the webservice except it's adress, and dynamicly call functions?


Floris Briolas
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

you add the web reference and have it dynamic.
this will add a application.exe.config file to the project
there you can change the url of the web service.
Rodney HelsensAuthor Commented:
I appreciate your comments...

I think the problem is that the windows service (which my class is called from) already has it's own app.config file, it is a seperate project.

The windows services was built by another developer, not my dynamically loads classes (which inherit the appropriate interface) based on events..

I am creating this class outside of the project for the windows service... so that is where my confusion comes in with the references... can my c# class have a .config file even if I am building a .dll and dropping it into another project?

praneethaConnect With a Mentor Commented:
can my c# class have a .config file even if I am building a .dll and dropping it into another project?

yes you can....
Rodney HelsensAuthor Commented:
Ok, thanks. I think I will share the app.config file then.. but what other files from my web service project will I need to copy over to the windows service project for it to work, besides the .dll?

I see the web references folder is created in my project. do I also need to copy this web references folder to the other project? or just the .wsdl file? or can I just copy my dll?

As you can see, I have not grasped the concept of this proxy class stuff, how it works

thanks for helping me
just the dll.
all of the other stuff is project specific stuff.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.