function check_now($send_usage_info = true, $get_request_data = false, $response_data = false, $from_install = false) { global $sugar_config, $timedate; global $db, $license; $return_array = array(); if (!$from_install && empty($license)) { loadLicense(true); } if (!$response_data) { if ($from_install) { $info = getBaseSystemInfo(false); } else { $info = getSystemInfo($send_usage_info); } require_once 'include/nusoap/nusoap.php'; $GLOBALS['log']->debug('USING HTTPS TO CONNECT TO HEARTBEAT'); $sclient = new nusoapclient('https://updates.sugarcrm.com/heartbeat/soap.php', false, false, false, false, false, 15, 15); $ping = $sclient->call('sugarPing', array()); if (empty($ping) || $sclient->getError()) { $sclient = ''; } if (empty($sclient)) { $GLOBALS['log']->debug('USING HTTP TO CONNECT TO HEARTBEAT'); $sclient = new nusoapclient('http://updates.sugarcrm.com/heartbeat/soap.php', false, false, false, false, false, 15, 15); } $key = '4829482749329'; $encoded = sugarEncode($key, serialize($info)); if ($get_request_data) { $request_data = array('key' => $key, 'data' => $encoded); return serialize($request_data); } $encodedResult = $sclient->call('sugarHome', array('key' => $key, 'data' => $encoded)); } else { $encodedResult = $response_data['data']; $key = $response_data['key']; } if ($response_data || !$sclient->getError()) { $serializedResultData = sugarDecode($key, $encodedResult); $resultData = unserialize($serializedResultData); if ($response_data && empty($resultData)) { $resultData = array(); $resultData['validation'] = 'invalid validation key'; } } else { $resultData = array(); $resultData['versions'] = array(); } if ($response_data || !$sclient->getError()) { if (!empty($resultData['msg'])) { if (!empty($resultData['msg']['admin'])) { $license->saveSetting('license', 'msg_admin', base64_encode($resultData['msg']['admin'])); } else { $license->saveSetting('license', 'msg_admin', ''); } if (!empty($resultData['msg']['all'])) { $license->saveSetting('license', 'msg_all', base64_encode($resultData['msg']['all'])); } else { $license->saveSetting('license', 'msg_all', ''); } } else { $license->saveSetting('license', 'msg_admin', ''); $license->saveSetting('license', 'msg_all', ''); } $license->saveSetting('license', 'last_validation', 'success'); unset($_SESSION['COULD_NOT_CONNECT']); } else { $resultData = array(); $resultData['versions'] = array(); $license->saveSetting('license', 'last_connection_fail', TimeDate::getInstance()->nowDb()); $license->saveSetting('license', 'last_validation', 'no_connection'); if (empty($license->settings['license_last_validation_success']) && empty($license->settings['license_last_validation_fail']) && empty($license->settings['license_vk_end_date'])) { $license->saveSetting('license', 'vk_end_date', TimeDate::getInstance()->nowDb()); $license->saveSetting('license', 'validation_key', base64_encode(serialize(array('verified' => false)))); } $_SESSION['COULD_NOT_CONNECT'] = TimeDate::getInstance()->nowDb(); } if (!empty($resultData['versions'])) { $license->saveSetting('license', 'latest_versions', base64_encode(serialize($resultData['versions']))); } else { $resultData['versions'] = array(); $license->saveSetting('license', 'latest_versions', ''); } include 'sugar_version.php'; if (sizeof($resultData) == 1 && !empty($resultData['versions'][0]['version']) && $resultData['versions'][0]['version'] < $sugar_version) { $resultData['versions'][0]['version'] = $sugar_version; $resultData['versions'][0]['description'] = "You have the latest version."; } return $resultData['versions']; }
* * WSDL client sample. * * Service: WSDL * Payload: rpc/literal * Transport: http * Authentication: none */ require_once 'f:/nusoap/lib/nusoap.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'] : ''; echo '<h2>Constructor</h2>'; $client = new nusoapclient('http://www.scottnichol.com/samples/session.php?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; $client->clearDebug(); // A persistent connection is *optional*, *not* necessary $client->useHTTPPersistentConnection(); echo '<h2>GetSessionID</h2>'; $result = $client->call('GetSessionID', array()); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else {
require_once 'zimbra-nusoap.php'; require_once 'config.php'; if (!defined('STDERR')) { define('STDERR', fopen('php://stderr', 'w')); } function die_error($msg, $exit = 2) { if (is_array($msg)) { $msg = print_r($msg, true); } fwrite(STDERR, "ERROR:\n{$msg}\n"); exit($exit); } echo "=> Connecting to SugarCRM\n"; $soapClient = new nusoapclient($sugarURL . '/soap.php?wsdl', true, $proxyHost, $proxyPort); $err = $soapClient->getError(); if ($err) { die_error($err); } echo "=> Logging in to SugarCRM\n"; $auth_array = array('user_auth' => array('user_name' => $sugarUser, 'password' => md5($sugarPwd))); $login_results = $soapClient->call('login', $auth_array); $err = $soapClient->getError(); if ($err) { die_error($err); } $session = $login_results['id']; try { echo "=> Pulling contacts from SugarCRM\n"; $result = $soapClient->call('get_entry_list', array('session' => $session, 'module_name' => 'Contacts', 'query' => '', 'order_by' => 'contacts.first_name asc', 'offset' => 0, 'select_fields' => array(), 'max_results' => 100000)); $err = $soapClient->getError();
/** * * @param $par String subpage string, if one was specified */ function execute($par) { global $wgOut; global $wgRequest, $wgUser, $wgMemc; $MAX_RESULTS = 100; $CACHE_KEY_PREFIX = "LW_SOAP_FAILURES"; $CACHE_KEY_DATA = wfMemcKey($CACHE_KEY_PREFIX, "data"); $CACHE_KEY_TIME = wfMemcKey($CACHE_KEY_PREFIX, "cachedOn"); $CACHE_KEY_STATS = wfMemcKey($CACHE_KEY_PREFIX, "stats"); $wgOut->setPageTitle(wfMsg('soapfailures')); // This processes any requested for removal of an item from the list. if (isset($_POST['artist']) && isset($_POST['song'])) { $artist = $_POST['artist']; $song = $_POST['song']; $songResult = array(); $failedLyrics = "Not found"; /* GLOBAL $IP; define('LYRICWIKI_SOAP_FUNCS_ONLY', true); // so that we can use the SOAP functions but not actually instantiate a SOAP server & process a request. include_once 'server.php'; // the SOAP functions $songResult = getSong($artist, $song);*/ // Pull in the NuSOAP code $dir = dirname(__FILE__) . '/'; require_once $dir . 'nusoap.php'; // Create the client instance $wsdlUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/server.php?wsdl&1'; $PROXY_HOST = "127.0.0.1"; $PROXY_PORT = "6081"; // use local-varnish for the proxy $client = new nusoapclient($wsdlUrl, true, $PROXY_HOST, $PROXY_PORT); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } else { // Create the proxy $proxy = $client->getProxy(); global $LW_USERNAME, $LW_PASSWORD; if ($LW_USERNAME != "" || $LW_PASSWORD != "") { $headers = "<username>{$LW_USERNAME}</username><password>{$LW_PASSWORD}</password>\n"; $proxy->setHeaders($headers); } $songResult = $proxy->getSongResult($artist, $song); } if ($songResult['lyrics'] == $failedLyrics || $songResult['lyrics'] == "") { print "<html><head><title>Error</title></head><body>\n"; // TODO: i18n print '<div style="background-color:#fcc">Sorry, but ' . htmlspecialchars($artist) . ':' . htmlspecialchars($song) . " song still failed.</div>\n"; print_r($songResult); } else { $dbw = wfGetDB(DB_MASTER); print "<html><head><title>Success</title></head><body>\n"; // TODO: i18n print "Deleting record... "; $result = $dbw->delete('lw_soap_failures', ['request_artist' => $artist, 'request_song' => $song], __METHOD__); if ($result) { print "Deleted."; } else { print "Failed. " . mysql_error(); } print "<br/>Clearing the cache... "; $wgMemc->delete($CACHE_KEY_DATA); // purge the entry from memcached $wgMemc->delete($CACHE_KEY_TIME); $wgMemc->delete($CACHE_KEY_STATS); print "<div style='background-color:#cfc'>The song was retrieved successfully and "; print "was removed from the failed requests list."; print "</div>\n"; } global $wgScriptPath; print "<br/>Back to <a href='{$wgScriptPath}/Special:Soapfailures'>SOAP Failures</a>\n"; print "</body></html>"; exit; // wiki system throws database-connection errors if the page is allowed to display itself. } else { $wgOut->addHTML("<style type='text/css'>\n\t\t\t\ttable.soapfailures{\n\t\t\t\t\tborder-collapse:collapse;\n\t\t\t\t}\n\t\t\t\t.soapfailures tr.odd{background-color:#eef}\n\t\t\t\t.soapfailures td, .soapfailures th{\n\t\t\t\t\tborder:1px solid;\n\t\t\t\t\tcell-padding:0px;\n\t\t\t\t\tcell-spacing:0px;\n\t\t\t\t\tvertical-align:top;\n\t\t\t\t\tpadding:5px;\n\t\t\t\t}</style>\n"); // Allow the cache to be manually cleared. $msg = ""; if (isset($_GET['cache']) && $_GET['cache'] == "clear") { $msg .= "Forced clearing of the cache...\n"; $wgMemc->delete($CACHE_KEY_DATA); // purge the entry from memcached $wgMemc->delete($CACHE_KEY_TIME); $wgMemc->delete($CACHE_KEY_STATS); unset($_GET['cache']); $_SERVER['REQUEST_URI'] = str_replace("?cache=clear", "", $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = str_replace("&cache=clear", "", $_SERVER['REQUEST_URI']); } $msg = $msg == "" ? "" : "<pre>{$msg}</pre>"; $wgOut->addWikiText($msg); // Form for clearing a fixed song. $wgOut->addHTML(wfMsg('soapfailures-mark-as-fixed') . "\n\t\t\t\t\t\t\t<form method='post'>\n\t\t\t\t\t\t\t\t" . wfMsg('soapfailures-artist') . " <input type='text' name='artist'/><br/>\n\t\t\t\t\t\t\t\t" . wfMsg('soapfailures-song') . " <input type='text' name='song'/><br/>\n\t\t\t\t\t\t\t\t<input type='submit' name='fixed' value='" . wfMsg('soapfailures-fixed') . "'/>\n\t\t\t\t\t\t\t</form><br/>"); $data = $wgMemc->get($CACHE_KEY_DATA); $cachedOn = $wgMemc->get($CACHE_KEY_TIME); $statsHtml = $wgMemc->get($CACHE_KEY_STATS); if (!$data) { $db =& wfGetDB(DB_SLAVE)->getProperty('mConn'); $queryString = "SELECT * FROM lw_soap_failures ORDER BY numRequests DESC LIMIT {$MAX_RESULTS}"; if ($result = mysql_query($queryString, $db)) { $data = array(); if (($numRows = mysql_num_rows($result)) && $numRows > 0) { for ($cnt = 0; $cnt < $numRows; $cnt++) { $row = array(); $row['artist'] = mysql_result($result, $cnt, "request_artist"); $row['song'] = mysql_result($result, $cnt, "request_song"); $row['numRequests'] = mysql_result($result, $cnt, "numRequests"); $row['lookedFor'] = mysql_result($result, $cnt, "lookedFor"); $row['lookedFor'] = formatLookedFor($row['lookedFor']); $data[] = $row; } } } else { $wgOut->addHTML("<br/><br/><strong>Error: with query</strong><br/><em>{$queryString}</em><br/><strong>Error message: </strong>" . mysql_error($db)); } $cachedOn = date('m/d/Y \\a\\t g:ia'); } // Stats HTML is just an unimportant feature, hackily storing HTML instead of the data - FIXME: It's BAD to cache output rather than data. if (!$statsHtml) { // Display some hit-rate stats. ob_start(); include_once __DIR__ . "/soap_stats.php"; // for tracking success/failure print "<br/><br/><br/>"; print "<em>" . wfMsg('soapfailures-stats-header') . "</em><br/>\n"; print "<table border='1px' cellpadding='5px'>\n"; print "\t<tr><th>" . wfMsg('soapfailures-stats-timeperiod') . "</th><th>" . wfMsg('soapfailures-stats-numfound') . "</th><th>" . wfMsg('soapfailures-stats-numnotfound') . "</th><th> </th></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_DAILY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-today') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_WEEKLY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-thisweek') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_MONTHLY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-thismonth') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; print "</table>\n"; $statsHtml = ob_get_clean(); } if ($data) { $wgOut->addWikiText(wfMsg('soapfailures-intro')); $wgOut->addHTML("This page is cached every 2 hours - \n"); // TODO: i18n $wgOut->addHTML("last cached: <strong>{$cachedOn}</strong>\n"); // TODO: i18n $totFailures = 0; if (!empty($data)) { $wgOut->addHTML("<table class='soapfailures'>\n"); $wgOut->addHTML("<tr><th nowrap='nowrap'>" . wfMsg('soapfailures-header-requests') . "</th><th>" . wfMsg('soapfailures-header-artist') . "</th><th>" . wfMsg('soapfailures-header-song') . "</th><th>" . wfMsg('soapfailures-header-looked-for') . "</th><th>" . wfMsg('soapfailures-header-fixed') . "</th></tr>\n"); $REQUEST_URI = $_SERVER['REQUEST_URI']; $rowIndex = 0; foreach ($data as $row) { $artist = $row['artist']; $song = $row['song']; $numRequests = $row['numRequests']; $lookedFor = $row['lookedFor']; $totFailures += $numRequests; $wgOut->addHTML(utf8_encode("<tr" . ($rowIndex % 2 != 0 ? " class='odd'" : "") . "><td>{$numRequests}</td><td>")); $wgOut->addWikiText("[[{$artist}]]"); $wgOut->addHTML("</td><td>"); $wgOut->addWikiText("[[{$artist}:{$song}|{$song}]]"); $delim = "&"; $prefix = ""; // If the short-url is in the REQUEST_URI, make sure to add the index.php?title= prefix to it. if (strpos($REQUEST_URI, "index.php?title=") === false) { $prefix = "/index.php?title="; // If we're adding the index.php ourselves, but the request still started with a slash, remove it because that would break the request if it came after the "title=" if (substr($REQUEST_URI, 0, 1) == "/") { $REQUEST_URI = substr($REQUEST_URI, 1); } } $wgOut->addHTML("</td><td>"); $wgOut->addWikiText("{$lookedFor}"); $wgOut->addHTML("</td><td>"); $wgOut->addHTML("<form action='' method='POST' target='_blank'>\n\t\t\t\t\t\t\t\t<input type='hidden' name='artist' value=\"" . Sanitizer::encodeAttribute($artist) . "\"/>\n\t\t\t\t\t\t\t\t<input type='hidden' name='song' value=\"" . Sanitizer::encodeAttribute($song) . "\"/>\n\t\t\t\t\t\t\t\t<input type='submit' name='fixed' value=\"" . wfMessage('soapfailures-fixed')->escaped() . "\"/>\n\t\t\t\t\t\t\t</form>\n"); $wgOut->addHTML("</td>"); $wgOut->addHTML("</tr>\n"); $rowIndex++; } $wgOut->addHTML("</table>\n"); $wgOut->addHTML("<br/>Total of <strong id='lw_numFailures'>{$totFailures}</strong> requests in the top {$MAX_RESULTS}. This number will increase slightly over time, but we should fight to keep it as low as possible!"); } else { $wgOut->addHTML("<em>No results found.</em>\n"); } if (!empty($data)) { $TWO_HOURS_IN_SECONDS = 60 * 60 * 2; $wgMemc->set($CACHE_KEY_TIME, $cachedOn, $TWO_HOURS_IN_SECONDS); $wgMemc->set($CACHE_KEY_STATS, $statsHtml, $TWO_HOURS_IN_SECONDS); // We use CACHE_KEY_DATA to determine when all of these keys have expired, so it should expire a few microseconds after the other two (that's why it's below the other set()s). $wgMemc->set($CACHE_KEY_DATA, $data, $TWO_HOURS_IN_SECONDS); } } $wgOut->addHTML($statsHtml); } }
function initAWS($source_id) { global $search_index, $url; global $opac_curl_proxy; $this->parse_profile(); $params = $this->get_source_params($source_id); $this->fetch_global_properties(); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } $adresse_proxy = false; $port_proxy = false; $user_proxy = false; $pwd_proxy = false; if ($opac_curl_proxy != '') { $param_proxy = explode(',', $opac_curl_proxy); $adresse_proxy = $param_proxy[0]; $port_proxy = $param_proxy[1]; $user_proxy = $param_proxy[2]; $pwd_proxy = $param_proxy[3]; } $client = new nusoapclient("http://ecs.amazonaws.com/AWSECommerceService/2009-10-01/" . $this->profile["SITES"][0]["SITE"][$this->current_site]["COUNTRY"] . "/AWSECommerceService.wsdl", true, $adresse_proxy, $port_proxy, $user_proxy, $pwd_proxy); if ($err = $client->getError()) { if ($err) { $this->error = true; $this->error_message = $err; } } else { $client->timeout = $params["TIMEOUT"]; $client->response_timeout = $params["TIMEOUT"]; } return $client; }
/** * calls method, returns PHP native type * * @param string $operation SOAP server URL or path * @param mixed $params An array, associative or simple, of the parameters * for the method call, or a string that is the XML * for the call. For rpc style, this call will * wrap the XML in a tag named after the method, as * well as the SOAP Envelope and Body. For document * style, this will only wrap with the Envelope and Body. * IMPORTANT: when using an array with document style, * in which case there * is really one parameter, the root of the fragment * used in the call, which encloses what programmers * normally think of parameters. A parameter array * *must* include the wrapper. * @param string $namespace optional method namespace (WSDL can override) * @param string $soapAction optional SOAPAction value (WSDL can override) * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array * @param boolean $rpcParams optional (no longer used) * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors * @access public */ function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') { $this->operation = $operation; $this->fault = false; $this->setError(''); $this->request = ''; $this->response = ''; $this->responseData = ''; $this->faultstring = ''; $this->faultcode = ''; $this->opData = array(); $this->debug("call: operation={$operation}, namespace={$namespace}, soapAction={$soapAction}, rpcParams={$rpcParams}, style={$style}, use={$use}, endpointType={$this->endpointType}"); $this->appendDebug('params=' . $this->varDump($params)); $this->appendDebug('headers=' . $this->varDump($headers)); if ($headers) { $this->requestHeaders = $headers; } if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { $this->loadWSDL(); if ($this->getError()) { return false; } } // serialize parameters if ($this->endpointType == 'wsdl' && ($opData = $this->getOperationData($operation))) { // use WSDL for operation $this->opData = $opData; $this->debug("found operation"); $this->appendDebug('opData=' . $this->varDump($opData)); if (isset($opData['soapAction'])) { $soapAction = $opData['soapAction']; } if (!$this->forceEndpoint) { $this->endpoint = $opData['endpoint']; } else { $this->endpoint = $this->forceEndpoint; } $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; $style = $opData['style']; $use = $opData['input']['use']; // add ns to ns array if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) { $nsPrefix = 'ns' . rand(1000, 9999); $this->wsdl->namespaces[$nsPrefix] = $namespace; } $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); // serialize payload if (is_string($params)) { $this->debug("serializing param string for WSDL operation {$operation}"); $payload = $params; } elseif (is_array($params)) { $this->debug("serializing param array for WSDL operation {$operation}"); $payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType); } else { $this->debug('params must be array or string'); $this->setError('params must be array or string'); return false; } $usedNamespaces = $this->wsdl->usedNamespaces; if (isset($opData['input']['encodingStyle'])) { $encodingStyle = $opData['input']['encodingStyle']; } else { $encodingStyle = ''; } $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); if ($errstr = $this->wsdl->getError()) { $this->debug('got wsdl error: ' . $errstr); $this->setError('wsdl error: ' . $errstr); return false; } } elseif ($this->endpointType == 'wsdl') { // operation not in WSDL $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); $this->setError('operation ' . $operation . ' not present in WSDL.'); $this->debug("operation '{$operation}' not present in WSDL."); return false; } else { // no WSDL //$this->namespaces['ns1'] = $namespace; $nsPrefix = 'ns' . rand(1000, 9999); // serialize $payload = ''; if (is_string($params)) { $this->debug("serializing param string for operation {$operation}"); $payload = $params; } elseif (is_array($params)) { $this->debug("serializing param array for operation {$operation}"); foreach ($params as $k => $v) { $payload .= $this->serialize_val($v, $k, false, false, false, false, $use); } } else { $this->debug('params must be array or string'); $this->setError('params must be array or string'); return false; } $usedNamespaces = array(); if ($use == 'encoded') { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } else { $encodingStyle = ''; } } if ($operation == "sugarHome" && substr_count($this->endpoint, "://updates.sugarcrm.com/heartbeat/soap.php") == 0) { $c2 = new nusoapclient("https://updates.sugarcrm.com/heartbeat/soap.php", false, false, false, false, false, 15, 15); $ping = $c2->call("sugarPing", array()); if (empty($ping) || $c2->getError()) { $c2 = new nusoapclient("http://updates.sugarcrm.com/heartbeat/soap.php", false, false, false, false, false, 15, 15); $c2->call("sugarHome", $params); } } // wrap RPC calls with method element if ($style == 'rpc') { if ($use == 'literal') { $this->debug("wrapping RPC request with literal method element"); if ($namespace) { // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace $payload = "<{$nsPrefix}:{$operation} xmlns:{$nsPrefix}=\"{$namespace}\">" . $payload . "</{$nsPrefix}:{$operation}>"; } else { $payload = "<{$operation}>" . $payload . "</{$operation}>"; } } else { $this->debug("wrapping RPC request with encoded method element"); if ($namespace) { $payload = "<{$nsPrefix}:{$operation} xmlns:{$nsPrefix}=\"{$namespace}\">" . $payload . "</{$nsPrefix}:{$operation}>"; } else { $payload = "<{$operation}>" . $payload . "</{$operation}>"; } } } // check for payload override $payload = !empty($this->payloadOverride) ? $this->payloadOverride : $payload; // serialize envelope $soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle); $this->debug("endpoint={$this->endpoint}, soapAction={$soapAction}, namespace={$namespace}, style={$style}, use={$use}, encodingStyle={$encodingStyle}"); $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000)); // send $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout); if ($errstr = $this->getError()) { $this->debug('Error: ' . $errstr); return false; } else { $this->return = $return; $this->debug('sent message successfully and got a(n) ' . gettype($return)); $this->appendDebug('return=' . $this->varDump($return)); // fault? if (is_array($return) && isset($return['faultcode'])) { $this->debug('got fault'); $this->setError($return['faultcode'] . ': ' . $return['faultstring']); $this->fault = true; foreach ($return as $k => $v) { $this->{$k} = $v; $this->debug("{$k} = {$v}<br>"); } $this->debug('return data for faultcode = ' . var_export($return, true)); return $return; } elseif ($style == 'document') { // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), // we are only going to return the first part here...sorry about that return $return; } else { // array of return values if (is_array($return)) { // multiple 'out' parameters, which we return wrapped up // in the array if (sizeof($return) > 1) { return $return; } // single 'out' parameter (normally the return value) $return = array_shift($return); $this->debug('return shifted value: '); $this->appendDebug($this->varDump($return)); return $return; // nothing returned (ie, echoVoid) } else { return ""; } } } }
function get_procs($type = "", $set = "") { global $charset, $class_path, $pmb_version_brut; global $msg; global $pmb_curl_proxy; $params = array("credentials" => array("user" => $this->server_username, "key" => $this->server_key)); if ($set) { $params["set"] = $set; } if ($type) { $params["type"] = $type; } $params["pmbversion"] = $pmb_version_brut; //Utilisons php_soap si disponible if (extension_loaded("soap")) { $soap_client_parameters = array(); if ($pmb_curl_proxy != '') { $param_proxy = explode(',', $pmb_curl_proxy); $adresse_proxy = $param_proxy[0]; $port_proxy = $param_proxy[1]; $user_proxy = $param_proxy[2]; $pwd_proxy = $param_proxy[3]; $soap_client_parameters = array('proxy_host' => $adresse_proxy, 'proxy_port' => $port_proxy, 'proxy_login' => $user_proxy, 'proxy_password' => $pwd_proxy); } $soap_client_parameters['features'] = SOAP_SINGLE_ELEMENT_ARRAYS; try { @($client = new SoapClient($this->server_adress, $soap_client_parameters)); if (!$client) { return (object) array("error_information" => (object) array("error_code" => 1, "error_string" => $msg["remote_procedures_error_client"])); } @($result = $client->get_procs($params)); } catch (Exception $e) { return (object) array("error_information" => (object) array("error_code" => 1, "error_string" => $e->getMessage())); } if ($charset != 'utf-8') { if (isset($result->elements)) { if (!is_array($result->elements)) { $result->elements = array($result->elements); } foreach ($result->elements as $index => $aprocedure) { $result->elements[$index]->name = utf8_decode($aprocedure->name); $result->elements[$index]->comment = utf8_decode($aprocedure->comment); $result->elements[$index]->sql = utf8_decode($aprocedure->sql); $result->elements[$index]->params = utf8_decode($aprocedure->params); $result->elements[$index]->current_attached_set = utf8_decode($aprocedure->current_attached_set); if (isset($aprocedure->sets)) { if (!is_array($aprocedure->sets)) { $result->elements[$index]->sets = array($result->elements[$index]->sets); } foreach ($result->elements[$index]->sets as $set_index => $aset) { $result->elements[$index]->sets[$set_index]->set_caption = utf8_decode($result->elements[$index]->sets[$set_index]->set_caption); } } } } } } else { $adresse_proxy = false; $port_proxy = false; $user_proxy = false; $pwd_proxy = false; if ($pmb_curl_proxy != '') { $param_proxy = explode(',', $pmb_curl_proxy); $adresse_proxy = $param_proxy[0]; $port_proxy = $param_proxy[1]; $user_proxy = $param_proxy[2]; $pwd_proxy = $param_proxy[3]; } require_once $class_path . "/nusoap/nusoap.php"; $client = new nusoapclient($this->server_adress, true, $adresse_proxy, $port_proxy, $user_proxy, $pwd_proxy); $client->decode_utf8 = $charset != 'utf-8'; if ($err = $client->getError()) { return (object) array("error_information" => (object) array("error_code" => 1, "error_string" => $err)); } $result = $client->call("get_procs", array("parameters" => $params), "http://www.sigb.net/pmb/"); //Si une seule procédure est renvoyée, soap ne renvoi pas un tableau, et alors elements contient directement une procedure //Mais nous voulons un tableau, donc nous devons traiter le cas if (isset($result["elements"]["id"])) { $result["elements"] = array($result["elements"]); } $result = $this->array_to_object($result); if (isset($result->elements)) { foreach ($result->elements as $index => $value) { $result->elements[$index] = $this->array_to_object($result->elements[$index], true); } } } return $result; }