生成 Web 服务代理 (Master Data Services)

可以使用一个代理类通过 Web 服务以编程方式访问 Master Data Services。可以通过两种方式将代理类添加到开发项目中:使用 .NET Framework 中的 Svcutil.exe 命令行工具,或在 Microsoft Visual Studio 中添加 Web 引用。

使用 Svcutil.exe 添加代理

必须安装了 Microsoft Visual Studio 或 Microsoft Windows SDK,才能在计算机上运行 Svcutil.exe。如果使用 Visual Studio,必须使用 Visual Studio 命令提示符运行该命令。有关详细信息,请参阅 ServiceModel Metadata Utility Tool (Svcutil.exe)(ServiceModel 元数据实用工具 (Svcutil.exe))和 Generating a WCF Client from Service Metadata(从服务元数据生成 WCF 客户端)。

若要使用 Svcutil.exe 来添加代理类,请使用如下命令:

svcutil.exe http://<server_name:port>/<virtual_path>/Service/Service.svc 
/out:<proxy_name>.cs /messageContract /tcv:Version35 
/noconfig /ct:System.Collections.ObjectModel.Collection`1 
/namespace:*,Microsoft.MasterDataServices

其中:

  • servername:port 是承载 Master Data Services 的计算机的名称和端口号。

  • virtual_path 是 Master Data Services 在 Internet Information Services (IIS) 中的虚拟路径。

  • proxy_name 是生成的代理的 C# 类名称。

使用 Web 引用添加代理

您还可以通过在 Visual Studio 项目中提供一个 Web 引用来添加代理。有关详细信息,请参阅 How to: Add and Remove Web References(如何添加和删除 Web 引用)。