Example #1
0
 function parseRequest($data = '', $attachments = null)
 {
     /* Parse response, get SOAP_Parser object. */
     $parser = new SOAP_Parser($data, $this->xml_encoding, $attachments);
     if ($parser->fault) {
         /* Fault occurred during message parsing. */
         $this->fault = $parser->fault;
         return null;
     }
     if (!count($parser->root_struct_name)) {
         /* No method specified. */
         $this->_raiseSoapFault('No method specified in request.');
         return null;
     }
     /* Handle message headers. */
     $request_headers = $parser->getHeaders();
     $header_results = array();
     if ($request_headers) {
         if (!is_a($request_headers, 'SOAP_Value')) {
             $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_headers, '', '', 'Server');
             return null;
         }
         if ($request_headers->value) {
             /* Handle headers now. */
             foreach ($request_headers->value as $header_val) {
                 $f_exists = $this->validateMethod($header_val->name, $header_val->namespace);
                 /* TODO: this does not take into account message routing
                  * yet. */
                 $myactor = !$header_val->actor || $header_val->actor == 'http://schemas.xmlsoap.org/soap/actor/next' || $header_val->actor == $this->endpoint;
                 if (!$f_exists && $header_val->mustunderstand && $myactor) {
                     $this->_raiseSoapFault('I don\'t understand header ' . $header_val->name, '', '', 'MustUnderstand');
                     return null;
                 }
                 /* We only handle the header if it's for us. */
                 $isok = $f_exists && $myactor;
                 if ($isok) {
                     /* Call our header now! */
                     $header_method = $header_val->name;
                     $header_data = array($this->_decode($header_val));
                     /* If there are parameters to pass. */
                     $hr =& $this->callMethod($header_method, $header_data);
                     if (PEAR::isError($hr)) {
                         $this->_raiseSoapFault($hr);
                         return null;
                     }
                     $results = $this->buildResult($hr, $this->return_type, $header_method, $header_val->namespace);
                     $header_results[] = $results[0];
                 }
             }
         }
     }
     /* Handle the method call. */
     /* Evaluate message, getting back a SOAP_Value object. */
     $this->call_methodname = $this->methodname = $parser->root_struct_name[0];
     /* Figure out the method namespace. */
     $this->method_namespace = $parser->message[$parser->root_struct[0]]['namespace'];
     if ($this->_wsdl) {
         $this->_setSchemaVersion($this->_wsdl->xsd);
         $dataHandler = $this->_wsdl->getDataHandler($this->methodname, $this->method_namespace);
         if ($dataHandler) {
             $this->call_methodname = $this->methodname = $dataHandler;
         }
         $this->_portName = $this->_wsdl->getPortName($this->methodname);
         if (PEAR::isError($this->_portName)) {
             $this->_raiseSoapFault($this->_portName);
             return null;
         }
         $opData = $this->_wsdl->getOperationData($this->_portName, $this->methodname);
         if (PEAR::isError($opData)) {
             $this->_raiseSoapFault($opData);
             return null;
         }
         $this->_options['style'] = $opData['style'];
         $this->_options['use'] = $opData['output']['use'];
         $this->_options['parameters'] = $opData['parameters'];
     }
     /* Does method exist? */
     if (!$this->methodname || !$this->validateMethod($this->methodname, $this->method_namespace)) {
         $this->_raiseSoapFault('method "' . $this->method_namespace . $this->methodname . '" not defined in service', '', '', 'Server');
         return null;
     }
     if (!($request_val = $parser->getResponse())) {
         return null;
     }
     if (!is_a($request_val, 'SOAP_Value')) {
         $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_val, '', '', 'Server');
         return null;
     }
     /* Verify that SOAP_Value objects in request match the methods
      * signature. */
     if (!$this->verifyMethod($request_val)) {
         /* verifyMethod() creates the fault. */
         return null;
     }
     /* Need to set special error detection inside the value class to
      * differentiate between no params passed, and an error decoding. */
     $request_data = $this->__decodeRequest($request_val);
     if (PEAR::isError($request_data)) {
         $this->_raiseSoapFault($request_data);
         return null;
     }
     $method_response =& $this->callMethod($this->call_methodname, $request_data);
     if (PEAR::isError($method_response)) {
         $this->_raiseSoapFault($method_response);
         return null;
     }
     if ($this->_options['parameters'] || !$method_response || $this->_options['style'] == 'rpc') {
         /* Get the method result. */
         if (is_null($method_response)) {
             $return_val = null;
         } else {
             $return_val = $this->buildResult($method_response, $this->return_type);
         }
         $qn = new QName($this->methodname . 'Response', $this->method_namespace);
         $methodValue = new SOAP_Value($qn->fqn(), 'Struct', $return_val);
     } else {
         $methodValue =& $method_response;
     }
     return $this->makeEnvelope($methodValue, $header_results, $this->response_encoding);
 }
Example #2
0
 function &__parse(&$response, $encoding, &$attachments)
 {
     // parse the response
     $response = new SOAP_Parser($response, $encoding, $attachments);
     if ($response->fault) {
         return $this->_raiseSoapFault($response->fault);
     }
     // return array of parameters
     $return =& $response->getResponse();
     $headers =& $response->getHeaders();
     if ($headers) {
         $this->headersIn =& $this->__decodeResponse($headers, false);
     }
     return $this->__decodeResponse($return);
 }
 /**
  * Parses a SOAP response.
  *
  * @see SOAP_Parser::
  *
  * @param string $response    XML content of SOAP response.
  * @param string $encoding    Character set encoding, defaults to 'UTF-8'.
  * @param array $attachments  List of attachments.
  */
 function parseResponse($response, $encoding, $attachments)
 {
     // Parse the response.
     $response = new SOAP_Parser($response, $encoding, $attachments);
     if ($response->fault) {
         $fault = $this->_raiseSoapFault($response->fault);
         return $fault;
     }
     // Return array of parameters.
     $return = $response->getResponse();
     $headers = $response->getHeaders();
     if ($headers) {
         $this->headersIn = $this->_decodeResponse($headers, false);
     }
     $decoded = $this->_decodeResponse($return);
     return $decoded;
 }