public function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/')
    {
        // TODO: add an option to automatically run utf8_encode on $body and $headers
        // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
        // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1

        $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
        $this->debug("headers:");
        $this->appendDebug($this->varDump($headers));
        $this->debug("namespaces:");
        $this->appendDebug($this->varDump($namespaces));

        // serialize namespaces
        $ns_string = '';
        foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
            $ns_string .= " xmlns:$k=\"$v\"";
        }
        if ($encodingStyle) {
            $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
        }

        // serialize headers
        if ($headers) {
            if (is_array($headers)) {
                $xml = '';
                foreach ($headers as $k => $v) {
                    if (is_object($v) && get_class($v) == 'soapval') {
                        $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
                    } else {
                        $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
                    }
                }
                $headers = $xml;
                $this->debug("In serializeEnvelope, serialized array of headers to $headers");
            }
            $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
        }
        // serialize envelope
        return
            '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
            '<SOAP-ENV:Envelope' . $ns_string . ">" .
            $headers .
            "<SOAP-ENV:Body>" .
            $body .
            "</SOAP-ENV:Body>" .
            "</SOAP-ENV:Envelope>";
    }
public function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/')
    {
        // TODO: add an option to automatically run utf8_encode on $body and $headers
        // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
        // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1

        $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
        $this->debug("headers:");
        $this->appendDebug($this->varDump($headers));
        $this->debug("namespaces:");
        $this->appendDebug($this->varDump($namespaces));

        // serialize namespaces
        $ns_string = '';
        foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
            $ns_string .= " xmlns:$k=\"$v\"";
        }
        if ($encodingStyle) {
            $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
        }

        // serialize headers
        if ($headers) {
            if (is_array($headers)) {
                $xml = '';
                foreach ($headers as $k => $v) {
                    if (is_object($v) && get_class($v) == 'soapval') {
                        $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
                    } else {
                        $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
                    }
                }
                $headers = $xml;
                $this->debug("In serializeEnvelope, serialized array of headers to $headers");
            }
            $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
        }
        // serialize envelope
        return
            '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
            '<SOAP-ENV:Envelope' . $ns_string . ">" .
            $headers .
            "<SOAP-ENV:Body>" .
            $body .
            "</SOAP-ENV:Body>" .
            "</SOAP-ENV:Envelope>";
    }
public function serializeEnvelope ( $ body , $ headers = false , $ namespaces = array ( ) , $ style = 'rpc' , $ use = 'encoded' , $ encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/' ) { // TODO: add an option to automatically run utf8_encode on $body and $headers // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 $ this -> debug ( "In serializeEnvelope length=" . strlen ( $ body ) . " body (max 1000 characters)=" . substr ( $ body , 0 , 1000 ) . " style=$style use=$use encodingStyle=$encodingStyle" ) ; $ this -> debug ( "headers:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ headers ) ) ; $ this -> debug ( "namespaces:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ namespaces ) ) ; // serialize namespaces $ ns_string = '' ; foreach ( array_merge ( $ this -> namespaces , $ namespaces ) as $ k => $ v ) { $ ns_string .= " xmlns:$k=\"$v\"" ; } if ( $ encodingStyle ) { $ ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string" ; } // serialize headers if ( $ headers ) { if ( is_array ( $ headers ) ) { $ xml = '' ; foreach ( $ headers as $ k => $ v ) { if ( is_object ( $ v ) && get_class ( $ v ) == 'soapval' ) { $ xml .= $ this -> serialize_val ( $ v , false , false , false , false , false , $ use ) ; } else { $ xml .= $ this -> serialize_val ( $ v , $ k , false , false , false , false , $ use ) ; } } $ headers = $ xml ; $ this -> debug ( "In serializeEnvelope, serialized array of headers to $headers" ) ; } $ headers = "<SOAP-ENV:Header>" . $ headers . "</SOAP-ENV:Header>" ; } // serialize envelope return '<?xml version="1.0" encoding="' . $ this -> soap_defencoding . '"?' . ">" . '<SOAP-ENV:Envelope' . $ ns_string . ">" . $ headers . "<SOAP-ENV:Body>" . $ body . "</SOAP-ENV:Body>" . "</SOAP-ENV:Envelope>" ; }
serializes a message

@param string $body the XML of the SOAP body
@param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
@param array $namespaces optional the namespaces used in generating the body and headers
@param string $style optional (rpc|document)
@param string $use optional (encoded|literal)
@param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
@return string the message
@access public
serializes a message