function inicializarWebService()
 {
     $proxy = array();
     $proxy['server'] = !is_null($this->proxy) ? $this->proxy->server : false;
     $proxy['port'] = !is_null($this->proxy) ? $this->proxy->port : false;
     $proxy['username'] = !is_null($this->proxy) ? $this->proxy->username : false;
     $proxy['password'] = !is_null($this->proxy) ? $this->proxy->password : false;
     $client = new nusoap_client($this->configuracao->wsdl, false, $proxy['server'], $proxy['port'], $proxy['username'], $proxy['password'], 0, 3000);
     $client->setDebugLevel(9);
     $client->setUseCURL(true);
     if (!is_null($this->certificado)) {
         if (strlen($this->certificado->crt . $this->certificado->key . $this->certificado->pem) > 0) {
             $client->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
             $client->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
             $client->authtype = 'certificate';
             if (strlen($this->certificado->crt) > 0) {
                 $client->certRequest['sslcertfile'] = $this->certificado->crt;
                 # file containing the user's certificate
             }
             if (strlen($this->certificado->key) > 0) {
                 $client->certRequest['sslkeyfile'] = $this->certificado->key;
                 # file containing the private key
             }
             if (strlen($this->certificado->pem) > 0) {
                 $client->certRequest['cainfofile'] = $this->certificado->pem;
                 # file containing the root certificate
             }
         }
     }
     $this->client = $client;
 }
Esempio n. 2
0
$libpath = api_get_path(LIBRARY_PATH);
// Create the client instance
$url = api_get_path(WEB_CODE_PATH) . "webservices/registration.soap.php?wsdl";
//$url = api_get_path(WEB_CODE_PATH)."webservices/access_url.php?wsdl";
// see the main/inc/configuration.php file to get this value
$security_key = api_get_configuration_value('security_key');
$client = new nusoap_client($url, true);
/*$client->xml_encoding = 'UTF-8';
$client->http_encoding = 'UTF-8';
$client->charencoding = 'UTF-8';*/
$soap_error = $client->getError();
if (!empty($soap_error)) {
    $error_message = 'Nusoap object creation failed: ' . $soap_error;
    throw new Exception($error_message);
}
$client->setDebugLevel(10000);
$client->debug_flag = true;
// This should be the IP address of the client
$ip_address = $_SERVER['SERVER_ADDR'];
$ip_address = "192.168.1.54";
$ip_address = "127.0.0.1";
//Secret key
$secret_key = sha1($ip_address . $security_key);
// Hash of the combination of IP Address + Chamilo security key
//$secret_key = sha1($security_key);
//Creating a random user_id, this values need to be provided from your system
$random_user_id = rand(0, 1000);
//Creating a random username this values need to be provided from your system
$generate_user_name = 'jbrion' . $random_user_id;
//Creating a password (the username)
$generate_password = sha1($generate_user_name);
<?php

$days = 1;
// how much days add to current
define('ROOT_DIR', './');
require_once ROOT_DIR . 'nusoap/lib/nusoap.php';
$wsdlurl = "http://soap.direct.yandex.ru/wsdl/v4/";
$client = new nusoap_client($wsdlurl, 'wsdl');
$client->authtype = 'certificate';
$client->decode_utf8 = 0;
$client->soap_defencoding = 'UTF-8';
$client->certRequest['sslcertfile'] = './cert.crt';
$client->certRequest['sslkeyfile'] = './private.key';
$client->certRequest['cainfofile'] = './cacert.pem';
$client->setDebugLevel(9);
function addzero($s)
{
    if (strlen($s) < 2) {
        $s = '0' . $s;
    }
    return $s;
}
$rows = $client->call('GetCampaignsList', array());
mb_internal_encoding('utf8');
foreach ($rows as $item) {
    if ($item['StatusArchive'] == 'Yes' || $item['StatusModerate'] == 'Pending' || $item['StatusActivating'] == 'Pending') {
        continue;
    }
    $cid = $item['CampaignID'];
    $params = array('CampaignIDS' => array($cid), 'GetPhrases' => 'WithPrices');
    $attempts = 3;
Esempio n. 4
0
 /**
  * Internal utility methods
  */
 private function call($service, $method, $params)
 {
     ini_set('memory_limit', '1024M');
     ini_set('max_execution_time', 1800);
     set_time_limit(0);
     $url = $this->wsdl_root . $service . '.asmx?wsdl';
     $timeout = 3000;
     $cache = new nusoap_wsdlcache($this->cache_dir, $timeout);
     $wsdl = $cache->get($url);
     // Set the WSDL
     if (is_null($wsdl)) {
         $wsdl = new wsdl($url, NULL, NULL, NULL, NULL, 0, $timeout, NULL, TRUE);
         $error = $wsdl->getError();
         $debug = $wsdl->getDebug();
         $wsdl->clearDebug();
         // Check for SOAP errors
         if (!empty($error)) {
             $this->errors[] = $error;
             if ($debug) {
                 $this->errors[] = '<pre>' . print_r($debug, TRUE) . '</pre>';
             }
             return FALSE;
         }
         $cache->put($wsdl);
     }
     // Send the SOAP request
     $params['securityPassword'] = $this->wsdl_keys[$service];
     $client = new nusoap_client($wsdl, 'wsdl', FALSE, FALSE, FALSE, FALSE, 0, $timeout);
     $client->setDebugLevel(0);
     // 0 - 9, where 0 is off
     $client->useHTTPPersistentConnection();
     if ($service == 'DataAccess' && $method == 'ExecuteStoredProcedure') {
         /*
          * See http://www.codingforums.com/archive/index.php/t-85260.html
          * and http://users.skynet.be/pascalbotte/rcx-ws-doc/nusoapadvanced.htm
          * for how to thwart the "got wsdl error: phpType is struct, but value is not an array"
          * error returned by nusoap when processing the response from $client->call()
          *
          * */
         $request = $client->serializeEnvelope(vsprintf('<ExecuteStoredProcedure xmlns="http://ibridge.isgsolutions.com/%s/">
                   <securityPassword>%s</securityPassword>
                   <name>%s</name>
                   <parameters>%s</parameters>
                   </ExecuteStoredProcedure>', array($service, $params['securityPassword'], $params['name'], $params['parameters'])));
         $response = $client->send($request, 'http://ibridge.isgsolutions.com/' . $service . '/' . $method, 0, $timeout);
     } else {
         $response = $client->call($method, $params);
     }
     $error = $client->getError();
     $debug = $client->getDebug();
     $client->clearDebug();
     // Check for SOAP errors
     if (!empty($error)) {
         $this->errors[] = $error;
         if ($debug) {
             $this->errors[] = '<pre>' . print_r($debug, TRUE) . '</pre>';
         }
         return FALSE;
     }
     // Process response
     $response = $response[$method . 'Result'];
     $data = NULL;
     if (strpos($response, '<') == 0) {
         // Some ISGweb methods return strings instead of XML
         libxml_use_internal_errors(TRUE);
         $response = preg_replace('/(<\\?xml[^?]+?)utf-16/i', '$1utf-8', $response);
         // Change encoding string to UTF8
         $response = utf8_encode($response);
         $response = $this->strip_invalid_xml($response);
         $obj = simplexml_load_string($response);
         $data = $response;
         $error = libxml_get_errors();
         // Check for XML parsing errors
         if (!empty($error)) {
             foreach ($error as $e) {
                 $this->errors[] = $e;
             }
             libxml_clear_errors();
             return FALSE;
         }
         $data = $this->object_to_array($obj);
         // Check for ISGweb errors (e.g. invalid data input, failure of service, etc.)
         if (array_key_exists('Errors', $data)) {
             $error = $data['Errors'];
             foreach ($error as $e) {
                 $this->errors[] = $e['@attributes']['Description'];
             }
             return FALSE;
         }
     } else {
         $data = $response;
     }
     return $data;
 }
Esempio n. 5
-22
function inicializarWebServiceSOF($configuracao)
{
    $proxy = ConfigWs::factory()->getSiopProxyConfig();
    $client = new nusoap_client($configuracao['wsdl_url'], false, $proxy['server'], $proxy['port'], $proxy['username'], $proxy['password'], 0, 3000);
    $client->setDebugLevel(9);
    $client->setUseCURL(true);
    // Verifica se há algum dado de configuração para certificado.
    // Caso houver define o tipo de autenticação para certificate.
    $certificado = ConfigWs::factory()->getSiopCertificateConfig();
    if (strlen($certificado['crt'] . $certificado['key'] . $certificado['pem']) > 0) {
        $client->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
        $client->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
        $client->authtype = 'certificate';
        if (strlen($certificado['crt']) > 0) {
            $client->certRequest['sslcertfile'] = $certificado['crt'];
            # file containing the user's certificate
        }
        if (strlen($certificado['key']) > 0) {
            $client->certRequest['sslkeyfile'] = $certificado['key'];
            # file containing the private key
        }
        if (strlen($certificado['pem']) > 0) {
            $client->certRequest['cainfofile'] = $certificado['pem'];
            # file containing the root certificate
        }
    }
    return $client;
}