如何从Windows服务调用web服务? [英] How to call Webservice from Windows Service?

查看:457
本文介绍了如何从Windows服务调用web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Windows服务调用web服务?

How to call Webservice from Windows Service?

我在我的网络服务器有一个Web服务。

I am having one webservice on my Webserver.

我有一个Windows服务来触发该web服务。

I have a windows-service to trigger that webservice.

所以,我只是要整合,并从我的窗口服务调用我的web服务。

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

我怎么能这样做?

编辑:

TempWindowService 是我的windows应用程序的名称

TempWindowService is name of my windows application

MyServ 是我的我的web服务的引用的名称。

MyServ is the name of my reference of my webservice.

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

下面 BatchProcess()是在我的web服务将WebMethod。

Here BatchProcess() is the webmethod under my webservice.

我上线误差

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

错误是如下

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

答:

对于那些有兴趣的解决了这个问题,这是要写入的code

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. :)

推荐答案

您会调用它就像你从任何应用程序,网络或其他方式。在Visual Studio中,添加一个服务引用为Web服务问题该项目为Windows服务。这将生成代理类适合你,你会用你的code来访问Web服务。

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.

这篇关于如何从Windows服务调用web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆