在 C# Windows 应用程序中使用 Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11184308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 16:55:01  来源:igfitidea点击:

Use a Web Service in C# Windows App

c#web-services

提问by Samy S.Rathore

I am new to using web services. I am assigned a task in which I need to use a web service in my Windows app. This is the web service I would be using: https://api.betfair.com/global/v3/BFGlobalService.wsdl

我是使用 Web 服务的新手。我被分配了一项任务,需要在我的 Windows 应用程序中使用 Web 服务。这是我将使用的网络服务:https: //api.betfair.com/global/v3/BFGlobalService.wsdl

Now, I've learned how to add a web reference to this service, but I could not find a basic tutorial that could help me learn how to make an object of this web service and use the service as I want to.

现在,我已经学会了如何向该服务添加 Web 引用,但是我找不到可以帮助我学习如何创建该 Web 服务的对象并根据需要使用该服务的基本教程。

Basicaly, what I need is to create an object from the above web service in my form, and to call it's methods. A C# code snippet would be great.

基本上,我需要的是在我的表单中从上述 Web 服务创建一个对象,并调用它的方法。AC# 代码片段会很棒。

Can anyone give me some directions? I am working in Visual Studio 2008 and a C# Windows App.

谁能给我一些方向?我在 Visual Studio 2008 和 C# Windows 应用程序中工作。

采纳答案by shajivk

  1. Right click on References
  2. select Add Service Reference
  3. give the wsdl address in the address textbox
  4. click Discover
  5. Give a name for the namespace eg;- BFG
  6. You can access the resources like BFG.MethodName() from you code
  1. 右键单击引用
  2. 选择添加服务引用
  3. 在地址文本框中给出 wsdl 地址
  4. 点击发现
  5. 为命名空间命名,例如;- BFG
  6. 你可以从你的代码中访问像 BFG.MethodName() 这样的资源

回答by Rajesh Subramanian

Please look at the following link for a sample application of consuming C# WEb Service in Win App,

请查看以下链接,获取在 Win App 中使用 C# WEB Service 的示例应用程序,

http://www.codeproject.com/Articles/2761/Consuming-Web-Services-from-a-Win-Forms-Applicatio

http://www.codeproject.com/Articles/2761/Consuming-Web-Services-from-a-Win-Forms-Applicatio

回答by ketan italiya

for consuming a web service here is the steps for that.see it.,from there you will get your solution.

这里是使用 Web 服务的步骤。查看它。,从那里您将获得解决方案。

click here

点击这里