WebSphere Message Service Clients: Web Services Client for C++, Version 1.1 作業系統: Linux, Windows

XML 內建的簡式類型

內建的簡式類型共有 45 個,它們是在 include\Axis\AxisUserAPI.hpp 中定義的。 當類型為「可為空值」或「選用」(亦即,minOccurs=”0”),則類型會定義成簡式類型的指標。

簡式類型的一般範例

下列範例顯示 WSDL 中的一般簡式類型。這個範例中使用的簡式類型是 xsd:int,它是對映到 C++ 類型的 xsd__int。從 WSDL 擷取的項目具有一個稱為 addReturn 的元素,其類型為整數。add 作業會使用這個元素, 這個作業使用 addResponse 元素來定義呼叫 add 作業時所預期的回應類型。

<element name="addResponse">
 <complexType>
  <sequence>
   <element name="addReturn" type="xsd:int"/>
  </sequence>
 		</complexType>
</element>

WSDL 後來已經將 addResponse 元素當作 add 方法的回應部分。這樣可以從 WSDL 中的簡式類型來產生下列 Web Services Client for C++ Web 服務方法原型:

public:
STORAGE_CLASS_INFO xsd__int add( …);

因此,在這個範例中,使用者產生的應用程式碼如下:

xsd__int	xsd_iReturn = ws.add( …);

簡式類型指標的範例

當類型為「可為空值」(亦即, nillable=”true”)、 「選用」(亦即,minOccurs=”0”),或文字類型(例如 xsel:string),則類型會定義成指標。

<element name="addResponse">
 <complexType>
  <sequence>
   <element name="addReturn" nillable=”true” type="xsd:int"/>
  </sequence>
 		</complexType>
</element>

這樣可以產生下列 Web Services Client for C++ Web 服務方法原型:

public: 
STORAGE_CLASS_INFO xsd__int * add( …);

以下是 WSDL 中的可為空值簡式類型所產生的使用者產生應用程式碼:

xsd__int *	xsd_piReturn = ws.add( …);

// 在程式碼的後面部分…

// 刪除這個指標並將它設為 NULL(因為它是由用戶端
應用程式所擁有)。

delete xsd_piReturn;

xsd_piReturn = NULL;
註: 上述範例顯示回覆值的刪除作業。任何由 Web Services Client for C++ 傳回的指標都會成為 用戶端應用程式的責任,而且如果刪除 Web 服務,也不會超出範圍。一旦不再需要物件類型的指標,使用者應用程式必須刪除它。

Reference topic

使用條款 | 此頁的評等

「時間戳記」圖示前次更新: 28 Apr 2006
(C) Copyright IBM Corporation 2005. All Rights Reserved.
本資訊中心採用 Eclipse 技術。(http://www.eclipse.org)