WebSphere Web Services Client for C++, Version 1.0.1 オペレーティング・システム: Linux, Windows

出力パラメーターとしての配列型

プロトタイプ・メソッドでは、出力配列を作成する必要があります。この配列は、適切に作成し管理する必要があります。

入力パラメーターとしての配列型の例から続いて登場する次の例では、Web サービスの simpleArray メソッドを呼び出し、戻される配列を使用するクライアント・アプリケーションを示しています。この例では、WSDL の nillable の単純型の配列の例で生成されるメソッドの一般的な使用法を示しています。応答の integer 配列は直接にはアクセスできません。 組み込み integer 配列を取得するには、以下のように、ユーザーが piSimpleResponseArray オブジェクトで get メソッドを呼び出す必要があります。

xsd__int_Array * piSimpleResponseArray = ws.simpleArray( &iInputArray);
int iSize = 0; // Size of the array.
// Pointer to a pointer that will contain the array. Get the contents
// of the response. The return value will be a pointer to a pointer containing
// the array and iSize will contain the number of elements in the array.
// Note that it is a const pointer so cannot be manipulated.
const xsd__int ** ppiIntArray = piSimpleResponseArray->get( (int&) iSize);
// Check if the array size greater than zero before processing it!
if( iSize > 0)
{
// For each element of the array...
for( int iCount = 0 ; iCount < iSize ; iCount++)
{
// Check that that element is not null before use...
if( ppiIntArray[iCount] != NULL)
{
cout <<“Element[” << iCount << “]=“ << *ppiIntArray[iCount] <<endl;
}
}
}
// Later in the code...
delete piSimpleResponseArray;
piSimpleResponseArray = NULL;
注:
  1. 戻されるポインターは NULL ではありません。
  2. ユーザーは、Web サービスの呼び出しによって戻されたオブジェクトの削除のみを行う必要があります。このオブジェクトから抽出されたオブジェクトを、クライアントが削除してはなりません。例えば、前のコード・サンプルでは、ppiIntArray は、親オブジェクト (piSimpleArrayResponse) の削除時にこの親オブジェクトによって削除されるため、ユーザーが削除することはできません。
  3. 整数値を指すポインターの配列へのポインター (ppiIntArray) が NULL の場合、これは空の配列を示しています。この場合は、iSize はゼロに等しくなります。

Reference topic

ご利用条件 | フィードバック (英語のみ)

Timestamp icon最終更新: 12 Jun 2006
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
このインフォメーション・センターでは Eclipse テクノロジーが採用されています。(http://www.eclipse.org)