Ejemplo n.º 1
0
 /**
  * processes SOAP message returned from server
  *
  * @param	array	$headers	The HTTP headers
  * @param	string	$data		unprocessed response data from server
  * @return	mixed	value of the message, decoded into a PHP type
  * @access   private
  */
 function parseResponse($headers, $data)
 {
     $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' and type ' . $headers['content-type']);
     if (!strstr($headers['content-type'], 'text/xml')) {
         $this->setError('Response not of type text/xml');
         return false;
     }
     if (strpos($headers['content-type'], '=')) {
         $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
         $this->debug('Got response encoding: ' . $enc);
         if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
             $this->xml_encoding = strtoupper($enc);
         } else {
             $this->xml_encoding = 'US-ASCII';
         }
     } else {
         // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
         $this->xml_encoding = 'ISO-8859-1';
     }
     $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating soap_parser');
     $parser = new soap_parser($data, $this->xml_encoding, $this->operation, $this->decode_utf8);
     // add parser debug data to our debug
     $this->appendDebug($parser->getDebug());
     // if parse errors
     if ($errstr = $parser->getError()) {
         $this->setError($errstr);
         // destroy the parser object
         unset($parser);
         return false;
     } else {
         // get SOAP headers
         $this->responseHeaders = $parser->getHeaders();
         // get decoded message
         $return = $parser->get_response();
         // add document for doclit support
         $this->document = $parser->document;
         // destroy the parser object
         unset($parser);
         // return decode message
         return $return;
     }
 }
Ejemplo n.º 2
0
 /**
  * processes SOAP message received from client
  *
  * @param	array	$headers	The HTTP headers
  * @param	string	$data		unprocessed request data from client
  * @return	mixed	value of the message, decoded into a PHP type
  * @access   private
  */
 function parseRequest($headers, $data)
 {
     $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $headers['content-type']);
     if (!strstr($headers['content-type'], 'text/xml')) {
         $this->setError('Request not of type text/xml');
         return false;
     }
     if (strpos($headers['content-type'], '=')) {
         $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
         $this->debug('Got response encoding: ' . $enc);
         if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
             $this->xml_encoding = strtoupper($enc);
         } else {
             $this->xml_encoding = 'US-ASCII';
         }
     } else {
         // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
         $this->xml_encoding = 'ISO-8859-1';
     }
     $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating soap_parser');
     // parse response, get soap parser obj
     $parser = new soap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
     // parser debug
     $this->debug("parser debug: \n" . $parser->getDebug());
     // if fault occurred during message parsing
     if ($err = $parser->getError()) {
         $this->result = 'fault: error in msg parsing: ' . $err;
         $this->fault('Client', "error in msg parsing:\n" . $err);
         // else successfully parsed request into soapval object
     } else {
         // get/set methodname
         $this->methodURI = $parser->root_struct_namespace;
         $this->methodname = $parser->root_struct_name;
         $this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
         $this->debug('calling parser->get_response()');
         $this->methodparams = $parser->get_response();
         // get SOAP headers
         $this->requestHeaders = $parser->getHeaders();
         // add document for doclit support
         $this->document = $parser->document;
     }
 }
Ejemplo n.º 3
0
 /**
  * parses a request
  *
  * The following fields are set by this function (when successful)
  *
  * headers
  * request
  * xml_encoding
  * SOAPAction
  * request
  * requestSOAP
  * methodURI
  * methodname
  * methodparams
  * requestHeaders
  * document
  *
  * This sets the fault field on error
  *
  * @param    string $data XML string
  * @access   private
  */
 function parse_request($data = '')
 {
     $this->debug('entering parse_request()');
     $this->parse_http_headers();
     $this->debug('got character encoding: ' . $this->xml_encoding);
     // uncompress if necessary
     if (isset($this->headers['Content-Encoding']) && $this->headers['Content-Encoding'] != '') {
         $this->debug('got content encoding: ' . $this->headers['Content-Encoding']);
         if ($this->headers['Content-Encoding'] == 'deflate' || $this->headers['Content-Encoding'] == 'gzip') {
             // if decoding works, use it. else assume data wasn't gzencoded
             if (function_exists('gzuncompress')) {
                 if ($this->headers['Content-Encoding'] == 'deflate' && ($degzdata = @gzuncompress($data))) {
                     $data = $degzdata;
                 } elseif ($this->headers['Content-Encoding'] == 'gzip' && ($degzdata = gzinflate(substr($data, 10)))) {
                     $data = $degzdata;
                 } else {
                     $this->fault('Client', 'Errors occurred when trying to decode the data');
                     return;
                 }
             } else {
                 $this->fault('Client', 'This Server does not support compressed data');
                 return;
             }
         }
     }
     $this->request .= "\r\n" . $data;
     $this->requestSOAP = $data;
     // parse response, get soap parser obj
     $parser = new soap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
     // parser debug
     $this->debug("parser debug: \n" . $parser->getDebug());
     // if fault occurred during message parsing
     if ($err = $parser->getError()) {
         $this->result = 'fault: error in msg parsing: ' . $err;
         $this->fault('Client', "error in msg parsing:\n" . $err);
         // else successfully parsed request into soapval object
     } else {
         // get/set methodname
         $this->methodURI = $parser->root_struct_namespace;
         $this->methodname = $parser->root_struct_name;
         $this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
         $this->debug('calling parser->get_response()');
         $this->methodparams = $parser->get_response();
         // get SOAP headers
         $this->requestHeaders = $parser->getHeaders();
         // add document for doclit support
         $this->document = $parser->document;
     }
     $this->debug('leaving parse_request');
 }