简体   繁体   English

如何在C#中使用WSDL文件使用WebService

[英]How to Consume a WebService using WSDL files in C#

So I have two wsdl files (xml based) and I need to use them to consume a web service. 所以我有两个wsdl文件 (基于xml),我需要使用它们来使用Web服务。 Not sure where to start? 不知道从哪里开始? I'm trying to add them in my Visual Studio Project Solution by clicking on "Add Service Reference" but I need an URL. 我试图通过单击“添加服务引用”将它们添加到我的Visual Studio Project解决方案中,但是我需要一个URL。

Should I add them to a Virtual Directory? 我应该将它们添加到虚拟目录吗? If so, how? 如果是这样,怎么办?

Thanks in advance 提前致谢

You already found the solution. 您已经找到了解决方案。 Use the "Add Service Reference" dialog and make sure your service is accessible by a URL. 使用“添加服务参考”对话框,并确保可以通过URL访问您的服务。 To do this either request the URL by the people offering the service or deploy the service in IIS. 为此,请提供服务的人员请求URL或在IIS中部署服务。

Personally I would forget about svcutil.exe. 我个人会忘记svcutil.exe。 If you have Visual Studio, it is much easier to add and update the service reference using the excellent integration of web services in Visual Studio. 如果您拥有Visual Studio,则可以使用Visual Studio中出色的Web服务集成来轻松添加和更新服务引用。

You can use the wsdl.exe tool which comes with Visual Studio (in there you can specify a local file path to your wsdl file) - 您可以使用Visual Studio随附的wsdl.exe工具(在其中可以指定wsdl文件的本地文件路径)-

http://msdn.microsoft.com/en-us/library/d2s8y7bs(VS.100).aspx http://msdn.microsoft.com/zh-CN/library/d2s8y7bs(VS.100).aspx

您可以使用wsdl文件的路径来添加服务引用。

You can use svcutil.exe as such: 您可以像这样使用svcutil.exe

svcutil.exe /language:cs /out:MyServiceProxy.cs /config:app.config c:\\path\\to\\my.wsdl svcutil.exe / language:cs /out:MyServiceProxy.cs /config:app.config c:\\ path \\ to \\ my.wsdl

Add your .wsdl address in address and click Go button.your service is add in your project. 在地址中添加.wsdl地址,然后单击“执行”按钮。您的服务已添加到您的项目中。

在此处输入图片说明

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

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