Solved

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

Posted on 2004-09-22
8
1,393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

717 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