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; } }
public function getParametersNames($wsdlUri, $operation) { global $prefs; $parameters = array(); if (!$wsdlUri || !$operation) { return $parameters; } $context = null; if ($prefs['use_proxy'] == 'y' && !strpos($wsdlUri, 'localhost')) { // Use proxy $context = stream_context_create(array('http' => array('proxy' => $prefs['proxy_host'] . ':' . $prefs['proxy_port'], 'request_fulluri' => true))); } // Copy content in cache $wsdl_data = file_get_contents($wsdlUri, false, $context); if (!isset($wsdl_data) || empty($wsdl_data)) { trigger_error(tr("No WSDL found")); return array(); } $wsdlFile = $GLOBALS['tikipath'] . 'temp/cache/' . md5($wsdlUri); file_put_contents($wsdlFile, $wsdl_data); // Read wsdl from local copy $wsdl = new wsdl('file:' . $wsdlFile); if (!empty($wsdl->error_str)) { trigger_error($wsdl->error_str); return $parameters; } $data = $wsdl->getOperationData($operation); if (isset($data['input']['parts'])) { foreach ($data['input']['parts'] as $parameter => $type) { preg_match('/^(.*)\\:(.*)\\^?$/', $type, $matches); if (count($matches) == 3 && ($typeDef = $wsdl->getTypeDef($matches[2], $matches[1]))) { if (isset($typeDef['elements'])) { foreach ($typeDef['elements'] as $element) { $parameters[] = $typeDef['name'] . ':' . $element['name']; } } } else { $parameters[] = $parameter; } } } return $parameters; }
* 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); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
/** * Test output WSDL when registering a web service function with no output parameters. */ public function test_register_without_output() { $this->resetAfterTest(); $serviceclass = 'testserviceclass'; $namespace = 'testnamespace'; $wsdl = new wsdl($serviceclass, $namespace); $functionname = 'testfunction'; $documentation = 'This is a test function'; $in = array('return' => array('type' => 'teststruct2')); $wsdl->register($functionname, $in, null, $documentation); $definitions = new \SimpleXMLElement($wsdl->to_xml()); // Test portType operation node. $porttypeoperation = $definitions->portType->operation; $this->assertEquals($documentation, $porttypeoperation->documentation); $this->assertTrue(isset($porttypeoperation->input)); $this->assertFalse(isset($porttypeoperation->output)); // Test binding operation nodes. $bindingoperation = $definitions->binding->operation; // Confirm that there is no input node. $this->assertTrue(isset($bindingoperation->input)); $this->assertFalse(isset($bindingoperation->output)); // Test messages. // Assert there's only the output message node. $this->assertEquals(1, count($definitions->message)); $messagein = $definitions->message[0]; $this->assertEquals($functionname . wsdl::IN, $messagein->attributes()->name); }
<?php /* ****************************** * WSDL aJax actions * ****************************** */ set_time_limit(0); include '../../includes/classes/core.php'; include '../../includes/classes/wsdl.class.php'; include '../../includes/classes/logger.class.php'; $action = $_REQUEST['act']; $error = ''; $data = ''; $properties = GetCompanyProperties(); $wsdl = new wsdl('http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL', 'mplus:406137014', '123456'); $_log = Logger::instance('../../log/wsdl/wsdl/', Logger::OFF); switch ($action) { case 'sync': $array = array("create_date_s" => $_REQUEST['create_date_s'], "create_date_e" => $_REQUEST['create_date_e'], "waybill_number" => $_REQUEST['waybill_number'], "seller_tin" => $_REQUEST['seller_tin']); $array = array_diff($array, array('')); if (empty($array)) { $error = 'შეავსეთ სინქრონიზაციისათვის აუცილებელი ველი(ები)!'; } else { $params = arrayToObject($array); $arr = $wsdl->get_buyer_waybills($params); for ($i = 0; $i < count($arr); $i++) { $wsdl->set_waybill_id($arr[$i]); $wsdl->get_waybill(1); } $arr = $wsdl->get_waybills($params); for ($i = 0; $i < count($arr); $i++) {
/** * Return the list of the operation of the WSDL * * @return array An array who contains all the operation of the WSDL */ public function __getFunctions() { $wsdl = new wsdl($this->wsdl); $operations = $wsdl->getOperations(); $return = array(); foreach ($operations as $_operation) { $output = $_operation['output']['parts']; $output_type = 'void'; if (array_key_exists('return', $output)) { $output_type = end(explode(':', $output['return'])); } $name = $_operation['name']; $input = array(); foreach ($_operation['input']['parts'] as $_param => $_type) { $input[] = end(explode(':', $_type)) . ' $' . $_param; } $input = join(', ', $input); $return[] = "{$output_type} {$name}({$input})"; } return $return; }
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); } }
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'); } }
/** * 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; }
<?php require_once '../../includes/classes/core.php'; require_once '../../includes/classes/wsdl.class.php'; $wsdl = new wsdl('http://192.168.215.30/services/public/callcentersupportservice.asmx?wsdl', 'CallCenter', '2cc4541a13009ba5da9b90a146d10369', '192.168.200.145', 'lasha', 'index.php'); $data = ''; $action = $_REQUEST['act']; switch ($action) { case 'pin': $pin = $_REQUEST['pin']; $pid = $_REQUEST['pid']; $tt = $wsdl->SearchClient($pin, $pid); $page = $wsdl->GenerateRedirect($tt); if ($tt) { $data = array('page' => $page); } else { $data = array('page' => 'error'); } break; case 'phone': $phone = $_REQUEST['phone']; $result = $wsdl->SearchClientByPhone($phone); if ($result[0]) { $page = $wsdl->GenerateRedirect($result[1]); $data = array('page' => $page, 'status' => 'true'); } else { $data = array('status' => 'false'); } break; case 'check_group': $result = $wsdl->GetRolesList();