示例#1
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) . ' headers:');
     $this->appendDebug($this->varDump($headers));
     if (!isset($headers['content-type'])) {
         $this->setError('Request not of type text/xml (no content-type header)');
         return false;
     }
     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 (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $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 NusoapParser');
     // parse response, get soap parser obj
     $parser = new NusoapParser($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('SOAP-ENV: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_soapbody()');
         $this->methodparams = $parser->get_soapbody();
         // get SOAP headers
         $this->requestHeaders = $parser->getHeaders();
         // get SOAP Header
         $this->requestHeader = $parser->get_soapheader();
         // add document for doclit support
         $this->document = $parser->document;
     }
 }