如何使用本地 WSDL 文件使用 WCF 服务?

问题描述:

我需要使用基于(最好是单个)wsdl 文件的 WCF 服务.

I need to consume a WCF service based on a (preferably single) wsdl file.

环境是 VS-2008 (sp1),我将使用自定义的添加服务引用"宏来生成错误处理代理.我希望能够通过提供从服务提供商处获得的 WSDL 文件(我不想提供主机 URL)来做到这一点.

The environment is VS-2008 (sp1), and I will be using a customized "Add Service Reference" macro to generate an error handling proxy. I want to be able to do this, by supplying a WSDL file that I get from the service provider (I do not want to supply a host URL).

如何做到这一点?

当然 - 您可以复制 WSDL 的路径+文件名并将其粘贴到 Visual Studio 中的添加服务引用"对话框中(或者只需键入 int完整路径 + WSDL 文件名).

Sure - you can copy the path+filename for the WSDL and paste that into the "Add Service Reference" dialog box in Visual Studio (or just type int the full path + WSDL file name).

或者,您可以使用 svcutil.exe 命令行实用程序将 WSDL 文件转换为您的客户端代理类.

Alternatively, you can use the svcutil.exe command line utility to convert the WSDL file to your client proxy class.