WebSphere Web Services Client for C++, Version 1.0.1 Operating Systems: Linux, Solaris

Complex types and arrays of complex type

When complex types are used in a web service, the same rules as for simple types apply.

Complex types

The following example shows classes produced from WSDL with a complex type. As shown in this example, complex types only take shallow copies of the data when using the set and get methods.

class STORAGE_CLASS_INFO ComplexType
{
public:
	class xsd__string	Message;
	class xsd__int	MessageSize;

	xsd__string	getMessage();
	void		setMessage( xsd__string InValue);
	xsd__int	getMessageSize();
	void		setMessageSize( xsd__int InValue);

The client has to remember that when using pointers to objects, only the pointer is copied and it is not cloned. For example, if a complex type contains a string, the client can set the contents of the string by creating a local string and then using the set method on the complex object to copy that string into the object.

The following example shows restrictions that can be applied when using a complex type:

xsd__int	iStringLength = strlen( “Hello World”);
xsd_string	myNewString = new char[iStringLength + 1];

strcpy( myNewString, “Hello World”);

myComplexType.setMessage( myNewString);

delete myNewString; // Do this and myComplexType.Message will be left pointing to 
// invalid memory.

Alternatively:

delete myComplexType; // Do this and myNewMessage will be pointing to invalid 
memory.

The same rules as for simple types apply to the parameters of a complex type when used on a method call. These rules are as follows:

Arrays of complex type

If a WSDL describes a complex type being used within an array, the WSDL2Ws tool generates a corresponding array object using the complex name type suffixed with "_Array".


Reference topic

Terms of Use | Rate this page

Timestamp iconLast updated: 12 Dec 2005
(C) Copyright IBM Corporation 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)