1. 程式人生 > 其它 >C#根據wsdl檔案生成客戶端呼叫程式碼

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, 如果需要修改,可以直接改為所需要的名稱空間