从C#应用程序调用ASP.net Web服务 [英] Calling ASP.net Web Service from C# Application

查看:145
本文介绍了从C#应用程序调用ASP.net Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我怎样才能调用Web服务,并从一个C#桌面应用程序的结果。我想提出一个桌面应用程序,我希望它能够连接到我的网上ASP.net Web服务。这怎么可能呢?


解决方案

  1. 在解决方案资源管理器中,右键单击项目节点,并选择添加服务参考。

  2. 输入您的服务WSDL所在的URL。这通常是服务本身的URL。

  3. 这在一个新的服务参考项目文件夹中生成一个强类型的代理类。

  4. 在您的桌面应用程序实例化代理类并调用它的方法编写代码。其余的功效神奇。 :)



AB Kolan也是正确的,但添加网络参考使用旧样式的Web服务框架而添加的服务引用使用新的WCF堆栈。重要提示:这是不会服务本身使用WCF为您在客户端使用WCF必需的。 WCF客户端上的通常是任何服务的最佳选择,只要你能承担上述.NET 3.0和依赖。


I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?

解决方案

  1. In Solution Explorer, right-click your project node and select Add Service Reference.
  2. Enter the URL where your service WSDL is located. This is usually the URL of the service itself.
  3. This generates a strongly-typed proxy class in a new Services References folder in your project.
  4. Write code in your desktop app to instantiate the proxy class and invoke methods on it. The rest works like magic. :)

AB Kolan was also correct, but Add Web Reference uses the old-style web services framework whereas Add Service References uses the new WCF stack. Important note: It is not required that the service itself use WCF for you to use WCF on the client side. WCF on the client is typically the best choice for any service, provided you can take a dependency on .NET 3.0 and above.

这篇关于从C#应用程序调用ASP.net Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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