The prototype method requires an input array to be created. This array must be created and managed properly.
If an array is to be used as an input parameter, then it has to be created and filled.
The following example shows the typical usage of a nillable simple array type required by a generated stub. The array is an example of the input array to the method. The example assumes that the array contains three elements whose values are 0, 1 and 2 respectively.
// Need an input array of 3 elements. int iArraySize = 3; // Final object type to be passed as an input parameter to the web service. xsd__int_Array iInputArray; // Preparatory array that contains the values to be passed. Note that the // array is an array of pointers of the required type. xsd__int ** ppiPrepArray = new xsd__int*[iArraySize]; // Loop used to populate the preparatory array. for( int iCount = 0 ; iCount < iArraySize ; iCount++) { // Each element in the array of type pointers is filled with a pointer to an // object of the required type. In this example we have chosen the value of // each element to be the same as the current count and so have passed this // value to the new instance of the pointer. ppiPrepArray[iCount] = new xsd__int( iCount); } // Set the contents of the final object to contain the elements of the // preparatory array. iInputArray.set( ppiPrepArray, iArraySize); … Call the web service(s) that use the input array … // No longer require iInputArray. Delete the preparatory array held within. for( int iCount = 0 ; iCount < iArraySize ; iCount++) { // Delete each pointer in the pointer array. delete ppiPrepArray[iCount]; ppiPrepArray[iCount] = NULL; } // Delete the array of pointers and then set the value to NULL so that it // cannot be reused. delete [] ppiPrepArray; ppiPrepArray = NULL;
When the method returns, iInputType can be destroyed. If iInputType was created as a pointer (piInputType), then the client user code must remember to delete it otherwise the code will have created a memory leak.