C#根据wsdl文件生成客户端调用代码

C#根据wsdl文件生成客户端调用代码,

要用到visaul studio的命令行工具。进入开始菜单visual studio的菜单,选择 "visual studio tool",打开菜单里面命令提示符选项,输入一下命令:

wsdl .\soapService.xml.wsdl /si  /namespace:nsname /out:.\ISoapService.cs

  这个命令生成服务端的接口文件,其中soapService.xml.wsdl是当前目录的wsdl文件

 

如果要生成客户端类文件,输入一下命令:

wsdl .\soapService.xml.wsdl  /namespace:nsname /out:.\SoapService.cs

  

一个完整的例子如下:

D:\>wsdl .\soapService.xml.wsdl /si  /namespace:nsname /out:.\ISoapService.cs
Microsoft(R) Web Services 描述语言实用工具
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
正在写入文件“.\ISoapService.cs”。

D:\>wsdl .\soapService.xml.wsdl  /namespace:nsname /out:.\SoapService.cs
Microsoft(R) Web Services 描述语言实用工具
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
正在写入文件“.\SoapService.cs”。

D:\>

 

关于参数:

/namespace:nsname 是指定命名空间为nsname, 如果需要修改,可以直接改为所需要的命名空间
posted @ 2021-08-12 12:11  薛定谔的青蛙王梓  阅读(1210)  评论(0编辑  收藏  举报