简体   繁体   English

从.net应用程序调用Web服务如何工作?

[英]How does calling a web service from a .net app work?

I added a web service as reference to a project and gave it name "days". 我添加了一个Web服务作为对项目的引用,并将其命名为“ days”。 But I don't actually understand how to work with it. 但是我实际上并不了解如何使用它。 Can someone show me the way how to get data from it? 有人可以告诉我如何从中获取数据的方式吗?

In posh I get data from a web service this way: 在豪华的情况下,我通过以下方式从Web服务获取数据:

$ws= New-WebServiceProxy -uri $xmld.Root.WebService.Address -credential $cred

$xml = $ws.getdays()

$xml

替代文字

Fortunately, you don't need to write a client application to test a web service because .NET includes a test web page that ASP.NET uses automatically when you request the URL of an .asmx file in a browser. 幸运的是,您不需要编写客户端应用程序来测试Web服务,因为.NET包括当您在浏览器中请求.asmx文件的URL时ASP.NET自动使用的测试网页。 This page uses reflection to read and show information about the web services, such as the names of the methods it provides. 该页面使用反射来读取和显示有关Web服务的信息,例如它提供的方法的名称。

To try the test page, request the xyz.asmx file of the web service in your browser. 要尝试测试页,请在浏览器中请求Web服务的xyz.asmx文件。 (In Visual Studio, you simply need to set this as the start page for your application and then run it.) (在Visual Studio中,您只需要将此设置为应用程序的起始页,然后运行它即可。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM