简体   繁体   English

如果是webservice,如何从WSDL生成代理类

[英]How to generate proxy class from WSDL in case of webservice

suppose when i have only wsdl file then how can i create proxy class just to call webservice various method. 假设当我只有wsdl文件时,我怎么能创建代理类只是为了调用webservice各种方法。 how webservice related all class and its property & method will be exposed in my c# apps. webserser如何关联所有类及其属性和方法将在我的c#apps中公开。 can anyone help guiding me. 任何人都可以帮助指导我。 thanks 谢谢

You would need to use the ServiceModel Metadata Utility Tool , or Visual Studio's Add Service Reference Dialog in order to generate a client proxy for the service with which you want to communicate. 您需要使用ServiceModel元数据实用工具或Visual Studio的“ 添加服务引用”对话框 ,以便为要与之通信的服务生成客户端代理。 The generated proxy will provide classes that abstract the service contract, and you can program your client applications to interact with these classes. 生成的代理将提供抽象服务契约的类,您可以对客户端应用程序进行编程以与这些类进行交互。

There is an utility, it shipps with Visual Studio (since 2005, I think), called wsdl.exe 有一个实用程序,它与Visual Studio(自2005年以来,我认为),称为wsdl.exe

It's commandline, and can be used to generate proxy. 它是命令行,可用于生成代理。

You can use WSDL.exe tool using command line. 您可以使用命令行使用WSDL.exe工具。

ie WseWsdl3 WSDLPath /out:MyProxyClass.cs 即WseWsdl3 WSDLPath /out:MyProxyClass.cs

if WseWsdl3.exe is unable to create the proxy class, there is still a way. 如果WseWsdl3.exe无法创建代理类,仍有一种方法。

If you can run your service as a regular ASP.NET web application in IIS, it creates temporary ASP.NET files where the proxy class is nicely generated for you. 如果您可以在IIS中将您的服务作为常规ASP.NET Web应用程序运行,它将创建临时ASP.NET文件,其中可以很好地为您生成代理类。

You can find it in folder: 你可以在文件夹中找到它:

C:\\Windows\\Microsoft.NET\\Framework\\vMAJOR.MINOR.BUILD\\Temporary ASP.NET Files\\YOUR_WEB_APP. C:\\ Windows \\ Microsoft.NET \\ Framework \\ vMAJOR.MINOR.BUILD \\ Temporary ASP.NET Files \\ YOUR_WEB_APP。 There are some subfolders with random names, go to most recent one and look something like "App_WebReferences.XXXX.0.cs". 有一些随机名称的子文件夹,转到最近的一个,看起来像“App_WebReferences.XXXX.0.cs”。

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

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