net自带wsdl.exe的用法与参数说明

来源:互联网 发布:网络暴力致死 编辑:程序博客网 时间:2024/05/20 14:26

wsdl.exe 现在的位置在 C:/Program Files/Microsoft SDKs/Windows/v6.0A/bin

 

我手里只有一个bizOprtater.wsdl文件,我用这个命令:
wsdl.exe   /l:CS   /n:bizOprtater   /out:bizOprtater.cs   bizOprtater.wsdl
生成了bizOprtater.cs

打开.net自己带的Visual Studio .NET 2003 命令提示 输入

wsdl /language:VB /n:mynamespace /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

默认为C#语言

/language:VB 为输出语言

/n:mynamespace namespace

/out:myProxyClass.cs 输出文件名

其中参数部分可以参考下面的参数来加到WSDL与 服务的URL之间

.net自带的帮助文档

Web 服务描述语言工具从 WSDL 协定文件、XSD 架构和 .discomap 发现文档为 XML Web services 和 XML Web services 客户端生成代码。

wsdl [options] {URL | path}

参数说明

URL指向 WSDL 协定文件 (.wsdl)、XSD 架构文件 (.xsd) 或发现文档 (.disco) 的 URL。请注意,您不能将 URL 指定为 .discomap 发现文档。

path本地 WSDL 协定文件 (.wsdl)、XSD 架构文件 (.xsd) 或发现文档(.disco 或 .discomap)的路径。

选项说明

/appsettingurlkey:key

/urlkey:key指定在生成代码时用于读取 URL 属性的默认值的配置键。

/appsettingbaseurl:baseurl

/baseurl:baseurl指定计算 URL 片段时所使用的基 URL。此工具通过将相关 URL 从 baseurl 参数转换为 WSDL 文档中的 URL 来计算 URL 片段。您必须用此选项来指定 /appsettingurlkey 选项。

/d[omain]:domain指定连接到要求身份验证的服务器时要使用的域名。

/l[anguage]:language指定用于所生成的代理类的语言。您可以指定 CS(C#;默认)、VB (Visual Basic)、JS (Jscript) 或 VJS (Visual J#) 作为语言参数。还可以指定实现 System.CodeDom.Compiler.CodeDomProvider 类的类的完全限定名称。

/n[amespace]:namespace指定所生成的代理或模板的命名空间。默认命名空间是全局命名空间。

/nologo取消显示 Microsoft 启动标题。

/o[ut]:filename指定用于保存所生成的代理代码的文件。该工具将从 XML Web services 名称来导出默认的文件名称。该工具将生成的数据集保存在不同的文件中。

/parsableerrors以类似于语言编译器所使用的错误报告格式显示错误。

/p[assword]:password指定连接到要求身份验证的服务器时要使用的密码。

/protocol:protocol指定要实现的协议。可以指定 SOAP(默认值)、HttpGet、HttpPost 或在配置文件中指定的自定义协议。

/proxy:URL指定用于 HTTP 请求的代理服务器的 URL。默认为使用系统代理设置。

/proxydomain:domain

/pd:domain指定连接到要求身份验证的代理服务器时要使用的域。

/proxypassword:password

/pp:password指定当连接到要求身份验证的代理服务器时要使用的密码。

/proxyusername:username

/pu:username指定连接到要求身份验证的代理服务器时要使用的用户名。

/server根据协定生成 XML Web services 的抽象类。默认为生成客户端代理类。

/u[sername]:username指定连接到要求身份验证的服务器时要使用的用户名。

/?显示此工具的命令语法和选项。

备注

.wsdl 文件是一个使用称作 Web 服务描述语言 (WSDL) 的 XML 语法编写的 XML 文档。此文件定义 XML Web services 的行为方式并指示客户端如何与该服务交互。

可以使用 Web 服务发现工具 (Disco.exe) 获得 XML Web services 的发现文档。由此工具生成的 .discomap、.disco、.wsdl 和 .xsd 文件可以用作 Wsdl.exe 的输入。

当您使用 Wsdl.exe 创建代理类时,将用指定的编程语言创建一个源文件。在为代理类生成源代码的过程中,该工具确定用于服务说明中指定的对象的最佳类型。在某些情况下,该工具使用最小公分母方法将这些对象转换成一个类型。因此,代理类中的生成类型可能不是开发人员想要或预期的类型。例如,当 Wsdl.exe 在服务说明中遇到 ArrayList 类型时,它将在生成的代理类中创建 Object Array。若要确保对象类型转换正确,请打开包含生成的代理类的文件,将所有不正确的对象类型更改成所需的对象类型。

示例

下面的命令为处于指定 URL 处的 XML Web services 创建 .wsdl 文件,并用 C# 语言为 XML Web services 创建客户端代理类。

wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

下面的命令用 C# 语言为位于指定 URL 处的 XML Web services 创建客户端代理类。该工具将客户端代理类保存在 myProxyClass.cs 文件中。

wsdl /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

下面的命令用 Microsoft Visual Basic 语言为位于指定 URL 处的 XML Web services 创建客户端代理类。该工具将客户端代理类保存在 myProxyClass.vb 文件中。

wsdl /language:VB /out:myProxyClass.vb http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

如果使用的是vs.net开发的话,就可以直接使用工具中的web引用向导,可自动生成代理类和所有相关的文件。

The Web Services Description Language tool generates code for XML Web services and XML Web service clients from WSDL contract files, XSD schemas, and .discomap discovery documents.

 

wsdl [options] {URL | path}

ArgumentDescriptionURLThe URL to a WSDL contract file (.wsdl), XSD schema file (.xsd), or discovery document (.disco). Note that you cannot specify a URL to a .discomap discovery document.pathThe path to a local WSDL contract file (.wsdl), XSD schema file (.xsd), or discovery document (.disco or .discomap).

OptionDescription/appsettingurlkey:key

 

or

/urlkey:key

Specifies the configuration key to use in order to read the default value for the URL property when generating code./appsettingbaseurl:baseurl

 

or

/baseurl:baseurl

Specifies the base URL to use when calculating the URL fragment. The tool calculates the URL fragment by converting the relative URL from the baseurl argument to the URL in the WSDL document. You must specify the /appsettingurlkey option with this option./d[omain]:domainSpecifies the domain name to use when connecting to a server that requires authentication./l[anguage]:languageSpecifies the language to use for the generated proxy class. You can specify CS (C#; default), VB (Visual Basic), JS (JScript) or VJS (Visual J#) as the language argument. You can also specify the fully qualified name of a class that implements the System.CodeDom.Compiler.CodeDomProvider Class./n[amespace]:namespaceSpecifies the namespace for the generated proxy or template. The default namespace is the global namespace./nologoSuppresses the Microsoft startup banner display./o[ut]:filenameSpecifies the file in which to save the generated proxy code. The tool derives the default file name from the XML Web service name. The tool saves generated datasets in different files./parsableerrorsDisplays errors in a format similar to the error reporting format used by language compilers./p[assword]:passwordSpecifies the password to use when connecting to a server that requires authentication./protocol:protocolSpecifies the protocol to implement. You can specify SOAP (default), HttpGet, HttpPost, or a custom protocol specified in the configuration file./proxy:URLSpecifies the URL of the proxy server to use for HTTP requests. The default is to use the system proxy setting./proxydomain:domain

 

or

/pd:domain

Specifies the domain to use when connecting to a proxy server that requires authentication./proxypassword:password

 

or

/pp:password

Specifies the password to use when connecting to a proxy server that requires authentication./proxyusername:username

 

or

/pu:username

Specifies the user name to use when connecting to a proxy server that requires authentication./serverGenerates an abstract class for an XML Web service based on the contracts. The default is to generate client proxy classes./u[sername]:usernameSpecifies the user name to use when connecting to a server that requires authentication./?Displays command syntax and options for the tool.

Remarks

A .wsdl file is an XML document written in an XML grammar called Web Services Description Language (WSDL). This file defines how an XML Web service behaves and instructs clients as to how to interact with the service.

You can obtain discovery documents for an XML Web service using the Web Services Discovery Tool (Disco.exe). The .discomap, .disco, .wsdl, and .xsd files produced by this tool can be used as input to Wsdl.exe.

When you use Wsdl.exe to create a proxy class, a single source file is created in the programming language that you specify. In the process of generating the source code for the proxy class, the tool determines the best type to use for objects specified in the service description. In some cases the tool uses a least-common-denominator approach for casting objects to a type. As a result, the generated type in the proxy class might not be what the developer wants or expects. For example, when Wsdl.exe encounters an ArrayList type in a service description, it creates an Object Array in the generated proxy class. To ensure correct object type casts, open the file containing the generated proxy class and change any incorrect object types to the expected object type.

Examples

The following command creates a .wsdl file for the XML Web service located at the specified URL and creates a client proxy class in the C# language for the XML Web service.

 

Copy Code

wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following command creates a client proxy class in the C# language for an XML Web service located at the specified URL. The tool saves the client proxy class in the file

myProxyClass.cs

.

 

Copy Code

wsdl /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following command creates a client proxy class in the Microsoft Visual Basic language for an XML Web service located at the specified URL. The tool saves the client proxy class in the file

myProxyClass.vb

.

 

Copy Code

wsdl /language:VB /out:myProxyClass.vb http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

原创粉丝点击