我們的Vault開發專家Barbara離開了,我不得不開始學習Vault API了。如果你也剛開始學習Vault,這篇文章也許對有你幫助。Vault用戶端主要采用Web Service與Vault伺服器通訊,Vault也提供了豐富的API,其中重要的就是各個WebService。Vault提供了.net的API,可以用C#或者VB.net來做定制開發,開發工具自然是Visual Studio了。 Vault 2013開始,Vault API支援.net framework 4.0, 所有這裡使用VS2010. 做個最簡單的WinForm程式,枚舉Vault伺服器中的所有檔案。
Vault 的SDK會随Vault Server或者Vault Client安裝,在Vault的安裝目錄\SDK 目錄下可以找到Vault SDK的安裝檔案,安裝完畢後可以得到下列目錄:

首先建立一個WinForm的應用程式,注意對于Vault 2013來說,需要使用.net Framework 4.0 .在上面添加一個listbox和一個button,然後添加引用。這裡作為一個獨立的應用程式,隻需要引用Autodesk.Connectivity.WebServices.dll即可,然後編寫代碼如下:
代碼并不複雜,在編譯時會提示'Microsoft.Web.Services3.WebServicesClientProtocol程式集找不到,
Error 1 The type 'Microsoft.Web.Services3.WebServicesClientProtocol' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
解決辦法即按照提示添加'Microsoft.Web.Services3的引用即可。如果你安裝了Vault Client,這個dll在C:\Program Files (x86)\Microsoft WSE\v3.0目錄下。如果你沒有安裝Vault client,你需要自行從微軟網站下載下傳WSE3(Web Service Extension)
另外還有錯誤資訊:
Error 1 The type 'System.Web.Services.Protocols.SoapHttpClientProtocol' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
需要添加System.Web.Services的引用。
然後編譯運作,結果如下:
轉載請保留此資訊。
本文轉自峻祁連. Moving to Cloud/Mobile部落格園部落格,原文連結:http://www.cnblogs.com/junqilian/archive/2013/01/23/2872461.html,如需轉載請自行聯系原作者