Solved

HOWTO: Calling a asp.net web service from Windows Service?

Posted on 2004-09-22
8
1,389 Views
Last Modified: 2012-06-27
I have a c# class that is invoked from a windows service, I am trying to call an asp.net 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 http://www.anotherserver.com/services/service.asmx without hard coding this into the class?

thanks in advance

0
Comment
Question by:Rodney Helsens
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12123224
you don;t want to do...

project -> add web reference -> and enter http://www.anotherserver.com/services/service.asmx

in visual studio.net

0
 
LVL 7

Assisted Solution

by:God_Ares
God_Ares earned 100 total points
ID: 12123365
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?

regards

Floris Briolas
0
 
LVL 5

Expert Comment

by:tomasX2
ID: 12123970
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.

http://www.codeproject.com/cs/webservices/CallXMLWebServices.asp
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 9

Author Comment

by:Rodney Helsens
ID: 12124168
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 project...it 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?

thanks
0
 
LVL 15

Assisted Solution

by:praneetha
praneetha earned 150 total points
ID: 12124183
can my c# class have a .config file even if I am building a .dll and dropping it into another project?


yes you can....
0
 
LVL 5

Accepted Solution

by:
tomasX2 earned 250 total points
ID: 12124213
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.
0
 
LVL 9

Author Comment

by:Rodney Helsens
ID: 12124314
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
0
 
LVL 5

Expert Comment

by:tomasX2
ID: 12124328
just the dll.
all of the other stuff is project specific stuff.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question