C# 在 windows 应用程序窗体中调用 web 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19951302/
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
Calling a web service in a windows application form
提问by Alex
EDIT. I was adding it as a service reference instead of a web service reference (found by when adding a service refererence, go into advanced and down the bottom it should say "add web reference") , I didn't know that option existed as it's hidden away.
编辑。我将它添加为服务引用而不是 Web 服务引用(通过添加服务引用时发现,进入高级和底部它应该说“添加 Web 引用”),我不知道该选项存在,因为它是藏起来。
I made a web service in c# .net. Initially it wasn't calling because I thought that the web form didn't like the codebehind for the web form that is created in VS2012, so I took that out and just included the web service file itself.
我在 c# .net 中做了一个 web 服务。最初它没有调用,因为我认为 Web 表单不喜欢在 VS2012 中创建的 Web 表单的代码隐藏,所以我将其取出并仅包含 Web 服务文件本身。
I'm pretty sure the libraries were included when I visit the url of the service with wsdl, but it still won't seem to call the service to the form.
当我使用 wsdl 访问服务的 url 时,我很确定这些库已包含在内,但它似乎仍然不会将该服务调用到表单中。
It displays some XML data and shows TestCypher as a workable service, so it should be working? I'm not entirely sure where the wsdl file should be hosted if I take the web service out of the solution
它显示一些 XML 数据并将 TestCypher 显示为一个可行的服务,所以它应该可以工作吗?如果我从解决方案中取出 Web 服务,我不完全确定 wsdl 文件应该托管在哪里
回答by Ragesh S
Please see the below link
请看下面的链接
http://www.codeproject.com/Articles/26941/Consuming-Webservice-In-A-Windows-Application
http://www.codeproject.com/Articles/26941/Consuming-Webservice-In-A-Windows-Application
you can use this method in your application. I just post this example in your requirement.
您可以在您的应用程序中使用此方法。我只是在你的要求中发布了这个例子。
please note : i have no guarantee about the perfomrnce area in this method.
请注意:我不能保证此方法中的性能区域。
So please consider this element when your application is use a wide number of users.
因此,当您的应用程序使用大量用户时,请考虑此元素。
Hope it help.
希望有帮助。