복합 유형을 웹 서버에 사용하면 단순 유형과 동일한 규칙이 적용됩니다.
다음 예제는 복합 유형의 WSDL에서 생성된 클래스를 보여 줍니다. 이 예제에서 설명한 대로 복합 유형만 set 및 get 메소드를 사용할 때 데이터의 샐로우(shallow)를 복사합니다.
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);
클라이언트는 오브젝트에 대한 포인터를 사용할 때 해당 포인터만 복사되고 복제되지는 않는다는 사실을 명심해야 합니다. 예를 들어, 복합 유형에 문자열이 포함될 경우 클라이언트는 로컬 문자열을 작성한 다음 복합 오브젝트에서 set 메소드를 사용하여 해당 문자열을 오브젝트에 복사할 수 있습니다.
다음 예제는 복합 유형을 사용할 때 적용될 수 있는 제한사항을 보여 줍니다.
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.
다른 방법:
delete myComplexType; // Do this and myNewMessage will be pointing to invalid memory.
메소드 호출에 사용될 경우 단순 유형과 같은 규칙이 복합 유형의 매개변수에 적용됩니다. 이러한 규칙은 다음과 같습니다.
ComplexType * myNewComplexType = new ComplexType( myExistingComplexType);
이 명령은 원래 오브젝트의 모든 구성원 변수를 복사하여 새 오브젝트를 채웁니다.
WSDL이 배열 내에서 사용되는 복합 유형을 설명할 경우 WSDL2Ws 도구가 접미부가 "_Array"인 복합 이름을 사용하여 해당 배열 오브젝트를 생성합니다.