/**
 *
 * @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()));
}
Example #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";
 }
 /**
  * @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 "";
 }
Example #4
0
 /**
  * Login
  *
  * @param string $username
  * @param string $password
  * @param string $organisation
  * @todo should this function create a new SOAP clust clienst?
  * @throw SoapFault
  */
 public function logon($username, $password, $organisation)
 {
     $return = false;
     $parameters = array('user' => $username, 'password' => $password, 'organisation' => $organisation);
     $logonResponse = $this->soapLoginClient->logon($parameters);
     if ($logonResponse->LogonResult == LogonResult::OK) {
         // Read the SOAP client last response
         $response = $this->soapLoginClient->__getLastResponse();
         /*
         //echo htmlentities($response);
         echo '<pre>';
         var_dump($this->soapLoginClient->__getTypes());
         echo '</pre>';
         echo '<pre>';
         var_dump($logonResponse);
         echo '</pre>';
         */
         // Create an SimpleXML object so we can easy access XML elements
         $envelope = simplexml_load_string($response, null, null, self::XML_NAMESPACE_SOAP_ENVELOPE);
         // Get the Twinfield header element from SOAP evenlope header
         $header = $envelope->Header->children(Twinfield::XML_NAMESPACE);
         // Save the clust and session ID data
         $this->cluster = $logonResponse->cluster;
         $this->sessionId = $header->Header->SessionID;
         // Create an SOAP input header for further SOAP request
         $this->soapInputHeader = new \SoapHeader(Twinfield::XML_NAMESPACE, 'Header', array('SessionID' => $this->sessionId));
         // Create a new SOAP client that connects to the cluster
         $wsdlClusterUrl = sprintf(self::SOAP_WSDL_CLUSTER_URI, $this->cluster);
         $this->soapClusterClient = new \SoapClient($wsdlClusterUrl);
         $return = true;
     }
     return $return;
 }
Example #5
0
 private function testEnv(array $functions, $url, OutputInterface $output)
 {
     $soapClient = new \SoapClient($url, array('cache_wsdl' => 0, 'trace' => 1, 'soap_version' => SOAP_1_1));
     foreach ($functions as $function => $parameters) {
         $output->writeln('Test de la fonction soap <comment>' . $function . '</comment>');
         $output->writeln('Parameters : ');
         dump($parameters);
         if (!array_key_exists('methodCall', $this->config) || $this->config['methodCall'] == 'soapCall') {
             $result = $soapClient->__soapCall($function, $parameters);
         } else {
             $result = $soapClient->{$function}($parameters);
         }
         $headers = $soapClient->__getLastResponseHeaders();
         if ($output->isDebug()) {
             $output->writeln('Entete de la reponse : ');
             dump($headers);
         }
         if (false === ($site = $this->getSiteHeader($headers))) {
             throw new \Exception('Site Header introuvable dans la réponse.', 1);
         }
         $output->writeln('Serveur ayant repondu : <info>' . $site . '</info>');
         $output->writeln('Reponse : ');
         dump($result);
         if ($output->isDebug()) {
             dump($soapClient->__getLastResponse());
         }
     }
 }
Example #6
0
 /**
  * Get response XML
  *
  * @return string
  */
 public function getLastResponse()
 {
     if ($this->_soapClient !== null) {
         return $this->_soapClient->__getLastResponse();
     }
     return '';
 }
 /**
  * Print the Last Response
  */
 private function printLastResponse()
 {
     if ($this->_config()->isLogEnabled($this->storeId)) {
         Mage::log('Mailup: printLastResponse');
         Mage::log($this->soapClient->__getLastResponse());
     }
 }
Example #8
0
 /**
  * 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;
 }
Example #9
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);
     }
 }
Example #10
0
 /**
  * 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!');
     }
 }
Example #11
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());
     }
 }
 /**
  * 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;
 }
Example #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());
 }
Example #14
0
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;
}
 /**
  * Return result of the SOAP call
  *
  * @param string $method
  * @param array  $parameters
  * 
  * @return string|object
  */
 public function call($method, array $parameters)
 {
     try {
         $oReturn = $this->soapClient->__soapCall($method, $parameters);
         unset($this->soapClient);
         return $oReturn;
     } catch (\SoapFault $fault) {
         print_r("Response: " . $this->soapClient->__getLastResponse());
         trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
     }
 }
 /**
  * Initialize the soap client with the local information.
  *
  * @throws InvalidCredentialException If given credentials are invalid
  * @throws RestCallException          If Prestashop is not accessible.
  * @throws \SoapFault
  */
 protected function connect()
 {
     try {
         $this->session = $this->client->login($this->clientParameters->getSoapUsername(), $this->clientParameters->getRestApiKey());
     } catch (\SoapFault $e) {
         if (static::PRESTASHOP_BAD_CREDENTIALS === $e->faultcode) {
             throw new InvalidCredentialException(sprintf('Error on Prestashop SOAP credentials to "%s": "%s".' . 'You should check your login and Prestashop API key.', $this->clientParameters->getPrestashopUrl(), $e->getMessage()), $e->getCode(), $e);
         } elseif (static::PRESTASHOP_CLIENT_NOT_CALLABLE === $e->faultcode) {
             $lastResponse = $this->client->__getLastResponse();
             echo "DEBUG: Last SOAP response: " . $lastResponse . "\n";
             if (strlen($lastResponse) <= 200) {
                 $truncatedLastResponse = htmlentities($lastResponse);
             } else {
                 $truncatedLastResponse = substr(htmlentities($lastResponse), 0, 100) . nl2br("\n...\n") . substr(htmlentities($lastResponse), -100);
             }
             throw new RestCallException(sprintf('Error on Prestashop client to "%s": "%s".' . 'Something is probably wrong in the last SOAP response:' . nl2br("\n") . '"%s"', $this->clientParameters->getPrestashopUrl(), $e->getMessage(), $truncatedLastResponse), $e->getCode(), $e);
         } else {
             throw $e;
         }
     }
 }
Example #17
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);
     }
 }
Example #18
0
 /**
  *
  */
 public function indexAction($city, $country)
 {
     $wsdl = 'http://www.webservicex.com/globalweather.asmx?WSDL';
     $url = 'http://www.webservicex.com/globalweather.asmx';
     $client = new \SoapClient($wsdl, array('trace' => 1, 'exception' => 0, 'location' => $url, 'cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_1));
     $inputparam = new \SoapVar('<ns1:GetWeather><ns1:CityName>' . $city . '</ns1:CityName><ns1:CountryName>' . $country . '</ns1:CountryName></ns1:GetWeather>', XSD_ANYXML);
     $return = $client->GetWeather($inputparam);
     $myresponse = $client->__getLastResponse();
     //return new Response(
     //'<html><body>Soap Esempio Response: <br>'.$client->__getLastResponse().'</body></html>'
     //);
     //$number = rand(1, $limit);
     return $this->render('estarRdaBundle:SoapEsempio:index.html.twig', array('myresponse' => $myresponse));
 }
Example #19
0
/**
 * PHP5 SOAP implementation
 */
function webServiceAction_php5(&$amfbody, $webServiceURI, $webServiceMethod, $args, $phpInternalEncoding)
{
    //Note that encoding is set to php internal encoding,
    //As SoapClient always sends and receives stuff in UTF-8 anyway
    if (class_exists('SoapClient')) {
        $client = new SoapClient($webServiceURI, array("exceptions" => 0, "trace" => 1, "encoding" => $phpInternalEncoding));
        $response = $client->__soapCall($webServiceMethod, $args[0]);
        if (is_soap_fault($response)) {
            $ex = new AMFException(E_USER_ERROR, "SOAP error: " . $client->__getLastResponse(), __FILE__, __LINE__, "AMFPHP_SOAP_ERROR");
            AMFException::throwException($amfbody, $ex);
        }
        return $response;
    } else {
        $ex = new AMFException(E_USER_ERROR, "PHP5 SoapClient is not installed", __FILE__, __LINE__, "AMFPHP_SOAP_NOT_INSTALLED_ERROR");
        AMFException::throwException($amfbody, $ex);
    }
}
Example #20
0
 public function run($reportName, $formatType = 'PDF', $reportParams = null, $saveFile = false)
 {
     $client = new \SoapClient($this->jasperServer->getWsdl(), array('login' => $this->jasperServer->getUsername(), 'password' => $this->jasperServer->getPassword(), "trace" => 1, "exceptions" => 0));
     $client->runReport($this->_requestMock($reportName, $formatType, $reportParams));
     preg_match('/boundary="(.*?)"/', $client->__getLastResponseHeaders(), $gotcha);
     $bound = $gotcha[1];
     $invokeReturnPart = explode($bound, $client->__getLastResponse());
     $output = substr($invokeReturnPart[2], strpos($invokeReturnPart[2], '<report>') + 9);
     $content = trim(str_replace("\n--", "", $output));
     if ($saveFile === true) {
         $filename = $this->jasperServer->getPathToSave() . DIRECTORY_SEPARATOR . 'generate_report_at_' . time() . ".{$formatType}";
         file_put_contents($filename, $content);
         return $filename;
     } else {
         return $content;
     }
 }
Example #21
0
 public function requestReport($report, $format, $params)
 {
     $params_xml = "";
     foreach ($params as $name => $value) {
         $params_xml .= "<parameter name=\"{$name}\"><![CDATA[{$value}]]></parameter>\n";
     }
     // This is a report parameter passed in.
     $request = '<?xml version="1.0" encoding="UTF-8"?>
             <request operationName="runReport" locale="en">
                 <argument name="RUN_OUTPUT_FORMAT">' . $format . '</argument>
                 <argument name="USE_DIME_ATTACHMENTS"><![CDATA[1]]></argument>
                 <resourceDescriptor name="" wsType="reportUnit" uriString="' . $report . '" isNew="false">
                     <label></label>' . $params_xml . '</resourceDescriptor>
             </request>
         ';
     $client = new \SoapClient(null, array('location' => $this->url, 'uri' => 'urn:', 'login' => $this->username, 'password' => $this->password, 'trace' => 1, 'exception' => 1, 'soap_version' => \SOAP_1_1, 'style' => \SOAP_RPC, 'use' => \SOAP_LITERAL));
     $result = null;
     try {
         $client->__soapCall('runReport', array('request' => $request));
     } catch (\SoapFault $cf) {
         // A DIME-encoded message has no text, generating an exception
         // Parse out the traced response, and get the file from there
         // Response should be one XML file, and one binary
         $dp = new DIME($client->__getLastResponse());
         $images = array();
         foreach ($dp->files as $f) {
             $extension = explode('/', $f->type);
             if ($extension[0] == 'image') {
                 $ruta = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'imagenes' . DIRECTORY_SEPARATOR;
                 //$ruta = dirname(__FILE__).'/../../../../../web/imagenes/';
                 $filename = $ruta . $f->id;
                 file_put_contents($filename, $f->data);
                 continue;
             }
             if ($f->type_format == DIME::TYPE_BINARY) {
                 $result .= $f->data;
             }
         }
     }
     $result = str_replace('images/', '/imagenes/', $result);
     return $result;
 }
Example #22
0
 /**
  * The capture command is used to create requests for performing captures
  * on authorized payments. A merchant can choose to have it set up through
  * Docdata Payments back office to automatically have the full
  * authorization amount captured for each payment after a configured delay.
  *The capture command can then be used to overwrite this default capture.
  * If no default capture is configured, a merchant should use the capture
  * command to create one.
  *
  * @param string           $paymentId
  * @param string|null      $merchantCaptureReference
  * @param Type\Amount|null $amount
  * @param string|null      $itemCode
  * @param string|null      $description
  * @param bool|null        $finalCapture
  * @param bool|null        $cancelReserved
  * @param string|null      $requiredCaptureDate
  *
  * @return Type\CaptureSuccess
  *
  * @throws \Exception
  */
 public function capture($paymentId, $merchantCaptureReference = null, Type\Amount $amount = null, $itemCode = null, $description = null, $finalCapture = null, $cancelReserved = null, $requiredCaptureDate = null)
 {
     $request = new Type\CaptureRequest();
     $request->setMerchant($this->merchant);
     $request->setPaymentId($paymentId);
     if ($merchantCaptureReference !== null) {
         $request->setMerchantCaptureReference($merchantCaptureReference);
     }
     if ($amount !== null) {
         $request->setAmount($amount);
     }
     if ($itemCode !== null) {
         $request->setItemCode($itemCode);
     }
     if ($description !== null) {
         $request->setDescription($description);
     }
     if ($finalCapture !== null) {
         $request->setFinalCapture($finalCapture);
     }
     if ($cancelReserved !== null) {
         $request->setCancelReserved($cancelReserved);
     }
     if ($requiredCaptureDate !== null) {
         $request->setRequiredCaptureDate($requiredCaptureDate);
     }
     // make the call
     $this->logger->info("Payment capture: " . $merchantCaptureReference, (array) $request->toArray());
     $response = $this->soap('capture', [$request->toArray()]);
     $this->logger->info("Payment capture soap request: " . $merchantCaptureReference, (array) $this->soapClient->__getLastRequest());
     $this->logger->info("Payment capture soap response: " . $merchantCaptureReference, (array) $this->soapClient->__getLastResponse());
     // validate response
     if (isset($response->captureError)) {
         if ($this->test) {
             var_dump($this->soapClient->__getLastRequest());
         }
         $this->logger->error("Payment capture: " . $merchantCaptureReference, (array) $response->captureError->getError()->getExplanation());
         throw new \Exception($response->captureError->getError()->getExplanation());
     }
     return $response->captureSuccess;
 }
Example #23
0
 function Image2PdfConvert()
 {
     if ($this->apiKey == "") {
         return "Please specify ApiKey";
     }
     if ($this->outputPdfLocation == "") {
         return "Please specify Output pdf File Location";
     }
     if ($this->inputImageLocation == "") {
         return "Please specify input Image Location";
     } else {
         $fileStream = file_get_contents($this->inputImageLocation);
     }
     $parameters = array("FileByteStream" => $fileStream);
     $wsdl = "http://apis.pdfaid.com/pdfaidservices/Service1.svc?wsdl";
     $endpoint = "http://apis.pdfaid.com/pdfaidservices/Service1.svc";
     $option = array('trace' => 1);
     $client = new SoapClient($wsdl, $option);
     $headers[] = new SoapHeader('http://tempuri.org/', 'apikey', $this->apiKey);
     $headers[] = new SoapHeader('http://tempuri.org/', 'imageQuality', $this->imageQuality);
     $headers[] = new SoapHeader('http://tempuri.org/', 'pdfTitle', $this->pdfTitle);
     $headers[] = new SoapHeader('http://tempuri.org/', 'pdfAuthor', $this->pdfAuthor);
     $headers[] = new SoapHeader('http://tempuri.org/', 'pdfSubject', $this->pdfSubject);
     $headers[] = new SoapHeader('http://tempuri.org/', 'pdfKeywords', $this->pdfKeywords);
     $headers[] = new SoapHeader('http://tempuri.org/', 'responseResult', "test");
     $client->__setSoapHeaders($headers);
     $result = $client->Image2Pdf($parameters);
     $clientResponse = $client->__getLastResponse();
     if ($clientResponse == "APINOK") {
         return "API is not Valid";
     }
     if ($clientResponse == "NOK") {
         return "Error Occured";
     } else {
         $fp = fopen($this->outputPdfLocation, 'wb');
         fwrite($fp, $result->FileByteStream);
         fclose($fp);
         return "OK";
     }
 }
<?php

require 'soap_config.php';
$client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1));
try {
    if ($session_id = $client->login($username, $password)) {
        echo 'Logged successfull. Session ID:' . $session_id . '<br />';
    }
    //* Set the function parameters.
    $client_id = 1;
    $params = array('server_id' => 1, 'parent_domain_id' => 1, 'username' => 'tom', 'password' => 'secret', 'quota_size' => 10000, 'active' => 'y', 'uid' => '5000', 'gid' => '5000', 'dir' => '/home/www/clients/client0/web1', 'quota_files' => -1, 'ul_ratio' => -1, 'dl_ratio' => -1, 'ul_bandwidth' => -1, 'dl_bandwidth' => -1);
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params);
    echo "FTP User ID: " . $affected_rows . "<br>";
    if ($client->logout($session_id)) {
        echo 'Logged out.<br />';
    }
} catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: ' . $e->getMessage());
}
Example #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)));
}
        }
        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";
}
Example #27
0
	$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());
    
  }
echo "\n</pre>\n"; 
?>
try {
    $cliente = new SoapClient(null, array('location' => $url, 'uri' => $uri));
    echo "Nombre de la receta 1 :<br>" . $cliente->obtieneNombreReceta(1);
    print "<br><br>";
    echo 'Preparacion de la receta 1 :<br>';
    echo $cliente->obtener_preparacion_receta(1);
    print "<br><br>";
    echo "Presentacion de la receta 1 :<br>";
    echo $cliente->obtener_presentacion_receta(1);
    print "<br><br>";
    echo "Lista de ingredientes de la receta 1 (es un array de string) :<br>";
    print_r($cliente->obtener_array_ingredientes_receta(1));
    print "<br><br>";
} catch (Exception $ex) {
    echo $ex->getMessage();
    print $cliente->__getLastResponse();
}
try {
    echo "Todos los ingredientes de la BD en un Array:<br>";
    print_r($cliente->obtener_ingredientes());
    print "<br><br>";
    echo "Todas las recetas en un Array:<br>";
    print_r($cliente->obtener_recetas());
    print "<br><br>";
} catch (Exception $ex) {
    echo $ex->getMessage();
    print $cliente->__getLastResponse();
}
?>
    </body>
</html>
 /**
  * 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;
     }
 }
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
if ($argc < 2) {
    die("Usage: " . $argv[0] . " group_id tracker_id \n");
}
$serverURL = isset($_SERVER['TULEAP_SERVER']) ? $_SERVER['TULEAP_SERVER'] : 'http://sonde.cro.enalean.com';
$login = isset($_SERVER['TULEAP_USER']) ? $_SERVER['TULEAP_USER'] : '******';
$password = isset($_SERVER['TULEAP_PASSWORD']) ? $_SERVER['TULEAP_PASSWORD'] : '******';
// Establish connexion to the server
$soapLogin = new SoapClient($serverURL . '/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$requesterSessionHash = $soapLogin->login($login, $password)->session_hash;
$group_id = $argv[1];
$tracker_id = $argv[2];
// Connecting to the soap's tracker client
$soapTracker = new SoapClient($serverURL . '/plugins/tracker/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
//Executing method getTrackerSemantic
try {
    $response = $soapTracker->getTrackerStructure($requesterSessionHash, $group_id, $tracker_id);
    var_dump($response);
} catch (Exception $e) {
    var_dump($soapTracker->__getLastResponse());
}
$soapLogin->logout($requesterSessionHash);