/**
 *
 * @param array $param
 *        	<br>Parámetros de entrada.
 * @return array
 */
function calculoAportacionCiudadano($param)
{
    global $respError, $farmacia;
    $param = objectToArray($param);
    //die(print_r($param));
    if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
        if (DEBUG & DEBUG_LOG) {
            $mensaje = print_r($param, TRUE);
            $mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
            error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
        }
    }
    unset($param["farmacia"]);
    unset($param["DNI"]);
    $client = new SoapClient(END_POINT, array("location" => LOCATION, "trace" => true, "exceptions" => false));
    $result = $client->__soapCall(__FUNCTION__, array($param));
    //die(print_r($result));
    if (is_soap_fault($result)) {
        if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
            if (DEBUG & DEBUG_LOG) {
                $mensaje = "REQUEST:\n" . $client->__getLastRequest() . "\n";
                $mensaje .= "RESPONSE:\n" . $client->__getLastResponse() . "\n";
                $mensaje .= "RESULT:\n" . $result . "\n";
                $mensaje .= "--SOAP FAULT, llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
                error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
            }
        }
        return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => array("codigoResultadoOperacion" => -9000, "mensajeResultadoOperacion" => $result->faultstring)));
    }
    return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => $respError->sinErrores()));
}
예제 #2
0
 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";
 }
예제 #3
0
 /**
  * @param bool $response
  * @param bool $request
  * @param SoapClient $soapClient
  * @return string
  */
 public function getDebug($response, $request, SoapClient $soapClient)
 {
     if ($response && $request) {
         return "RAW request:\n" . $soapClient->__getLastRequest() . "\n" . "RAW response:\n" . $soapClient->__getLastResponse() . "\n";
     }
     if ($response) {
         return "RAW response:\n" . $soapClient->__getLastResponse() . "\n";
     }
     if ($request) {
         return "RAW request:\n" . $soapClient->__getLastRequest() . "\n";
     }
     return "";
 }
예제 #4
0
파일: ApiClient.php 프로젝트: didww/php-sdk
 /**
  * method to call didww api 2 soap method
  * @param string $method
  * @param array $arguments
  * @return mixed
  * @throws ApiClientException
  */
 public function call($method, $arguments = array())
 {
     $arguments = array_merge(array('auth_string' => self::getCredentials()->getAuthString()), $arguments);
     $method = 'didww_' . $method;
     $timeStart = microtime(true);
     try {
         $result = $this->_client->__soapCall($method, $arguments);
     } catch (\Exception $e) {
         if (self::$_debug) {
             $this->debug("raw request", $this->_client->__getLastRequest());
             $this->debug("raw response", $this->_client->__getLastResponse());
         }
         throw $e;
     }
     if (self::$_debug) {
         $this->debug("raw request", $this->_client->__getLastRequest());
         $this->debug("raw response", $this->_client->__getLastResponse());
     }
     /**
      * check if api returned error and throw exception
      */
     if (isset($result->error) && $result->error > 0) {
         $message = isset(self::$_errorCodes[$result->error]) ? self::$_errorCodes[$result->error] : 'Unknown error with code : ' . $result->error;
         throw new ApiClientException($message);
     }
     $timeFinish = microtime(true);
     $this->time = $timeFinish - $timeStart;
     if (self::$_debug) {
         $this->debug("response from {$method}:", $result);
     }
     return (array) $result;
 }
예제 #5
0
 /**
  * Print the last request
  * 
  * @return void
  */
 private function printLastRequest()
 {
     return;
     if ($this->_config()->isLogEnabled($this->storeId)) {
         $this->soapClient->__getLastRequest();
     }
 }
예제 #6
0
 /**
  * @return string|null
  */
 public function __getLastRequest()
 {
     if (!$this->xmlDSigAdapter || !$this->debugMode) {
         return parent::__getLastRequest();
     }
     return $this->lastRequest;
 }
예제 #7
0
 protected function soapExecute($method, $data, $responseNode)
 {
     $xmlResponse = $this->wsClient->{$method}($data)->{$responseNode};
     var_dump($xmlResponse);
     exit;
     $xmlResponse = $this->array_flat(json_decode(json_encode((array) simplexml_load_string($xmlResponse)), true), $arr = []);
     $this->setLastError(null);
     $this->setLastHttpStatusCode(0);
     $this->setLastRawRequest($this->wsClient->__getLastRequest());
     $this->setLastRawResponse($this->wsClient->__getLastResponse());
     $this->setLastRequest($data);
     $this->setLastResponse($xmlResponse);
     if ($this->getLastError()) {
         throw new Exception\SoapException($this->getLastError());
     }
 }
예제 #8
0
 /**
  * Log the last soap call as request and response XML files.
  *
  * @param \SoapClient $client
  * @param string $operation
  */
 public function logSoapCall($client, $operation)
 {
     if (file_exists($this->path)) {
         $fileName = "ryanwinchester-netsuite-php-" . date("Ymd.His") . "-" . $operation;
         $logFile = $this->path . "/" . $fileName;
         // REQUEST
         $request = $logFile . "-request.xml";
         $Handle = fopen($request, 'w');
         $Data = $client->__getLastRequest();
         $Data = cleanUpNamespaces($Data);
         $xml = simplexml_load_string($Data, 'SimpleXMLElement', LIBXML_NOCDATA);
         $privateFieldXpaths = array('//password', '//password2', '//currentPassword', '//newPassword', '//newPassword2', '//ccNumber', '//ccSecurityCode', '//socialSecurityNumber');
         $privateFields = $xml->xpath(implode(" | ", $privateFieldXpaths));
         foreach ($privateFields as &$field) {
             $field[0] = "[Content Removed for Security Reasons]";
         }
         $stringCustomFields = $xml->xpath("//customField[@xsitype='StringCustomFieldRef']");
         foreach ($stringCustomFields as $field) {
             $field->value = "[Content Removed for Security Reasons]";
         }
         $xml_string = str_replace('xsitype', 'xsi:type', $xml->asXML());
         fwrite($Handle, $xml_string);
         fclose($Handle);
         // RESPONSE
         $response = $logFile . "-response.xml";
         $Handle = fopen($response, 'w');
         $Data = $client->__getLastResponse();
         fwrite($Handle, $Data);
         fclose($Handle);
     }
 }
예제 #9
0
파일: Client.php 프로젝트: b091/mkphp-1
 /**
  * Magiczne wywowałanie metody $this->SoapClient->ClassName($args)
  * Opakowane jest przez try-catch, więc od razu obsłużone są wyjątki i zwracany response.
  *
  * Przykład:
  *  $this->authorize($param1, $param2, $param3);
  *  $this->sendRegistries($registries);
  * powoduje uruchomienie:
  *  $this->soapClient->authorize($param1, $param2, $param3);
  *  $this->soapClient->sendRegistries($registries);
  *
  * @param $name
  * @param $arguments
  *
  * @return mixed
  * @throws MK_Exception
  */
 public function __call($name, $arguments)
 {
     if ($this->soapClient instanceof SoapClient) {
         try {
             $response = $this->soapClient->__soapCall($name, $arguments);
             if ($this->debugRequest) {
                 echo $this->debugRow('Last request', $this->soapClient->__getLastRequest());
             }
             if ($this->debugResponse) {
                 echo $this->debugRow('Last response', $this->soapClient->__getLastResponse());
             }
             return $response;
         } catch (SoapFault $e) {
             $debug = $this->debugRequest ? $this->debugRow('Last request', $this->soapClient->__getLastRequest()) : '';
             $debug .= $this->debugResponse ? $this->debugRow('Last response', $this->soapClient->__getLastResponse()) : '';
             throw new MK_Exception($debug . $this->debugRow('SoapFault', $e->getMessage()));
         } catch (Exception $e) {
             $debug = $this->debugRequest ? $this->debugRow('Last request', $this->soapClient->__getLastRequest()) : '';
             $debug .= $this->debugResponse ? $this->debugRow('Last response', $this->soapClient->__getLastResponse()) : '';
             throw new MK_Exception($debug . $this->debugRow('Exception', $e->getMessage()));
         }
     } else {
         throw new MK_Exception('Nie zostało nawiązane połączenie z Brokerem!');
     }
 }
예제 #10
0
 /**
  * Retrieve request XML
  *
  * @return string
  */
 public function getLastRequest()
 {
     if ($this->_soapClient !== null) {
         return $this->_soapClient->__getLastRequest();
     }
     return '';
 }
예제 #11
0
 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();
     }
 }
 /**
  * Check result on errors (both: soap error and sugar's responce error)
  * @param $result
  * @return bool
  */
 protected function checkResult($result)
 {
     $this->fault = null;
     if (defined('SUGAR_SOAP_TRACE')) {
         $this->log($this->_soap->__getLastRequest(), 'DEBUG');
         $this->log($this->_soap->__getLastResponse(), 'DEBUG');
     }
     if (is_soap_fault($result)) {
         $this->fault = array('type' => 'soap', 'code' => $result->faultcode, 'message' => $result->faultstring);
         $this->log("SOAP error {$this->fault['message']}", 'ERROR');
         return false;
     }
     if (isset($result->error) && $result->error->number != 0) {
         $this->fault = array('type' => 'responce', 'code' => $result->error->number, 'message' => $result->error->name);
         $this->log("SOAP sugar responce error {$this->fault['message']}", 'ERROR');
         return false;
     }
     return true;
 }
예제 #13
0
 /**
  * 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());
 }
예제 #14
0
파일: factura.php 프로젝트: aabcehmt/fe
function CallWSAA($CMS)
{
    $client = new SoapClient(WSDLA, array('soap_version' => SOAP_1_2, 'location' => URL, 'trace' => 1, 'exceptions' => 0));
    $results = $client->loginCms(array('in0' => $CMS));
    file_put_contents("request-loginCms.xml", $client->__getLastRequest());
    file_put_contents("response-loginCms.xml", $client->__getLastResponse());
    if (is_soap_fault($results)) {
        exit("SOAP Fault: " . $results->faultcode . "\n" . $results->faultstring . "\n");
    }
    return $results->loginCmsReturn;
}
예제 #15
0
 private function sendRequest($method, $data = array())
 {
     error_reporting(0);
     ini_set('default_socket_timeout', 30);
     $soapClient = new SoapClient(Configure::read('PartTradeApi.url'), array('trace' => 1));
     $response = (array) $soapClient->{$method}($data);
     $this->writeLog('REQUEST', json_encode($data) . "\r\n" . $soapClient->__getLastRequest());
     $this->writeLog('RESPONSE', json_encode($response));
     if (!$response) {
         throw new Exception('PartTradeAPI: No response from server');
     }
     return $response;
 }
예제 #16
0
파일: ZapTradeApi.php 프로젝트: Mirocow/gpz
 private function sendRequest($method, $data = array())
 {
     error_reporting(0);
     ini_set('default_socket_timeout', 30);
     $options = array("soap_version" => SOAP_1_2, "encoding" => "utf-8");
     $soapClient = new SoapClient(Configure::read('ZapTradeApi.url'), $options);
     $userData = array('email' => Configure::read('ZapTradeApi.username'), 'password' => Configure::read('ZapTradeApi.password'));
     $response = (array) $soapClient->{$method}($userData, $data);
     $this->writeLog('REQUEST', json_encode($data) . "\r\n" . $soapClient->__getLastRequest());
     $this->writeLog('RESPONSE', json_encode($response));
     if (!$response) {
         throw new Exception('ZapTradeAPI: No response from server');
     }
     if (isset($response['error'])) {
         throw new Exception('ZapTradeAPI: ' . $response['error']);
     }
     return $response;
 }
예제 #17
0
 /**
  * Make SOAP Request
  * 
  * @param string $methodName
  * @param array $parameters
  * @param boolean $isTest
  * @param boolean $debug
  * 
  * @return \SimpleXMLElement
  */
 public static function SoapRequest($methodName, array $parameters, $isTest = false, $debug = false)
 {
     $soapClientParams = array();
     if ($debug) {
         $soapClientParams['trace'] = 1;
     }
     if ($isTest) {
         $wsdlUrl = static::WSDL_TEST_URL;
         $methodName .= 'Tst';
     } else {
         $wsdlUrl = static::WSDL_URL;
     }
     $soapClient = new \SoapClient($wsdlUrl, $soapClientParams);
     // optionally use KomerciSoapClient to format the XML according to the specs
     $soapResult = $soapClient->__soapCall($methodName, $parameters);
     if ($debug) {
         var_dump($soapClient->__getLastRequest());
     }
     $resultNodeName = $methodName . 'Result';
     $xmlResult = $soapResult->{$resultNodeName}->any;
     return $xmlResult;
 }
예제 #18
0
 /**
  * The status call can be used to get a report on the current status of a Payment Order, its payments and its
  * captures or refunds. It can be used to determine whether an order is considered paid, to retrieve a payment ID,
  * to get information on the statuses of captures/refunds.
  *
  * @param string $paymentOrderKey
  *
  * @return Type\StatusSuccess
  *
  * @throws \Exception
  */
 public function status($paymentOrderKey)
 {
     $request = new Type\StatusRequest();
     $request->setMerchant($this->merchant);
     $request->setPaymentOrderKey($paymentOrderKey);
     // make the call
     $this->logger->info("Payment status: " . $paymentOrderKey, $request->toArray());
     /** @var StatusResponse $response */
     $response = $this->soap('status', [$request->toArray()]);
     $this->logger->info("Payment status soap request: " . $paymentOrderKey, (array) $this->soapClient->__getLastRequest());
     $this->logger->info("Payment status soap response: " . $paymentOrderKey, (array) $this->soapClient->__getLastRequest());
     // validate response
     if ($response->getStatusError()) {
         if ($this->test) {
             var_dump($this->soapClient->__getLastRequest());
             var_dump($response->getStatusError());
         }
         $this->logger->error("Payment status: " . $paymentOrderKey, (array) $response->getStatusError()->getError()->getExplanation());
         throw new \Exception($response->getStatusError()->getError()->getExplanation());
     }
     return $response->getStatusSuccess();
 }
예제 #19
0
 /**
  * @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);
     }
 }
예제 #20
0
function attach_file_protocol($subject, $sender, $usage_code, $files, $document, $print_full_result = false)
{
    $client = new SoapClient(PROTOCOL_URL, array('trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 0));
    // set trace = 1 for debugging
    $client->__setLocation(PROTOCOL_URL);
    $return = array();
    foreach ($files as $file) {
        try {
            $protocol_args = array('userName' => PROTOCOL_USER, 'password' => PROTOCOL_PASS, 'document' => $document->return, 'fileData' => $file['file'], 'fileName' => $file['name'], 'fileDescription' => $file['description'], 'inOutBoth' => 1);
            $result = $client->attachFileToDocument($protocol_args);
            $return[] = array('name' => $file['name'], 'description' => $file['description'], 'protocol_attach' => $result->return);
        } catch (SoapFault $fault) {
            if (DEBUG) {
                $return[] = array('lastest_request' => $client->__getLastRequest(), 'fault' => $fault->getMessage());
            }
        }
    }
    //TEMP -------------------
    echo '<br /><hr /> attachFileToDocument call results: <br /><br />';
    print_r($return);
    //------------------------
    return $return;
}
 /**
  * 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;
     }
 }
예제 #22
0
 /**
  * @Route("/", name="home")
  * @Method({"GET"})
  * @Template
  */
 public function indexAction()
 {
     $currentDate = new \DateTime('now');
     $afipParameters = $this->container->getParameter('afip-ws');
     $tmpDir = $this->container->getParameter('tmpDir');
     $wsaa = $afipParameters['wsaa'];
     $wsfev1 = $afipParameters['wsfev1'];
     $cert = realpath($afipParameters['cert']);
     $pri = realpath($afipParameters['pri']);
     $traFile = '/tra-' . $currentDate->format("YmdHis") . '.xml';
     $traTmpFile = '/tra-' . $currentDate->format("YmdHis") . '.tmp';
     $taFIle = '/ta-' . $currentDate->format("YmdHis") . '.xml';
     // Crear tra file con el request al servicio
     $tra = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>' . '<loginTicketRequest version="1.0">' . '</loginTicketRequest>');
     $tra->addChild('header');
     $tra->header->addChild('uniqueId', date('U'));
     $tra->header->addChild('generationTime', date('c', date('U') - 60));
     $tra->header->addChild('expirationTime', date('c', date('U') + 60));
     $tra->addChild('service', 'wsfe');
     $tra->asXML($tmpDir . $traFile);
     // This functions makes the PKCS#7 signature using TRA as input file, CERT and PRIVATEKEY
     $status = openssl_pkcs7_sign($tmpDir . $traFile, $tmpDir . $traTmpFile, 'file://' . $cert, array('file://' . $pri, 'umadsysadmin'), array(), !PKCS7_DETACHED);
     if (!$status) {
         exit("ERROR generating PKCS#7 signature");
     }
     $sign = fopen($tmpDir . $traTmpFile, "r");
     $i = 0;
     $cms = "";
     while (!feof($sign)) {
         $buffer = fgets($sign);
         if ($i++ >= 4) {
             $cms .= $buffer;
         }
     }
     fclose($sign);
     //unlink($tmpDir.$traFile);
     //unlink($tmpDir.$traTmpFile);
     //var_dump($cms);
     $client = new \SoapClient($wsaa, array('soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 0));
     $result = $client->loginCms(array('in0' => $cms));
     file_put_contents($tmpDir . '/loginCmsRequest-' . $currentDate->format("YmdHis") . '.xml', $client->__getLastRequest());
     file_put_contents($tmpDir . '/loginCmsResponse-' . $currentDate->format("YmdHis") . '.xml', $client->__getLastResponse());
     if (is_soap_fault($result)) {
         exit("SOAP Fault: " . $result->faultcode . "\n" . $result->faultstring . "\n");
     }
     file_put_contents($tmpDir . $taFIle, $result->loginCmsReturn);
     /*$ta = new \SimpleXMLElement(file_get_contents('/var/www/efact-afip.com.ar/ws-source/xml/ta-20151014163631.xml'));
             $source = $ta->header->source;
             $destination = $ta->header->destination;
             $uniqueId = $ta->header->uniqueId;
             $generationTime = $ta->header->generationTime;
             $expirationTime = $ta->header->expirationTime;
             $token = (string) $ta->credentials->token;
             $sign = (string) $ta->credentials->sign;
     
             //unlink($xmlDir.$taFIle);
     
             $clientWsfe = new \SoapClient($wsfev1, array('soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 0));
     
     
             $parameters = new \StdClass();
             $parameters->Auth = new \StdClass();
             $parameters->Auth->Token = $token;
             $parameters->Auth->Sign = $sign;
             $parameters->Auth->Cuit = '27953948406';
     
             $parameters->FeCAEReq = new \StdClass();
             $parameters->FeCAEReq->FeCabReq = new \StdClass();
             $parameters->FeCAEReq->FeCabReq->CantReg = 1;
             $parameters->FeCAEReq->FeCabReq->PtoVta = 12;
             $parameters->FeCAEReq->FeCabReq->CbteTipo = 1;
             $parameters->FeCAEReq->FeDetReq = new \StdClass();
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest = new \StdClass();
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->Concepto = 1;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->DocTipo = 80;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->DocNro = 20111111112;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->CbteDesde = 1;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->CbteHasta = 1;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->CbteFch = 20100903;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpTotal = 184.05;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpTotConc = 0;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpNeto = 150;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpOpEx = 0;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpTrib = 7.8;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->ImpIVA = 26.25;
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->FchServDesde = '';
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->FchServHasta = '';
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->FchVtoPago = '';
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->MonId = 'PES';
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->MonCotiz = 1;
                 
             $tributo1 = new \StdClass();
             $tributo1->Id = 99;
             $tributo1->Desc = 'Impuesto Municipal Matanza';
             $tributo1->BaseImp = 150;
             $tributo1->Alic = 5.2;
             $tributo1->Importe = 7.8;
     
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->Tributos = array($tributo1);
     
             $iva1 = new \StdClass();
             $iva1->Id = 5;
             $iva1->BaseImp = 100;
             $iva1->Importe = 21;
     
             $iva2 = new \StdClass();
             $iva2->Id = 4;
             $iva2->BaseImp = 50;
             $iva2->Importe = 5.25;
     
             $parameters->FeCAEReq->FeDetReq->FECAEDetRequest->Iva = array($iva1, $iva2);
     
             //var_dump($parameters);
     
     
             $feCAESolicitar = $clientWsfe->FECAESolicitar($parameters);
     
             if (is_soap_fault($feCAESolicitar)) {
                 exit("SOAP Fault: ".$feCAESolicitar->faultcode."\n".$feCAESolicitar->faultstring."\n");
             }
     
             print_r($feCAESolicitar->FECAESolicitarResult);
     
             
             //$feAuthRequest = $clientWsfe->FEAuthRequest();
     
             $feAuthRequest = $clientWsfe->__soapCall('FEAuthRequest', array('Token' => $token, 'Sign' => $sign, 'Cuit' => '27953948406'));
     
             var_dump(get_class_methods($clientWsfe));
             var_dump($clientWsfe->__getTypes()[1]);
             var_dump($clientWsfe->__getFunctions());
     
             if (is_soap_fault($feAuthRequest)) {
                 exit("SOAP Fault: ".$feAuthRequest->faultcode."\n".$feAuthRequest->faultstring."\n");
             }*/
     return array('name' => "");
 }
 /**
  * Make the call
  *
  * @param string $method The method to be called.
  * @param array $parameters [optional] $parameters    The parameters.
  * @return mixed
  * @throws CampaignCommanderMemberException
  */
 protected function doCall($method, array $parameters = array())
 {
     // open connection if needed
     if ($this->soapClient === null || $this->token === null) {
         // build options
         $options = array('soap_version' => SOAP_1_1, 'trace' => self::DEBUG, 'exceptions' => true, 'connection_timeout' => $this->getTimeOut(), 'user_agent' => $this->getUserAgent(), 'typemap' => array(array('type_ns' => 'http://www.w3.org/2001/XMLSchema', 'type_name' => 'long', 'to_xml' => array(__CLASS__, 'toLongXML'), 'from_xml' => array(__CLASS__, 'fromLongXML'))));
         // create client
         $this->soapClient = new \SoapClient($this->getServer() . '/' . self::WSDL_URL, $options);
         // build login parameters
         $loginParameters['login'] = $this->getLogin();
         $loginParameters['pwd'] = $this->getPassword();
         $loginParameters['key'] = $this->getKey();
         // make the call
         $response = $this->soapClient->__soapCall('openApiConnection', array($loginParameters));
         // validate
         if (is_soap_fault($response)) {
             // more detailed message available
             $message = $response->getMessage();
             if (isset($response->detail->ConnectionServiceException->description)) {
                 $message = (string) $response->detail->ConnectionServiceException->description;
             }
             if (isset($response->detail->MemberServiceException->description)) {
                 $message = (string) $response->detail->MemberServiceException->description . ' ' . $response->detail->MemberServiceException->fields . ' ' . $response->detail->MemberServiceException->status;
             }
             // invalid token?
             if ($message == 'Please enter a valid token to validate your connection.') {
                 // reset token
                 $this->token = null;
                 // try again
                 return self::doCall($method, $parameters);
             }
             // internal debugging enabled
             if (self::DEBUG) {
                 echo '<pre>';
                 echo 'last request<br />';
                 var_dump($this->soapClient->__getLastRequest());
                 echo 'response<br />';
                 var_dump($response);
                 echo '</pre>';
             }
             // throw exception
             throw new CampaignCommanderMemberException($message);
         }
         // validate response
         if (!isset($response->return)) {
             throw new CampaignCommanderMemberException('Invalid response');
         }
         // set token
         $this->token = (string) $response->return;
     }
     // redefine
     $method = (string) $method;
     $parameters = (array) $parameters;
     // loop parameters
     foreach ($parameters as $key => $value) {
         // strings should be UTF8
         if (gettype($value) == 'string') {
             $parameters[$key] = utf8_encode($value);
         }
     }
     // add token
     $parameters['token'] = $this->token;
     try {
         // make the call
         $response = $this->soapClient->__soapCall($method, array($parameters));
     } catch (\Exception $e) {
         // internal debugging enabled
         if (self::DEBUG) {
             echo '<pre>';
             echo 'last request<br />';
             var_dump($this->soapClient->__getLastRequest());
             echo 'response<br />';
             if (isset($response)) {
                 var_dump($response);
             }
             echo '</pre>';
         }
         // throw exception
         throw new CampaignCommanderMemberException($e->getMessage());
     }
     // validate response
     if (is_soap_fault($response)) {
         // more detailed message available
         $message = $response->getMessage();
         if (isset($response->detail->ConnectionServiceException->description)) {
             $message = (string) $response->detail->ConnectionServiceException->description;
         }
         if (isset($response->detail->MemberServiceException->description)) {
             $message = (string) $response->detail->MemberServiceException->description;
         }
         if (isset($response->detail->CcmdServiceException->description)) {
             $message = (string) $response->detail->CcmdServiceException->description;
             if (isset($response->detail->CcmdServiceException->fields)) {
                 $message .= ' fields: ' . $response->detail->CcmdServiceException->fields;
             }
             if (isset($response->detail->CcmdServiceException->status)) {
                 $message .= ' status: ' . $response->detail->CcmdServiceException->status;
             }
         }
         // internal debugging enabled
         if (self::DEBUG) {
             echo '<pre>';
             var_dump(htmlentities($this->soapClient->__getLastRequest()));
             var_dump($this);
             echo '</pre>';
         }
         // throw exception
         throw new CampaignCommanderMemberException($message);
     }
     // empty reply
     if (!isset($response->return)) {
         return null;
     }
     // return the response
     return $response->return;
 }
예제 #24
0
 /**
  * Returns the last SOAP request
  *
  * @return string The last SOAP request
  */
 public function getRequest()
 {
     return $this->client->__getLastRequest();
 }
예제 #25
0
/**
 *
 * @param array $param.        	
 *
 * @return array
 */
function registroDispensacion($param)
{
    global $respError, $farmacia, $conn, $connBack, $insercionRemota, $SQLserverName, $SQLserverNameBack;
    $param = objectToArray($param);
    //die(print_r($param));
    $TSI = $param["TSI"];
    $DNI = $param["DNI"];
    if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
        if (DEBUG & DEBUG_LOG) {
            $mensaje = print_r($param, TRUE);
            $mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
            error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
        }
    }
    unset($param["TSI"]);
    unset($param["farmacia"]);
    unset($param["DNI"]);
    if (!CompruebaTSI(strtoupper($TSI))) {
        return array(__FUNCTION__ . "Result" => array("return" => "", "resultadoOperacion" => array("codigoResultadoOperacion" => -9023, "mensajeResultadoOperacion" => "TSI: '{$TSI}' incorrecto.")));
    }
    libxml_use_internal_errors(true);
    $xmlin = new DOMDocument();
    if (!$xmlin->loadXML(ltrim($param["arg0"]))) {
        $errors = libxml_get_errors();
        libxml_clear_errors();
        libxml_use_internal_errors(false);
        if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
            if (DEBUG & DEBUG_LOG) {
                $mensaje = "codigoResultadoOperacion:\n" . $errors[0]->code . "\n";
                $mensaje .= "mensajeResultadoOperacion:\n" . $errors[0]->message . "\n";
                $mensaje .= "arg0:\n" . $param["arg0"] . "\n";
                $mensaje .= "--Error de parseo en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
                error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
            }
        }
        return array(__FUNCTION__ . "Result" => array("return" => $param["arg0"], "resultadoOperacion" => array("codigoResultadoOperacion" => $errors[0]->code, "mensajeResultadoOperacion" => $errors[0]->message)));
    }
    $productos = $xmlin->getElementsByTagName("producto");
    foreach ($productos as $value) {
        $idreceta = $value->getElementsByTagName("idreceta_iddispensacion")->item(0)->nodeValue;
        if (ChequeaTalonario(strtoupper($idreceta)) == false) {
            return array(__FUNCTION__ . "Result" => array("return" => "", "resultadoOperacion" => array("codigoResultadoOperacion" => -9022, "mensajeResultadoOperacion" => "El id_receta: {$idreceta} no pasa el chequeo de control.")));
        }
    }
    $client = new SoapClient(END_POINT, array("location" => LOCATION, "trace" => true, "exceptions" => false));
    $result = $client->__soapCall(__FUNCTION__, array($param));
    //die(print_r($result));
    if (is_soap_fault($result)) {
        if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
            if (DEBUG & DEBUG_LOG) {
                $mensaje = "REQUEST:\n" . $client->__getLastRequest() . "\n";
                $mensaje .= "RESPONSE:\n" . $client->__getLastResponse() . "\n";
                $mensaje .= "RESULT:\n" . $result . "\n";
                $mensaje .= "--SOAP FAULT, llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
                error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
            }
        }
        return array(__FUNCTION__ . "Result" => array("return" => $result, "resultadoOperacion" => array("codigoResultadoOperacion" => -9000, "mensajeResultadoOperacion" => $result->faultstring)));
    }
    $xmlout = new DOMDocument();
    if (!$xmlout->loadXML(ltrim($result->return))) {
        $errors = libxml_get_errors();
        libxml_clear_errors();
        libxml_use_internal_errors(false);
        //die(print_r($errors));
        if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
            if (DEBUG & DEBUG_LOG) {
                $mensaje = "codigoResultadoOperacion:\n" . $errors[0]->code . "\n";
                $mensaje .= "mensajeResultadoOperacion:\n" . $errors[0]->message . "\n";
                $mensaje .= "RESULT:\n" . $result . "\n";
                $mensaje .= "--Error de parseo en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
                error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
            }
        }
        return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => array("codigoResultadoOperacion" => $errors[0]->code, "mensajeResultadoOperacion" => $errors[0]->message)));
    }
    $resultado = $xmlout->getElementsByTagName("resultado");
    foreach ($resultado as $value) {
        $codigoR = $value->getElementsByTagName("codigo")->item(0)->nodeValue;
        $descripcionR = $value->getElementsByTagName("descripcion")->item(0)->nodeValue;
    }
    if ($codigoR == 0) {
        //Comprobamos que el resultado de operación sea igual a cero (0).
        //Cogemos el XML de entrada y salida y lo leemos para capturar los datos
        $msg = $xmlout->getElementsByTagName("msg")->item(0)->attributes;
        foreach ($msg as $atributo) {
            if ($atributo->name == 'fecha') {
                $fechaXML = $atributo->nodeValue;
            }
        }
        //Datos de Productos
        $productos = $xmlin->getElementsByTagName("producto");
        foreach ($productos as $value) {
            $tabla = PREFIJO_TABLA_DISPENSACION . date("ym");
            $parametros = array("farmacia" => $farmacia, "sistema" => $xmlout->getElementsByTagName("sistema")->item(0)->nodeValue, "idtx" => $xmlout->getElementsByTagName("idtx")->item(0)->nodeValue, "CIP" => $xmlout->getElementsByTagName("cip")->item(0)->nodeValue, "identificacion" => $xmlout->getElementsByTagName("identificacion")->item(0)->nodeValue, "DNI" => $DNI, "codFarmacia" => $xmlin->getElementsByTagName("codfarmacia")->item(0)->nodeValue, "codColegiado" => $xmlin->getElementsByTagName("codcolegiado")->item(0)->nodeValue, "numColegiado" => $xmlin->getElementsByTagName("ncolegiado")->item(0)->nodeValue, "TSI" => $TSI, "id_Receta" => $value->getElementsByTagName("idreceta_iddispensacion")->item(0)->nodeValue, "PVPCalculadoAport" => $value->getElementsByTagName("pvpcalculadoaport")->item(0)->nodeValue, "PVPTotal" => $value->getElementsByTagName("pvptotal")->item(0)->nodeValue, "euros_Receta" => $value->getElementsByTagName("euros_receta")->item(0)->nodeValue, "envases" => $value->getElementsByTagName("nenvases")->item(0)->nodeValue, "codNacional" => $value->getElementsByTagName("codnacional")->item(0)->nodeValue, "PVPComerEnv" => $value->getElementsByTagName("pvpconerenv")->item(0)->nodeValue, "aportacionProducto" => $value->getElementsByTagName("aportacionproducto")->item(0)->nodeValue, "check_Atep" => $value->getElementsByTagName("check_atep")->item(0)->nodeValue, "indicador_Euro" => $value->getElementsByTagName("indicador_euro")->item(0)->nodeValue, "check_Objecion" => $value->getElementsByTagName("check_objecion")->item(0)->nodeValue, "check_Visado" => $value->getElementsByTagName("check_visado")->item(0)->nodeValue, "fechaXML" => $fechaXML);
            $resultadoInsertar = insertar($conn, $tabla, $parametros, $SQLserverName);
            // Si está activada la inserción remota la hacemos.
            if ($insercionRemota) {
                insertar($connBack, $tabla, $param, $SQLserverNameBack);
            }
        }
    }
    return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => array("codigoResultadoOperacion" => $codigoR, "mensajeResultadoOperacion" => $descripcionR)));
}
예제 #26
0
echo "<pre>\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";
    
예제 #27
0
        }
        echo "</tr>\n";
        foreach ($aResults as $iRow => $aData) {
            echo "<tr>\n";
            foreach ($aData->values as $aKeyValuePair) {
                echo "   <td>" . $aKeyValuePair->value . "</td>\n";
            }
            echo "</tr>\n";
        }
        echo "</table>\n";
    } else {
        $aErrors = array();
        foreach ($oRes->errors->messages as $oMessage) {
            $aErrors[] = $oMessage->text;
        }
        $sErrorMsg = implode(', ', $aErrors);
        echo "<p>SearchObjects() failed with message: {$sErrorMsg}</p>\n";
        //echo "<pre>\n";
        //print_r($oRes);
        //echo "</pre>\n";
    }
    echo "</p>\n";
} catch (SoapFault $e) {
    echo "<h1>SoapFault Exception: {$e->getMessage()}</h1>\n";
    echo "<h2>Request</h2>\n";
    echo "<pre>\n";
    echo htmlspecialchars($oSoapClient->__getLastRequest()) . "\n";
    echo "</pre>";
    echo "<h2>Response</h2>";
    echo $oSoapClient->__getLastResponse() . "\n";
}
예제 #28
0
파일: soap-test.php 프로젝트: horros/agavi
    }
    $result = $client->getProduct($_GET['item']);
} catch (SoapFault $e) {
    $result = $e->__toString();
}
?>
		<h3>Return Value</h3>
		<pre>
<?php 
var_dump($result);
?>
		</pre>
		<h3>SOAP Request</h3>
		<pre>
<?php 
echo htmlspecialchars($client->__getLastRequest());
?>
		</pre>
		<h3>SOAP Response</h3>
		<pre>
<?php 
echo htmlspecialchars($client->__getLastResponse());
?>
		</pre>
		<hr />
		<h2>listProducts()</h2>
<?php 
try {
    $result = $client->listProducts();
} catch (SoapFault $e) {
    $result = $e->__toString();
								<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);
    echo "</pre>";
예제 #30
0
 /** 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);
     }
 }