How to call Webservice from Windows Service?

梦想的初衷 提交于 2019-12-18 17:36:07

问题


How to call Webservice from Windows Service?

I am having one webservice on my Webserver.

I have a windows-service to trigger that webservice.

So I just want to integrate and call my webservice from my windows service.

How can I do that?

EDIT:

TempWindowService is name of my windows application

MyServ is the name of my reference of my webservice.

 TempWindowService.MyServ newService = new TempWindowService.MyServ();
 newService.BatchProcess();

Here BatchProcess() is the webmethod under my webservice.

I get error on line

 TempWindowService.MyServ newService = new TempWindowService.MyServ();

Error is as below

 'TempWindowService.MyServ' is a 'namespace' but is used like a 'type'  

ANSWER:

For Those Who are interested in solution to this question, this is the code to be written

TempWindowService.MyServ.MyServSoapClient newService = new TempWindowService.MyServ.MyServSoapClient();

Hope this Helps everyone looking for a solution to this question. :)


回答1:


You'd call it just like you would from any application, web or otherwise. In Visual Studio, add a Service Reference for the web service in question to the project for the Windows Service. This will generate proxy classes for you which you would use in your code to access the web service.



来源:https://stackoverflow.com/questions/5470445/how-to-call-webservice-from-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!