static function encodeValue( $doc, $name, $value )
    {
        switch ( gettype( $value ) )
        {
            case "string" :
            {
                $node = $doc->createElement( $name, $value );
                $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                     ggSOAPRequest::XSD_PREFIX . ':string' );
                return $node;
            } break;

            case "boolean" :
            {
                $node = $doc->createElement( $name, $value ? 'true' : 'false' );
                $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                     ggSOAPRequest::XSD_PREFIX . ':boolean' );
                return $node;
            } break;

            case "integer" :
            {
                $node = $doc->createElement( $name, $value );
                $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                     ggSOAPRequest::XSD_PREFIX . ':int' );
                return $node;
            } break;

            case "double" :
            {
                $node = $doc->createElement( $name, $value );
                $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                     ggSOAPRequest::XSD_PREFIX . ':float' );
                return $node;
            } break;

            case "array" :
            {
                $arrayCount = count( $value );

                $isStruct = false;
                // Check for struct
                $i = 0;
                foreach( $value as $key => $val )
                {
                    if ( $i !== $key )
                    {
                        $isStruct = true;
                        break;
                    }
                    $i++;
                }

                if ( $isStruct == true )
                {
                    $node = $doc->createElement( $name );
                    $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                         ggSOAPRequest::ENC_PREFIX . ':SOAPStruct' );

                    foreach( $value as $key => $val )
                    {
                        $subNode = ggSOAPRequest::encodeValue( $doc, (string)$key, $val );
                        $node->appendChild( $subNode );
                    }
                    return $node;
                }
                else
                {
                    $node = $doc->createElement( $name );
                    $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type',
                                         ggSOAPRequest::ENC_PREFIX . ':Array' );
                    $node->setAttribute( ggSOAPRequest::ENC_PREFIX . ':arrayType',
                                         ggSOAPRequest::XSD_PREFIX . ":string[$arrayCount]" );

                    foreach ( $value as $arrayItem )
                    {
                        $subNode = ggSOAPRequest::encodeValue( $doc, "item", $arrayItem );
                        $node->appendChild( $subNode );
                    }

                    return  $node;
                }
            } break;
        }

        return false;
    }