简体   繁体   English

C#,wsdl代理类,如何使用?

[英]C# , wsdl proxy classes , how to use it?

我有一个wsdl和xsd文件,并使用wsdl.exe实用工具生成代理类,但是在项目中我没有任何服务引用,可以在c#中使用它吗?

If you want to consume the web service use wsdl.exe to generate the proxy class and after adding that class in your project you can use the service and their methods. 如果要使用Web服务,请使用wsdl.exe生成代理类,并在您的项目中添加该类后,可以使用该服务及其方法。 And if you have a wcf service which you want to consume you will have to use svcutil.exe to generate the proxy class. 而且,如果您要使用wcf服务,则必须使用svcutil.exe生成代理类。 you need not to create the metadata(wsdl,xsd etc.) of the service. 您无需创建服务的元数据(wsdl,xsd等)。

wsdl.exe will generate a .cs file containing the proxy classes. wsdl.exe将生成一个包含代理类的.cs文件。 You need to copy and include this file to your project (Add existing file ...). 您需要将该文件复制并包括到您的项目中(添加现有文件...)。

And if you want to use a WCF client you should use svcutil.exe to generate your client proxy, not wsdl.exe . 如果要使用WCF客户端,则应使用svcutil.exe生成客户端代理,而不是wsdl.exe The Add Service Reference dialog in Visual Studio internally uses svcutil.exe. Visual Studio中的“添加服务引用”对话框在内部使用svcutil.exe。 The Add Web Reference dialog uses wsdl.exe. “添加Web参考”对话框使用wsdl.exe。

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

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