天天看點

關于Bugzilla WebService接口API名稱 描述 方法調用參數 帳号登陸 方法穩定的、實驗性的及不穩定的狀态 錯誤

參考:http://www.bugzilla.org/docs/3.2/en/html/api/Bugzilla/WebService.html

http://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService.html

剛翻譯完就發現找到是老的api。。。

新版中支援json格式傳回、并多了很多接口:

<dl></dl>

<dt></dt>

<dd></dd>

Bugzilla::WebService - Bugzilla的Web Service接口

Bugzilla WebServices的通路入口是Bugzilla安裝目錄中 <code>xmlrpc.cgi</code> 腳本檔案。比如,如果你的 Bugzilla 位于 <code>bugzilla.yourdomain.com,那麼</code>你的 XML-RPC 用戶端就要通路 API : <code>http://bugzilla.yourdomain.com/xmlrpc.cgi</code>

除了标準的參數類型如<code>int</code>, <code>string等外,XML-RPC還有兩種資料結構</code> <code>&lt;struct&gt;</code> 及 <code>&lt;array&gt;。</code>

XML-RPC:

API文檔裡:

以下示例代碼中,<code>[</code> 和 <code>]</code> 用來代表數組的起止界定。

比如,XML-RPC中的數組

在API文檔裡,會寫成:

所有的Bugzilla WebServices 函數以&lt;struct&gt;的形式接收參數。換句話說,所有函數都隻接收單個參數,所有的參數都包含在這個參數中。API文檔中列出的對應名稱的參數意味着放在struct資料結構中。

Added in Bugzilla 3.6

You can specify <code>Bugzilla_login</code> and <code>Bugzilla_password</code> as arguments to any WebService method, and you will be logged in as that user if your credentials are correct. Here are the arguments you can specify to any WebService method to perform a login:

The <code>Bugzilla_restrictlogin</code> option is only used when you have also specified <code>Bugzilla_login</code> and <code>Bugzilla_password</code>.

Added in Bugzilla 5.0 and backported to 4.4.3

You can specify <code>Bugzilla_token</code> as argument to any WebService method, and you will be logged in as that user if the token is correct. This is the token returned when calling <code>User.login</code> mentioned above.

Support for using login cookies for authentication has been dropped for security reasons.

Methods are marked STABLE if you can expect their parameters and return values not to change between versions of Bugzilla. You are best off always using methods markedSTABLE. We may add parameters and additional items to the return values, but your old code will always continue to work with any new changes we make. If we ever break aSTABLE interface, we'll post a big notice in the Release Notes, and it will only happen during a major new release.

Methods (or parts of methods) are marked EXPERIMENTAL if we believe they will be stable, but there's a slight chance that small parts will change in the future.

Certain parts of a method's description may be marked as UNSTABLE, in which case those parts are not guaranteed to stay the same between Bugzilla versions.

如果某個webservice調用失敗,它會抛出一個标準的XML-RPC錯誤。包括一個數字格式的錯誤代碼,以及相應的描述文字。這些錯誤代碼是固定的,不會因Bugzilla的版本變化而改變。

各種抛出的錯誤由那些函數的相應文檔進行聲明。如果你的代碼中需要知道會抛出什麼錯誤,用數字代碼而不要去分析那些描述文字,因為各版本可能會有變化。

臨時錯誤與重大錯誤

如果錯誤代碼是大于0的數字,該錯誤就可以叫做臨時錯誤,意味着是由于使用者的輸入引起的錯誤,而不是系統本身。

如果錯誤代碼小于0,則該錯誤是緻命性的,意味着是系統錯誤,可能需要聯系管理者解決。

負數與正數錯誤不是對稱的,比如有一個代号是302的錯誤,但不一定就對應有-302的錯誤。

有時函數可能抛出具體含義的錯誤代碼,這種情況下-32000代表系統重大錯誤,32000則代表是臨時性錯誤。

繼續閱讀