function InitTransport($wsdlUrl) { // instantiate wsdl cache manager $cache_use = (bool) Configuration::Instance()->GetValue('application', 'wsdl_use_cache'); $cache_path = file_exists(Configuration::Instance()->GetValue('application', 'wsdl_cache_path')) ? Configuration::Instance()->GetValue('application', 'wsdl_cache_path') : Configuration::Instance()->GetValue('application', 'session_save_path'); // paranoia check, if session_save_path set to NULL $cache_path = file_exists($cache_path) ? $cache_path : ini_get('session.save_path'); // $cache_lifetime = Configuration::Instance()->GetValue('application', 'wsdl_cache_lifetime') != '' ? (int) Configuration::Instance()->GetValue('application', 'wsdl_cache_lifetime') : 60 * 60 * 24; // defaults to 1 day if ($cache_path != '' && $cache_use) { $wsdl_cache = new wsdlcache($cache_path, $cache_lifetime); } // try to get from cache first... if ($wsdl_cache) { $wsdl = $wsdl_cache->get($wsdlUrl); } // cache hit? if not, get it from server and put to cache if (!$wsdl) { $wsdl = new wsdl($wsdlUrl, $this->mProxyHost, $this->mProxyPort, $this->mProxyUser, $this->mProxyPass); if ($wsdl_cache && !$wsdl->getError()) { $wsdl_cache->put($wsdl); } } $this->mTransport = new soapclient($wsdl, TRUE, $this->mProxyHost, $this->mProxyPort, $this->mProxyUser, $this->mProxyPass); }
public function Connect() { // instantiate wsdl cache manager if ($this->mDbConfig['db_wsdl_cache_path'] != '' && $this->mDbConfig['db_wsdl_cache_enabled']) { $wsdl_cache = new wsdlcache($this->mDbConfig['db_wsdl_cache_path'], $this->mDbConfig['db_wsdl_cache_lifetime']); } // try to get from cache first... $wsdl_url = $this->mDbConfig['db_wsdl_url']; if ($this->mDbConfig['db_namespace']) { $wsdl_url_query = parse_url($wsdl_url, PHP_URL_QUERY); if (!$wsdl_url_query) { $wsdl_url .= '?nspace=' . $this->mDbConfig['db_namespace']; } else { $wsdl_url .= '&nspace=' . $this->mDbConfig['db_namespace']; } } if ($wsdl_cache) { $wsdl = $wsdl_cache->get($wsdl_url); } // cache hit? if not, get it from server and put to cache if (!$wsdl) { SysLog::Log('Cache MISSED: ' . $wsdl_url, 'SoapDatabaseEngine'); $wsdl = new wsdl($wsdl_url, $this->mDbConfig['db_proxy_host'], $this->mDbConfig['db_proxy_port'], $this->mDbConfig['db_proxy_user'], $this->mDbConfig['db_proxy_pass'], $this->mDbConfig['db_connection_timeout'], $this->mDbConfig['db_response_timeout']); $this->mErrorMessage = $wsdl->getError(); if ($this->mErrorMessage) { SysLog::Log('WSDL error: ' . $this->mErrorMessage, 'DatabaseEngine'); $this->mErrorMessage = 'An error has occured when instantiating WSDL object (' . $this->mDbConfig['db_wsdl_url'] . '&nspace=' . $this->mDbConfig['db_namespace'] . '). The error was: "' . $this->mErrorMessage . '" Check your WSDL document or database configuration.'; return FALSE; } if ($wsdl_cache) { $wsdl_cache->put($wsdl); } } else { SysLog::Log('Cache HIT: ' . $this->mDbConfig['db_wsdl_url'] . '&nspace=' . $this->mDbConfig['db_namespace'], 'SoapDatabaseEngine'); } // use it as usual $temp = new soapclient($wsdl, TRUE, $this->mDbConfig['db_proxy_host'], $this->mDbConfig['db_proxy_port'], $this->mDbConfig['db_proxy_user'], $this->mDbConfig['db_proxy_pass'], $this->mDbConfig['db_connection_timeout'], $this->mDbConfig['db_response_timeout']); $this->mErrorMessage = $temp->getError(); if (!$this->mErrorMessage) { $this->mrDbConnection = $temp->getProxy(); if (isset($this->mDbConfig['db_credentials'])) { $this->mrDbConnection->setCredentials($this->mDbConfig['db_credentials']['user'], $this->mDbConfig['db_credentials']['pass'], $this->mDbConfig['db_credentials']['type'], $this->mDbConfig['db_credentials']['cert']); } return TRUE; } else { SysLog::Log('Error in SoapDatabaseEngine: ' . $temp->getError(), 'SoapDatabaseEngine'); return FALSE; } }
function _feed_stockbiz($method, $url, $params, $debug = true) { global $_services; require_once _NUSOAP_ABSPATH_ . 'nusoap.php'; require_once _NUSOAP_ABSPATH_ . 'class.wsdlcache.php'; $cache = new wsdlcache(_NUSOAP_CACHE_, 0); $wsdl = $cache->get($url); if (is_null($wsdl)) { $wsdl = new wsdl($url); $cache->put($wsdl); } else { $wsdl->clearDebug(); } $client = new nusoap_client($wsdl, true); $client->decode_utf8 = false; $client->setUseCurl(false); $result = $client->call($method, $params); if ($client->fault) { if ($debug) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } } else { if ($err = $client->getError()) { if ($debug) { echo '<h2>Error</h2><pre>' . $err . '</pre>'; } } else { if (!empty($result)) { return $result; } } } return false; }
* * WSDL client sample. * * Service: WSDL * Payload: rpc/encoded * Transport: http * Authentication: none */ require_once '../lib/nusoap.php'; require_once '../lib/class.wsdlcache.php'; $proxyHost = isset($_POST['proxyHost']) ? $_POST['proxyHost'] : ''; $proxyPort = isset($_POST['proxyPort']) ? $_POST['proxyPort'] : ''; $proxyUsername = isset($_POST['proxyUsername']) ? $_POST['proxyUsername'] : ''; $proxyPassword = isset($_POST['proxyPassword']) ? $_POST['proxyPassword'] : ''; $useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0'; $cache = new wsdlcache('.', 60); $wsdl = $cache->get('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl'); if (is_null($wsdl)) { $wsdl = new wsdl('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl', $proxyHost, $proxyPort, $proxyUsername, $proxyPassword, 0, 30, null, $useCURL); $err = $wsdl->getError(); if ($err) { echo '<h2>WSDL Constructor error (Expect - 404 Not Found)</h2><pre>' . $err . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($wsdl->getDebug(), ENT_QUOTES) . '</pre>'; exit; } $cache->put($wsdl); } else { $wsdl->clearDebug(); $wsdl->debug('Retrieved from cache'); } $client = new nusoap_client($wsdl, 'wsdl', $proxyHost, $proxyPort, $proxyUsername, $proxyPassword);
* * Service: WSDL * Payload: document/literal * Transport: http * Authentication: none */ require_once '../lib/nusoap.php'; require_once '../lib/class.wsdlcache.php'; $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : ''; $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : ''; $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : ''; $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : ''; $method = isset($_GET['method']) ? $_GET['method'] : 'ItemSearch'; $SubscriptionId = 'Your AWS subscription id'; $wsdlurl = 'http://webservices.amazon.com/AWSECommerceService/US/AWSECommerceService.wsdl'; $cache = new wsdlcache('.', 120); $wsdl = $cache->get($wsdlurl); if (is_null($wsdl)) { $wsdl = new wsdl($wsdlurl, $proxyhost, $proxyport, $proxyusername, $proxypassword); $cache->put($wsdl); } else { $wsdl->debug_str = ''; $wsdl->debug('Retrieved from cache'); } $client = new nusoap_client($wsdl, true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $client->soap_defencoding = 'UTF-8'; function GetCartCreateParams()
* $Id: wsdlclient5.php,v 1.3 2004/02/23 19:22:19 snichol Exp $ * * WSDL client sample. * * Service: WSDL * Payload: rpc/encoded * Transport: http * Authentication: none */ require_once '../lib/nusoap.php'; require_once '../lib/class.wsdlcache.php'; $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : ''; $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : ''; $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : ''; $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : ''; $cache = new wsdlcache('.', 60); $wsdl = $cache->get('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl'); if (is_null($wsdl)) { $wsdl = new wsdl('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword); $cache->put($wsdl); } else { $wsdl->debug_str = ''; $wsdl->debug('Retrieved from cache'); } $client = new soapclient($wsdl, true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $params = array('isbn' => '0060188782'); $result = $client->call('getPrice', $params);
private function RegisterServiceByWsdlConfig($wsdlConfig = NULL) { if (!$wsdlConfig) { return FALSE; } if ($wsdlConfig['location'] == 'remote') { if ($this->mUseWsdlCache) { $wsdl_cache = new wsdlcache($this->mWsdlCachePath, $this->mWsdlCacheLifetime); } // try to get from cache first... if ($wsdl_cache) { $wsdl = $wsdl_cache->get($wsdlConfig['address']); } // cache hit? if not, get it from server and put to cache if (!$wsdl) { $wsdl = new wsdl($wsdlConfig['address'], $wsdlConfig['proxy_host'], $wsdlConfig['proxy_port'], $wsdlConfig['proxy_user'], $wsdlConfig['proxy_pass']); $error = $wsdl->getError(); if ($error) { SysLog::Log('An error occured when fecthing wsdl from ' . $wsdlConfig['address'] . ': ' . $error, 'wsdlgenerator'); } if ($wsdl_cache && !$error) { $wsdl_cache->put($wsdl); } } if (!$error) { $this->RegisterServiceByWsdlObject($wsdl); } } elseif ($wsdlConfig['location'] == 'local') { $this->RegisterServiceBySoapClass($wsdlConfig); } }
/** * @throws RussianPostApiException * @return \nusoap_client */ protected function initClient() { $cache = new \wsdlcache('.', 120); $wsdl = $cache->get($this->wsdlEndpoint); if (is_null($wsdl)) { $wsdl = new \wsdl($this->wsdlEndpoint); $cache->put($wsdl); } else { $wsdl->debug_str = ''; $wsdl->debug('Retrieved from cache'); } $client = new \nusoap_client($wsdl, true); $client->soap_defencoding = 'UTF-8'; $client->decode_utf8 = false; $err = $client->getError(); if ($err) { throw new RussianPostApiException($err); } return $client; }
protected function importWsdlUrl($wsdl_url, $proxy_host = '', $proxy_port = '', $proxy_user = '', $proxy_pass = '') { SysLog::Instance()->log("importing from {$wsdl_url}", 'soapgateway'); // instantiate wsdl cache manager $cache_use = (bool) Configuration::Instance()->GetValue('application', 'wsdl_use_cache'); $cache_path = file_exists(Configuration::Instance()->GetValue('application', 'wsdl_cache_path')) ? Configuration::Instance()->GetValue('application', 'wsdl_cache_path') : Configuration::Instance()->GetTempDir(); $cache_lifetime = Configuration::Instance()->GetValue('application', 'wsdl_cache_lifetime') != '' ? (int) Configuration::Instance()->GetValue('application', 'wsdl_cache_lifetime') : 60 * 60 * 24; // defaults to 1 day if ($cache_path != '' && $cache_use) { $wsdl_cache = new wsdlcache($cache_path, $cache_lifetime); } // try to get from cache first... if ($wsdl_cache) { $wsdl = $wsdl_cache->get($wsdl_url); } // cache hit? if not, get it from server and put to cache if (!$wsdl) { $wsdl = new wsdl($wsdl_url, $proxy_host, $proxy_port, $proxy_user, $proxy_pass); if ($wsdl_cache && !$wsdl->getError()) { $wsdl_cache->put($wsdl); } } if (is_object($wsdl) && !$wsdl->getError()) { // adjustment: re-encode URL, since after importing somewhoe it won't be escaped anymore thus yields in invalid xml if (count($wsdl->ports) >= 1) { foreach ($wsdl->ports as $pName => $attrs) { if (preg_match('/(.*)?\\?(.*)/', $attrs['location'], $found)) { $main_url = $found[1]; $query_str = $found[2]; if (!empty($query_str)) { $main_url .= '?'; } } else { $main_url = $attrs; $query_str = ''; } $wsdl->ports["{$pName}"]['location'] = $main_url . htmlentities($query_str); } } $this->importWsdlObject($wsdl); } else { SysLog::Instance()->log("Unable to read wsdl from url: {$wsdl_url}", 'soapgateway'); } }