public function requestDebug() { echo "Last Request:\n\n"; echo $this->client->__getLastRequestHeaders() . "\n\n"; echo self::tidyit($this->client->__getLastRequest()) . "\n\n"; echo $this->client->__getLastResponseHeaders() . "\n\n"; echo self::tidyit($this->client->__getLastResponse()) . "\n"; }
public static function GetRegZavod() { $debug = false; $wsdl_url = dirname(__FILE__) . '/RegZavodServicePort.wsdl'; if (!file_exists($wsdl_url)) { echo 'Missing WSDL shema for RegZavodServicePort.wsdl', "\n"; echo 'WSDL PATH: ', $wsdl_url, "\n"; die; } $client = new SoapClient($wsdl_url, array('exceptions' => 0, 'trace' => 1, 'user_agent' => 'Bober')); $result = $client->__soapCall('getRegZavod', array()); if ($debug) { var_dump($client->__getFunctions()); echo 'REQUEST HEADERS:', "\n", $client->__getLastRequestHeaders(), "\n"; echo 'REQUEST:', "\n", $client->__getLastRequest(), "\n"; var_dump($result); if (is_soap_fault($result)) { trigger_error('SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})', E_USER_ERROR); } print_r($result); } if ($result != '' && !is_soap_fault($result)) { $result = json_decode(json_encode($result), true); return $result; } else { return array(); } }
/** * Retrieve request headers * * @return string */ public function getLastRequestHeaders() { if ($this->_soapClient !== null) { return $this->_soapClient->__getLastRequestHeaders(); } return ''; }
/** * Dump Client response and request messages * * @param SoapClient $client Client instance * * @return void */ private function dumpSoapMessages($client) { echo '<br />$client->__getLastRequest():<br />'; var_dump($client->__getLastRequest()); echo '<br />$client->__getLastRequestHeaders():<br />'; var_dump($client->__getLastRequestHeaders()); echo '<br />$client->__getLastResponse():<br />'; var_dump($client->__getLastResponse()); echo '<br />$client->__getLastResponseHeaders():<br />'; var_dump($client->__getLastResponseHeaders()); }
/** * @param array $data * @param bool|false $returnXml * * @return \stdClass|array|string * * @throws WebGateException */ public function send($data, $returnXml = false) { try { $options = ['trace' => true, 'exceptions' => true, 'connection_timeout' => $this->connectionTimeout]; if (!empty($this->login)) { $options['login'] = $this->login; $options['password'] = $this->password; } if (0) { $options['location'] = ''; $options['uri'] = ''; $wsdl = null; } else { $wsdl = $this->wsdlPath; } $client = new \SoapClient($wsdl, $options); ini_set("default_socket_timeout", $this->connectionTimeout); $response = $client->__soapCall($this->methodName, array('params' => $data)); $this->logger->addDebug('Response XML: ' . PHP_EOL . $client->__getLastResponse()); $this->logger->addDebug('Response JSON: ' . PHP_EOL . json_encode($response)); return $returnXml ? $client->__getLastResponse() : $response; } catch (\SoapFault $e) { if (isset($client)) { $this->logger->addDebug(PHP_EOL . __METHOD__ . ':'); $this->logger->addDebug('Request Headers: ' . $client->__getLastRequestHeaders()); $this->logger->addDebug('Request: ' . $client->__getLastRequest()); $this->logger->addDebug('Response Headers: ' . $client->__getLastResponseHeaders()); $this->logger->addDebug('Response: ' . PHP_EOL . $client->__getLastResponse()); } if ($e->getCode()) { $code = $e->getCode(); } else { $code = isset($e->faultcode) && is_numeric($e->faultcode) ? $e->faultcode : 500; } $this->logger->addCritical(PHP_EOL . __METHOD__ . sprintf('[%s/%s] %s', $e->getCode(), $code, $e->getMessage())); throw new WebGateException($e->getMessage(), $code, $e); } }
/** * Invoke method call * * @param string method name * @param var vars * @return var answer * @throws webservices.soap.SOAPFaultException */ public function invoke() { $args = func_get_args(); $method = array_shift($args); $options = ['encoding' => $this->getEncoding(), 'exceptions' => 0, 'trace' => $this->cat != null, 'user_agent' => 'XP-Framework/' . get_class($this)]; if (null !== $this->ctimeout) { $options['connection_timeout'] = $this->ctimeout; } if (null !== $this->timeout) { // NOOP } if (null !== $this->endpoint->getUser()) { $options['login'] = $this->endpoint->getUser(); } if (null !== $this->endpoint->getPassword()) { $options['password'] = $this->endpoint->getPassword(); } if (sizeof($this->map)) { $options['classmap'] = $this->map; } $this->version && ($options['soap_version'] = $this->version); $this->location && ($options['location'] = $this->location); if ($this->wsdl) { $client = new \SoapClient($this->endpoint->getURL(), $options); } else { // Do not overwrite location if already set from outside isset($options['location']) || ($options['location'] = $this->endpoint->getURL()); // Assert we have a uri if (!$this->uri) { throw new \lang\IllegalArgumentException('SOAP uri required in non-wsdl mode.'); } $options['uri'] = $this->uri; $options['style'] = $this->getStyle(); $options['use'] = $this->getSoapEncoding(); $client = new \SoapClient(null, $options); } // Take care of wrapping XP SOAP types into respective ext/soap value objects $result = $client->__soapCall($method, $this->checkParams($args)); $this->cat && $this->cat->debug('>>>', $client->__getLastRequestHeaders(), $client->__getLastRequest()); $this->cat && $this->cat->debug('<<<', $client->__getLastResponseHeaders(), $client->__getLastResponse()); if (is_soap_fault($result)) { throw new SOAPFaultException(new CommonSoapFault($result->faultcode, $result->faultstring)); } return $result; }
// This method allows us to capture the original SoapClient // instance for debugging. (we will check the last request // made by SoapClient any time we see an exception!) $soapClient = new SoapClient(SoapAsendiaWebApiClient::TESTING_WSDL, ['trace' => 1]); $wsdlClient = new AsendiaWsdlClientImpl($soapClient); $asendia = new SoapAsendiaWebApiClient($wsdlClient, $login, $password); try { printf("Creating a shipment.\n"); $createdShipment = $asendia->createShipment(); printf(" * shipment number: %s\n", $createdShipment->getShipment()); printf(" * status: %s\n", $createdShipment->getStatus()); printf("\n"); } catch (Error $e) { printf(" * ERROR: %s\n\n", $e->getMessage()); if ($soapClient) { print_r($soapClient->__getLastRequestHeaders()); print_r($soapClient->__getLastRequest()); } throw $e; } try { printf("Adding packages to a shipment.\n"); $manifest = get_manifest_from_facade($randomize = true); $addedShipmentPackages = $asendia->addPackagesToShipment($createdShipment->getShipment(), $manifest, $labelType); printf(" * shipment number: %s\n", $addedShipmentPackages->getShipment()); foreach ($addedShipmentPackages->getPackages() as $package) { printf(" * Added package\n"); printf(" * PckId: %s\n", $package->getPckId()); printf(" * LabelFile: %s\n", $package->getLabelFile()); printf("\n"); }
/*$headers = array(); $headers[] = new SoapHeader('http://www.topcall.com/2005/solution.wsdl', 'SendSimpleMessage', array('Service'=>'', 'Number' => '1234', 'Subject'=>'', 'Text' => '121212')); */ try { $result = $client->SendSimpleMessage(array('Service'=>"test string",'Number'=> "1234",'Subject'=>"234234",'Text'=>"dfgdfgdfg")); //$result = $client->__soapCall("SendSimpleMessage", array('bbb', '12345','aaa' ,'tresctresce')); echo "Response:\n" . $client->__getLastRequest() . "\n"; echo "Response:\n" . $client->__getLastRequestHeaders() . "\n"; echo "Response:\n" . $client->__getLastResponseHeaders() . "\n"; echo "Response:\n" . $client->__getLastResponse(); print_r($result); } catch (SoapFault $soapFault) { var_dump($soapFault); echo "Response:\n" . $client->__getLastRequest() . "\n"; echo "Response:\n" . $client->__getLastRequestHeaders() . "\n"; echo "Response:\n" . $client->__getLastResponseHeaders() . "\n"; var_dump($client->__getFunctions());
/** * returns last request headers * * @return string */ public function getLastRequestHeaders() { return $this->soapClient->__getLastRequestHeaders(); }
$response = array(); //$response['helloResponse'] = $client->getHello(); $response['goodbyeResponse'] = $client->getGoodbye(); //print_r($response); } catch (SoapFault $fault) { echo "<pre style='margin:2em;color:red'>"; print_r($fault); //echo 'Soap Error - faultcode: '.$fault->faultcode.' faultstring: '.$fault->faultstring; echo "</pre>"; } echo '<hr>'; echo "<pre style='margin:2em;color:black;'>"; echo 'Reponse <br>'; var_dump($response); echo '</pre>'; echo '<hr>'; echo "<pre style='margin:2em;font-family:\"Courier New\",Courier,monospace;line-height:1em'>"; echo 'Soap Client trace' . "\n"; echo "REQUEST:" . $client->__getLastRequest() . "\n"; echo "RESPONSE:" . $client->__getLastResponse() . "\n"; echo "REQUEST HEADERS:" . $client->__getLastRequestHeaders(); echo "RESPONSE HEADERS:" . $client->__getLastResponseHeaders(); echo 'Debug Report <br>'; echo '</pre>'; //Notice: Array to string conversion in F:\bit5411\apps\gjsoap\htdocs\includes\gj_utility.inc.php on line 341 //fix above generateDebugReport('browser', get_defined_vars()); ?>
/** * @link http://php.net/manual/en/soapclient.getlastrequestheaders.php * * @return string */ public function __getLastRequestHeaders() { return parent::__getLastRequestHeaders(); }
//body foreach ($children as $child) { //GetTaxiInfosResponse foreach ($child->children() as $x) { //taxi info echo $x->TaxiInfo->LicenseNum; echo $x->TaxiInfo->LicenseDate; } } } var_dump($response_head); echo '<pre/>'; echo '<h2>Request</h2>'; echo '<pre>'; $request = $client->__getLastRequest(); $request_head = $client->__getLastRequestHeaders(); $xml = simplexml_load_string($request); //echo $xml->asXML(); //$children = $xml->children('http://dtis.mos.ru/taxi'); echo htmlentities($request); var_dump($request); var_dump($request_head); echo '<pre/>'; echo '<pre>'; var_dump($result); echo '<pre/>'; } catch (SoapFault $fault) { trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); } function parseXmlResponse($response) {
/** * @return array */ public function getLastRequest() { return array('request' => array('header' => $this->soapClient->__getLastRequestHeaders(), 'body' => $this->soapClient->__getLastRequest()), 'response' => array('header' => $this->soapClient->__getLastResponseHeaders(), 'body' => $this->soapClient->__getLastResponse())); }
<?php ini_set('soap.wsdl_cache_enabled', '0'); require_once 'config.php'; $client = new SoapClient("http://process.localhost/process.wsdl.php"); //, array('trace' => 1)); try { $uri = 'http://localhost/sample.3gp'; $callback = 'http://localhost/process_callback.php?ref=123'; //will tell client app that file "123" finished processing $watermark_uri = 'http://localhost/watermark.png'; $result = $client->fetchAndConvert('username', 'password', $uri, $callback, $watermark_uri); if (!$result) { echo 'Failed to add order!'; } else { echo 'Order added successfully. Order ID is ' . $result; } } catch (Exception $e) { echo 'Exception: ' . $e . '<br/><br/>'; echo 'Request header: ' . htmlspecialchars($client->__getLastRequestHeaders()) . '<br/>'; echo 'Request: ' . htmlspecialchars($client->__getLastRequest()) . '<br/>'; echo 'Response: ' . htmlspecialchars($client->__getLastResponse()) . '<br/>'; }
<?php $client = new SoapClient("http://sparesprit.de/sprit.wsdl", array('location' => "http://sparesprit.de/server.php", 'uri' => "http://localhost", 'trace' => 1)); try { $result = $client->__soapCall("getCoordsByTown", array("town" => "Leipzig")); //echo $result; echo gettype($result); } catch (Exception $e) { echo 'Exception abgefangen: ', $e->getMessage(), "\n"; } echo "\nReturning value of __soapCall() call: " . $return; echo "\nDumping request headers:\n" . $client->__getLastRequestHeaders(); echo "\nDumping request:\n" . $client->__getLastRequest(); echo "\nDumping response headers:\n" . $client->__getLastResponseHeaders(); echo "\nDumping response:\n" . $client->__getLastResponse();
echo json_encode(array("error" => $e->getMessage())); echo $e->getMessage(); $logger->log($client->__getLastRequestHeaders()); $logger->log($client->__getLastRequest()); $logger->log($client->__getLastResponse()); } }); /** * Funcion que regresa una lista de URLs de productos para un usuario determinado. */ $app->get('/library_service/get_download_urls/{product_id}/{user_id}', function ($product_id, $user_id) use($app, $logger) { $options = array('trace' => 1, 'location' => LIBRARY_SERVICE_ENPOINT, 'stream_context' => stream_context_create(array('http' => array('header' => "Partner: " . PARTNER . "\r\n" . "APIKey: " . APIKEY . "")))); $client = new SoapClient(LIBRARY_SERVICE, $options); try { $response = $client->GetDownloadUrls(array('request' => array("ProductId" => $product_id, "UserId" => $user_id))); $json = json_encode($response->GetDownloadUrlsResult); //set content type $app->response->setContentType('application/json', 'UTF-8'); //echo response echo $json; $logger->log($client->__getLastRequest()); $logger->log($client->__getLastResponse()); } catch (SoapFault $e) { $app->response->setStatusCode(401, "Bad Request")->send(); echo json_encode(array("error" => $e->getMessage())); echo $e->getMessage(); $logger->log($client->__getLastRequestHeaders()); $logger->log($client->__getLastRequest()); $logger->log($client->__getLastResponse()); } });
$ret = $client->GetOfflineOrderSummary($ret); //$ret= $client->newOrder($soapstuff); // $ret = $client->ProfileAdd($po); echo "<pre>"; print_r($ret); echo "</pre>"; } catch (SoapFault $sf) { //Log SOAP fault from connection echo "__getLastRequest"; echo "<pre>"; echo print_r($client->__getLastRequest, true); echo "</pre>"; echo "__getLastRequestHeaders"; echo "<pre>"; echo print_r($client->__getLastRequestHeaders(), true); echo "</pre>"; echo "__getLastResponse"; echo "<pre>"; echo print_r($client->__getLastResponse(), true); echo "</pre>"; echo("-----soapfault-------------<br>\n"); echo "<pre>"; echo print_r($sf, true); echo "</pre>"; } class getOfflineOrderSummary { public $CustomerNumber;
/** * @test */ public function cookie() { $obj = new CurlSoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true)); $original_obj = new \SoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true)); $this->assertEquals(array(), $obj->__getCookies()); $this->assertEquals(array(), $original_obj->__getCookies()); $obj->__setCookie('CookieTest', 'HelloWorld'); $obj->__setCookie('CookieTest2', 'HelloWorld2'); $original_obj->__setCookie('CookieTest', 'HelloWorld'); $original_obj->__setCookie('CookieTest2', 'HelloWorld2'); $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $obj->__getCookies()); $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $original_obj->__getCookies()); $this->assertEquals(array(1, 'a', false), $obj->test(array(1, 'a', false))); $this->assertEquals(array(1, 'a', false), $original_obj->test(array(1, 'a', false))); // difference of CurlSoapClient from SoapClient [";" -> "; "] $this->assertTrue(stripos($obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld; CookieTest2=HelloWorld2') !== false); $this->assertTrue(stripos($original_obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld;CookieTest2=HelloWorld2') !== false); }
/** sends a SOAP request to a FedEx server. see what happens */ function send_fedex_query($request) { if ($this->debug) { $log = "\n\n==\n" . get_class($this) . "::send_fedex_query()\n" . date('r'); $log .= "\nIP: " . $_SERVER['REMOTE_ADDR']; error_log($log, 3, $this->debug_log); } $wsdl = dirname(__FILE__) . '/' . $this->_path_to_wsdl; if ($this->test_mode) { // testing version wsql hacked in, has a one-line difference $wsdl = preg_replace('/\\.wsdl$/', '-testing.wsdl', $wsdl); } $client = new SoapClient($wsdl, array('trace' => $this->debug)); // http://us3.php.net/manual/en/ref.soap.php $quotes = array(); try { $response = $client->getRates($request); } catch (SoapFault $e) { if ($this->debug) { $log = "\n\n==== EXCEPTION CAUGHT : SoapFault Exception ====\n"; $log .= "====REQUEST====: \n" . $client->__getLastRequestHeaders() . "\n"; $log .= $client->__getLastRequest() . "\n\n"; $log .= "====RESPONSE===: \n" . $client->__getLastResponseHeaders() . "\n"; $log .= $client->__getLastResponse() . "\n\n"; error_log($log, 3, $this->debug_log); } return $this->raiseError($e->getMessage()); } if ($this->debug) { $log = "\n====REQUEST==== \n" . $client->__getLastRequest() . "\n\n"; error_log($log, 3, $this->debug_log); error_log("\nHighestSeverity: {$response->HighestSeverity}\n", 3, $this->debug_log); $log = "====RESPONSE===: \n" . serialize($response) . "\n\n"; error_log($log, 3, $this->debug_log); } if ($response->HighestSeverity == 'SUCCESS') { foreach ($response->RateReplyDetails as $rateReply) { if (!is_object($rateReply) || !isset($rateReply->ServiceType)) { continue; } $service = $rateReply->ServiceType; foreach ($rateReply->RatedShipmentDetails as $detail) { $last_rate = null; if (isset($detail->ShipmentRateDetail)) { $rate = $detail->ShipmentRateDetail->TotalNetFedExCharge->Amount; /* fedex returns multiple rate detail objects for each method, but they are always identical (maybe) */ if (!empty($last_rate) and $rate != $last_rate) { $msg = "got different rates for the same shipping method {$service}"; trigger_error($msg, E_USER_WARNING); if ($this->debug) { error_log("{$msg}\n", 3, $this->debug_log); } } $last_rate = $rate; } } $quotes[$service] = $rate; } if (empty($quotes)) { $err = "No ship methods are available for this destination at this time. Please try again."; if ($this->debug) { error_log("ERROR: {$err}\n", 3, $this->debug_log); } return $this->raiseError($err); } return $quotes; } else { if (is_object($response->Notifications)) { if ($response->Notifications->Code == 556) { $err = "The Address or Postal/ZIP code was not valid."; } else { $err = $response->Notifications->Severity . ': ' . $response->Notifications->Message . ' '; } } elseif (is_array($response->Notifications)) { foreach ($response->Notifications as $notification) { $err .= $notification->Message . ' '; } } if ($this->debug) { error_log("Notification: {$err}\n", 3, $this->debug_log); } return $this->raiseError($err); } }
/** * Execute queryMore() API call. * * @return result object * * @throws ZuoraFault */ public function queryMore($zoql) { $query = array("queryLocator" => $zoql); $queryWrapper = array("queryMore" => $query); try { $result = $this->_client->__soapCall("queryMore", $queryWrapper, null, $this->_header); } catch (SoapFault $e) { throw new ZuoraFault('ERROR in ' . __METHOD__, $e, $this->_client->__getLastRequestHeaders(), $this->_client->__getLastRequest(), $this->_client->__getLastResponseHeaders(), $this->_client->__getLastResponse()); } return $result; }
/** * Submits an API request through the iATS SOAP API Toolkit. * * @param $request * The request object or array containing the parameters of the requested services. * * @return * The response object from the API with properties pertinent to the requested * services. */ function request($credentials, $payment) { // Attempt the SOAP request and log the exception on failure. $method = $this->method['method']; if (empty($method)) { dsm($this->method); return FALSE; } // do some massaging of parameters for badly behaving iATS methods ($method is now the iATS method, not our internal key) switch ($method) { case 'CreateCreditCardCustomerCode': case 'UpdateCreditCardCustomerCode': $dummy_date = date('c', time()); // now foreach (array('beginDate', 'endDate') as $key) { if (empty($request_params[$key])) { $request_params[$key] = $dummy_date; } } break; } $message = $this->method['message']; $response = $this->method['response']; // always log requests to my own table, start by making a copy of the original request // note: this is different from the drupal watchdog logging that only happens if userframework logging and debug are enabled if (!empty($payment['invoiceNum'])) { $logged_request = $payment; // mask the cc numbers $this->mask($logged_request); // log: ip, invoiceNum, , cc, total, date // dpm($logged_request); $cc = isset($logged_request['creditCardNum']) ? $logged_request['creditCardNum'] : (isset($logged_request['ccNum']) ? $logged_request['ccNum'] : ''); $ip = $logged_request['customerIPAddress']; $query_params = array(1 => array($logged_request['invoiceNum'], 'String'), 2 => array($ip, 'String'), 3 => array(substr($cc, -4), 'String'), 4 => array('', 'String'), 5 => array($logged_request['total'], 'String')); CRM_Core_DAO::executeQuery("INSERT INTO civicrm_iats_request_log\n (invoice_num, ip, cc, customer_code, total, request_datetime) VALUES (%1, %2, %3, %4, %5, NOW())", $query_params); if (!$this->is_ipv4($ip)) { $payment['customerIPAddress'] = substr($ip, 0, 30); } // save the invoiceNum so I can log it for the response $this->invoiceNum = $logged_request['invoiceNum']; } // the agent user and password only get put in here so they don't end up in a log above try { /* until iATS fixes it's box verify, we need to have trace on to make the hack below work */ $soapClient = new SoapClient($this->_wsdl_url, array('trace' => 1, 'soap_version' => SOAP_1_2)); /* build the request manually as per the iATS docs */ $xml = '<' . $message . ' xmlns="' . $this->_wsdl_url_ns . '">'; $request = array_merge($this->request, (array) $credentials, (array) $payment); // Pass CiviCRM tag + version to iATS $request['comment'] = 'CiviCRM: ' . CRM_Utils_System::version() . ' + ' . 'iATS Extension: ' . $this->iats_extension_version(); $tags = !empty($this->_tag_order) ? $this->_tag_order : array_keys($request); foreach ($tags as $k) { if (isset($request[$k])) { $xml .= '<' . $k . '>' . $request[$k] . '</' . $k . '>'; } } $xml .= '</' . $message . '>'; if (!empty($this->options['log'])) { watchdog('civicrm_iatspayments_com', 'Method info: !method', array('!method' => $method), WATCHDOG_NOTICE); watchdog('civicrm_iatspayments_com', 'XML: !xml', array('!xml' => $xml), WATCHDOG_NOTICE); } $soapRequest = new SoapVar($xml, XSD_ANYXML); if (!empty($this->options['log'])) { watchdog('civicrm_iatspayments_com', 'Request !request', array('!request' => print_r($soapRequest, TRUE)), WATCHDOG_NOTICE); } $soapResponse = $soapClient->{$method}($soapRequest); if (!empty($this->options['log']) && !empty($this->options['debug'])) { $request_log = "\n HEADER:\n"; $request_log .= $soapClient->__getLastRequestHeaders(); $request_log .= "\n BODY:\n"; $request_log .= $soapClient->__getLastRequest(); $request_log .= "\n BODYEND:\n"; watchdog('civicrm_iatspayments_com', 'Request: !request', array('!request' => '<pre>' . $request_log . '</pre>'), WATCHDOG_NOTICE); $response_log = "\n HEADER:\n"; $response_log .= $soapClient->__getLastResponseHeaders(); $response_log .= "\n BODY:\n"; $response_log .= $soapClient->__getLastResponse(); $response_log .= "\n BODYEND:\n"; watchdog('civicrm_iatspayments_com', 'Response: !response', array('!response' => '<pre>' . $response_log . '</pre>'), WATCHDOG_NOTICE); } } catch (SoapFault $exception) { if (!empty($this->options['log'])) { watchdog('civicrm_iatspayments_com', 'SoapFault: !exception', array('!exception' => '<pre>' . print_r($exception, TRUE) . '</pre>'), WATCHDOG_ERROR); $response_log = "\n HEADER:\n"; $response_log .= $soapClient->__getLastResponseHeaders(); $response_log .= "\n BODY:\n"; $response_log .= $soapClient->__getLastResponse(); $response_log .= "\n BODYEND:\n"; watchdog('civicrm_iatspayments_com', 'Raw Response: !response', array('!response' => '<pre>' . $response_log . '</pre>'), WATCHDOG_NOTICE); } return FALSE; } // Log the response if specified. if (!empty($this->options['log'])) { watchdog('civicrm_iatspayments_com', 'iATS SOAP response: !request', array('!request' => '<pre>' . print_r($soapResponse, TRUE) . '</pre>', WATCHDOG_DEBUG)); } if (isset($soapResponse->{$response}->any)) { $xml_response = $soapResponse->{$response}->any; return new SimpleXMLElement($xml_response); } else { // deal with bad iats soap, this will only work if trace (debug) is on for now $hack = new stdClass(); $hack->FILE = strip_tags($soapClient->__getLastResponse()); return $hack; } }
<?php $options = array('uri' => 'http://api.local/ws', 'location' => 'http://api.local/ws/index.php', 'trace' => 1); $x = new stdClass(); $x->username = '******'; $x->password = '******'; $header = new SoapHeader('http://api.local/ws', 'AuthenticationHeader', $x); $client = new SoapClient(NULL, $options); $client->__setSoapHeaders(array($header)); try { $books = $client->getAvailableBooks(); print_r($books); $books = $client->addBook('La storia infinita'); print_r($books); } catch (SoapFault $e) { echo $e->getMessage(); } echo $client->__getLastRequestHeaders(); echo "\n\n"; echo $client->__getLastRequest(); echo "\n\n"; echo $client->__getLastResponseHeaders(); echo "\n\n"; echo $client->__getLastResponse();
<vehicleType>' . $vehicleType . '</vehicleType> <manufacturer>' . $manufacturer . '</manufacturer> <baseModel>' . $baseModel . '</baseModel> <subModel>' . $subModel . '</subModel> </request>', XSD_ANYXML); $tag['getDriversCabOptions'] = $request; $prerequest = new SoapVar($tag, SOAP_ENC_OBJECT); $getCardata = array($prerequest); // Set the previously stored cookie for the request foreach ($keys as $k) { $wsdlDatei_eval2->__setCookie($k, $requestCookies[$k]); } $objConversions = $wsdlDatei_eval2->__soapCall('getDriversCabOptions', $getCardata); if (is_soap_fault($objConversions)) { trigger_error("SOAP Fault: (faultcode: {$objConversions->faultcode}, faultstring: {$objConversions->faultstring})", E_USER_ERROR); print_r("REQUEST-Header2: " . $wsdlDatei_eval2->__getLastRequestHeaders() . ""); print_r("Last-REQUEST2: " . $wsdlDatei_eval2->__getLastRequest() . ""); print_r("Last-RESPONSE2: " . $wsdlDatei_eval2->__getLastResponseHeaders() . ""); } echo "<pre>"; print_r("REQUEST-Header2: " . $wsdlDatei_eval2->__getLastRequestHeaders() . ""); print_r("Last-REQUEST2: " . $wsdlDatei_eval2->__getLastRequest() . ""); print_r("Last-RESPONSE2: " . $wsdlDatei_eval2->__getLastResponseHeaders() . ""); print_r($objConversions); echo "</pre>"; $wsdlDatei_eval->doLogout(); } catch (SoapFault $e) { $errorHandled = false; $wsdlDatei_eval->doLogout(); echo "<pre>"; print_r($e);
/** * Generic call method */ public function _call($method, $args, $apply = true) { $result = array('data' => null); $ret = null; // authorize on every call, service class decides what to do on every method call $auth = new stdClass(); $auth->authKey = $this->getAuthKey(); $header = new SoapHeader('http://e107.org/services/auth', 'checkAuthHeader', $auth); try { $this->client->__setSoapHeaders(array($header)); if (is_array($args) && $apply) { $ret = call_user_func_array(array($this->client, $method), $args); } else { $ret = $this->client->{$method}($args); } $result = $ret; if (isset($ret['exception'])) { $result['exception'] = array(); $result['exception']['message'] = "API Exception [call::{$method}]: (#" . $ret['exception']['code'] . ") " . $ret['exception']['message']; $result['exception']['code'] = 'API_' . $ret['exception']['code']; } unset($ret); } catch (SoapFault $e) { $result['exception']['message'] = "SoapFault Exception [call::{$method}]: (#" . $e->faultcode . ") " . $e->faultstring; $result['exception']['code'] = 'SOAP_' . $e->faultcode; if (E107_DEBUG_LEVEL) { $result['exception']['trace'] = $e->getTraceAsString(); $result['exception']['message'] .= ". Header fault: " . ($e->headerfault ? $e->headerfault : 'n/a'); } } catch (Exception $e) { $result['exception']['message'] = "Generic Exception [call::{$method}]: (#" . $e->getCode() . ") " . $e->getMessage(); $result['exception']['code'] = 'GEN_' . $e->getCode(); if (E107_DEBUG_LEVEL) { $result['debug']['trace'] = $e->getTraceAsString(); } } if (E107_DEBUG_LEVEL) { $result['debug']['response'] = $this->client->__getLastResponse(); $result['debug']['request'] = $this->client->__getLastRequest(); $result['debug']['request_header'] = $this->client->__getLastRequestHeaders(); } return $result; }