function Execute_Sale(&$transInfo, &$bankInfo, &$companyInfo) { $client = new nusoapclient('https://service.merchlogin.com/?wsdl', true); $sid = 20115; $rcode = $bankInfo['bk_additional_id']; $uip = strval($transInfo['ipaddress']); if ($bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]) { $sid = $bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]; } $response = ""; $response['errormsg'] = "Transaction could not be processed."; $expDate = explode("/", $transInfo['validupto']); $expYear = $expDate[0]; $expMonth = $expDate[1]; $MID = "ca7e5842-dd33-1029-bf92-0013723bba63"; //if($bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]) $TID = $bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]; $DESC = "www.pay-support.com 1-800-511-2457"; //if($bankInfo['cb_config']['custom']['desc_sites'][$transInfo['td_site_ID']]) $DESC = $bankInfo['cb_config']['custom']['desc_sites'][$transInfo['td_site_ID']]; //$transInfo['billing_descriptor']=$DESC; $cust_cntry = $transInfo['country']; //urlencode(func_get_country($transInfo['country'],'co_full')); $transInfo['cardtype'] = 'Visa'; if (substr($transInfo['CCnumber'], 0, 1) == '5') { $transInfo['cardtype'] = 'Mastercard'; } if (!$transInfo['state']) { $transInfo['state'] = 'a'; } $params = array("merchantId" => strval($MID), "IPAddress" => strval($transInfo['ipaddress']), "submittedAmount" => doubleval($transInfo['amount']), "merchantReference" => strval($transInfo['reference_number']), "clientFirstname" => strval($transInfo['name']), "clientSurname" => strval($transInfo['surname']), "clientPhone" => strval($transInfo['phonenumber']), "clientStreet" => strval($transInfo['address']), "clientCity" => strval($transInfo['city']), "clientState" => strval($transInfo['state']), "clientCountry" => strval($cust_cntry), "clientPostcode" => strval($transInfo['zipcode']), "clientEmail" => strval($transInfo['email']), "product" => strval($transInfo['productdescription']), "cardNumber" => strval($transInfo['CCnumber']), "cardName" => strval($transInfo['name'] . " " . $transInfo['surname']), "expiryMonth" => strval($expMonth), "expiryYear" => strval($expYear), "cardCVV" => strval($transInfo['cvv'])); if (strlen($params['clientState']) != 2) { $params['clientState'] = 'ZZ'; } $process_result = $client->call('ProcessCreditCard', $params); $response = array(); $response['td_bank_transaction_id'] = $process_result['TransactionID']; $response['td_process_result'] = serialize($process_result); $response['td_process_query'] = serialize($params); $response['td_bank_recieved'] = 'yes'; //if(in_array($process_result['Status'],array('5','4','2'))) // $response['td_bank_recieved'] = 'no'; if ($process_result['Status'] == '1') { $response['status'] = "A"; $response['td_bank_recieved'] = 'yes'; $response['td_process_msg'] = $process_result['Message'] . ": Approved"; } else { if (in_array($process_result['Status'], array('5', '4', '2'))) { $response['td_bank_recieved'] = 'no'; } $response['status'] = "D"; $response['errormsg'] = $process_result['Message']; if (!isset($process_result['Status'])) { $response['errormsg'] = "Declined (SoEx)"; } } return $response; }
/** * Initialize the soap client and store in the $GLOBALS object for use * * @param login designates whether we want to try to login after we initialize or not */ function initialize($login = true) { if (empty($GLOBALS['SugarDepot'])) { $GLOBALS['log']->debug('USING HTTPS TO CONNECT TO HEARTBEAT'); $soap_client = new nusoapclient(HTTPS_URL, false); $ping = $soap_client->call('sugarPing', array()); $GLOBALS['SugarDepot'] = $soap_client; } //if we do not have a session, then try to login if ($login && empty($_SESSION['SugarDepotSessionID'])) { PackageManagerComm::login(); } }
function Execute_Sale(&$transInfo, &$bankInfo, &$companyInfo) { $client = new nusoapclient('https://soap.Servpay.com/tx2.php?wsdl', true); $sid = 20115; $rcode = $bankInfo['bk_additional_id']; $uip = strval($transInfo['ipaddress']); if ($bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]) { $sid = $bankInfo['cb_config']['custom']['tid_sites'][$transInfo['td_site_ID']]; } $expDate = explode("/", $transInfo['validupto']); $expYear = $expDate[0]; $expMonth = $expDate[1]; $cust_cntry = urlencode(func_get_country($transInfo['country'], 'co_full')); $transInfo['cardtype'] = 'VISA'; if (substr($transInfo['CCnumber'], 0, 1) == '5') { $transInfo['cardtype'] = 'MASTERCARD'; } if (!$transInfo['state']) { $transInfo['state'] = "NA"; } $udetails = array('username' => '', 'password' => '', 'card_name' => strval($transInfo['name'] . " " . $transInfo['surname']), 'card_no' => strval($transInfo['CCnumber']), 'card_type' => $transInfo['cardtype'], 'card_ccv' => strval($transInfo['cvv']), 'card_exp_month' => strval($expMonth), 'card_exp_year' => strval($expYear), 'bank_name' => '', 'bank_phone' => $transInfo['td_bank_number'], 'firstname' => strval($transInfo['name']), 'lastname' => strval($transInfo['surname']), 'email' => strval($transInfo['email']), 'phone' => strval($transInfo['phonenumber']), 'mobile' => '', 'address' => strval($transInfo['address']), 'suburb_city' => strval($transInfo['city']), 'state' => strval($transInfo['state']), 'postcode' => strval($transInfo['zipcode']), 'country' => strval($cust_cntry), 'ship_firstname' => strval($transInfo['name']), 'ship_lastname' => strval($transInfo['surname']), 'ship_address' => strval($transInfo['address']), 'ship_suburb_city' => strval($transInfo['city']), 'ship_state' => strval($transInfo['state']), 'ship_postcode' => strval($transInfo['zipcode']), 'ship_country' => strval($cust_cntry)); $txparams = array('ref1' => 'NULL', 'cmd' => '', 'vbv' => NULL); $cart = array('items' => array(array('name' => 'null', 'quantity' => 1, 'amount_unit' => round($transInfo['amount'], 2), 'item_no' => '', 'item_desc' => '')), 'summary' => array('quantity' => 1, 'amount_purchase' => round($transInfo['amount'], 2), 'amount_shipping' => '0', 'currency_code' => 'USD')); $param = array('sid' => $sid, 'rcode' => $rcode, 'uip' => $uip, 'udetails' => $udetails, 'cart' => $cart, 'txparams' => $txparams); $process_result = $client->call('processSinglePayTx', $param); //print_r($param);print_r($process_result); $response = NULL; $response['td_bank_transaction_id'] = $process_result['txid']; $response['td_process_result'] = serialize($process_result); $response['td_process_query'] = serialize($param); $response['td_bank_recieved'] = 'yes'; //if(in_array($process_result['Status'],array('5','4','2'))) // $response['td_bank_recieved'] = 'no'; if ($process_result['status'] == 'OK') { $response['status'] = "A"; $response['td_bank_recieved'] = 'yes'; $response['td_process_msg'] = $process_result['status'] . ": Approved"; } else { $response['status'] = "D"; $response['errormsg'] = $process_result['error']['msg'] . " " . $process_result['error']['info']; if (!$response['errormsg']) { $response['errormsg'] = "Declined (SoEx)"; } } return $response; }
/** * Test asserts that contact can be found by custom field * * @group 58138 * @dataProvider dataProvider */ public function testSoapVersions($url) { $soap_url = $GLOBALS['sugar_config']['site_url'] . $url; $this->soap = new nusoapclient($soap_url); $result = $this->soap->call('login', array('user_auth' => array('user_name' => $GLOBALS['current_user']->user_name, 'password' => $GLOBALS['current_user']->user_hash, 'version' => '.01'), 'application_name' => 'SoapTest')); $actual = $this->soap->call('get_relationships', array('session' => $result['id'], 'module_name' => 'Accounts', 'module_id' => $this->account->id, 'link_field_name' => 'contacts', 'related_module_query' => "contacts_cstm.test_c = 'test value' ", 'link_module_fields' => array('id'), 'deleted' => '1')); $this->assertInternalType('array', $actual, 'Incorrect response'); if (empty($actual['entry_list'])) { $this->fail('Data is not present'); } $actual = reset($actual['entry_list']); $this->assertEquals($this->contact->id, $actual['id'], 'Contact is incorrect'); }
if ($null != '1') { $params = array('inputBoolean' => false); } else { $params = array('inputBoolean' => null); } } elseif ($method == 'echoBase64') { if ($null != '1') { $params = array('inputBase64' => base64_encode('You must encode the data you send; NuSOAP will automatically decode the data it receives')); } else { $params = array('inputBase64' => null); } } else { echo 'Sorry, I do not know about method ' . $method; exit; } $client = new nusoapclient('http://www.scottnichol.com/samples/round2_base_server.php?wsdl&debug=1', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $client->useHTTPPersistentConnection(); echo '<h2>Execute ' . $method . '</h2>'; $result = $client->call($method, $params); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError();
* $Id: wsdlclient13.php,v 1.1 2004/10/01 19:57:21 snichol Exp $ * * 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>';
</tr> <tr><th colspan='6'>Use the name 'lead' and password 'lead' for portal lead generation</th></tr> <tr> <td>CONTACT NAME:</td><td><input type='text' name='user_name' value='{$user_name}'></td></td> </tr> <tr><td><input type='submit' value='Submit'></td></tr> </table> </form> EOQ; if (!empty($portal_name)) { $portal_password = md5($portal_password); require_once 'include/nusoap/nusoap.php'; //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient($GLOBALS['sugar_config']['site_url'] . '/soap.php'); //define the SOAP Client an echo '<b>LOGIN:</b><BR>'; $result = $soapclient->call('portal_login', array('portal_auth' => array('user_name' => $portal_name, 'password' => $portal_password, 'version' => '.01'), 'user_name' => $user_name, 'application_name' => 'SoapTestPortal')); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>'; echo $soapclient->response; echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; echo print_r($result); $session = $result['id']; echo '<br><br><b>CREATE LEAD:</b><BR>'; $result = $soapclient->call('portal_set_entry', array('session' => $session, 'module_name' => 'Leads', 'name_value_list' => array(array('name' => 'first_name', 'value' => 'Test'), array('name' => 'last_name', 'value' => 'Lead'), array('name' => 'portal_name', 'value' => 'portal_name'), array('name' => 'portal_app', 'value' => 'SoapTestPortal'), array('name' => 'description', 'value' => 'A lead created through webservices')))); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>';
function convert_disc_client() { set_time_limit(3600); ini_set('default_socket_timeout', 360); global $sugar_config; require_once 'vendor/nusoap//nusoap.php'; $errors = array(); $server_url = "http://"; $user_name = ""; $admin_name = ""; $password = ""; $oc_install = false; if (empty($sugar_config['unique_key'])) { $sugar_config['unique_key'] = create_guid(); } if (isset($_SESSION['oc_install']) && $_SESSION['oc_install'] == true) { $oc_install = true; } // run options are: convert, sync // default behavior of this page $run = "convert"; if (!$oc_install) { if (isset($_REQUEST['run'])) { $run = $_REQUEST['run']; } if ($run == "convert") { if (isset($_REQUEST['server_url'])) { $server_url = $_REQUEST['server_url']; if ($server_url == "") { $errors[] = "Server URL cannot be empty."; } } } else { if ($run == "sync") { $server_url = $sugar_config['sync_site_url']; } } if (isset($_REQUEST['user_name'])) { $user_name = $_REQUEST['user_name']; if ($user_name == "") { $errors[] = "User Name cannot be empty."; } } if (isset($_REQUEST['password'])) { if ($_REQUEST['password'] == "") { $errors[] = "Password cannot be empty."; } else { $password = $_REQUEST['password']; } } } else { //this is an offline client install if (isset($_SESSION['oc_run'])) { $run = $_SESSION['oc_run']; } if ($run == "convert") { if (isset($_SESSION['oc_server_url'])) { $server_url = $_SESSION['oc_server_url']; if ($server_url == "") { $errors[] = "Server URL cannot be empty."; } } } else { if ($run == "sync") { $server_url = $sugar_config['sync_site_url']; } } if (isset($_SESSION['oc_username'])) { $user_name = $_SESSION['oc_username']; if ($user_name == "") { $errors[] = "User Name cannot be empty."; } } if (isset($_SESSION['oc_password'])) { if ($_SESSION['oc_password'] == "") { $errors[] = "Password cannot be empty."; } else { $password = $_SESSION['oc_password']; } } } //end check for offline client install if (!isset($_SESSION['is_oc_conversion']) || $_SESSION['is_oc_conversion'] == false) { $password = md5($password); } $sugar_config['oc_username'] = $user_name; $sugar_config['oc_password'] = $password; $sugar_config['oc_converted'] = false; $sugar_config['disc_client'] = true; if (isset($_SESSION['install_method'])) { $sugar_config['install_method'] = $_SESSION['install_method']; } if ((isset($_REQUEST['submitted']) || $oc_install) && sizeof($errors) == 0) { if (empty($server_url) || $server_url == 'http://') { $errors[] = "Server URL is required"; } else { $sugar_config['sync_site_url'] = $server_url; $soapclient = new nusoapclient("{$server_url}/soap.php"); $soapclient->response_timeout = 360; if ($soapclient->call('is_loopback', array())) { $errors[] = "Server and Client must be on separate machines with unique ip addresses"; } $result = $soapclient->call('get_sugar_flavor', array()); global $sugar_flavor, $sugar_version; if ($result != $sugar_flavor) { $errors[] = "Server and Client must both be running the same flavor of Sugar."; } if (!$soapclient->call('offline_client_available', array())) { $errors[] = "No licenses available for offline client"; } $result = $soapclient->call('login', array('user_auth' => array('user_name' => $user_name, 'password' => $password, 'version' => '.01'), 'application_name' => 'Disconnected Client Setup')); if ($soapclient->error_str) { $errors[] = "Login failed with error: " . $soapclient->response; } if ($result['error']['number'] != 0) { $errors[] = "Login failed with error: " . $result['error']['name'] . ' ' . $result['error']['description']; } $session = $result['id']; } $errorString = ""; if (!empty($errors)) { foreach ($errors as $error) { $errorString .= $error . "<br>"; } } if ($session && empty($errors)) { if ($run == "convert") { // register this client/user with server // update local config.php file $install_method = 'web'; if (isset($sugar_config['install_method'])) { $install_method = $sugar_config['install_method']; } //attempt to obtain the system_id from the server //php_uname('n') will only work on a windows system $machine_name = php_uname('n'); $soapclient->setHeaders('sugar_version=' . $sugar_version); $result = $soapclient->call('get_unique_system_id', array('session' => $session, 'unique_key' => $sugar_config['unique_key'], 'system_name' => $machine_name, 'install_method' => $install_method)); if ($soapclient->error_str) { $errors[] = "Unable to obtain unique system id from server: " . $soapclient->error_str; } else { if ($result['error']['number'] != 0) { $errors[] = $result['error']['description']; } else { $admin = BeanFactory::getBean('Administration'); $system_id = $result['id']; if (!isset($system_id)) { $system_id = 1; } $admin->saveSetting('system', 'system_id', $system_id); } } } // data sync triggers if (empty($errors)) { require_once "modules/Sync/SyncHelper.php"; sync_users($soapclient, $session, true, true); $sugar_config['oc_converted'] = true; echo 'Updating Local Information<br>'; //echo 'Done - will auto logout in <div id="seconds_left">10</div> seconds<script> function logout_countdown(left){document.getElementById("seconds_left").innerHTML = left; if(left == 0){document.location.href = "index.php?module=Users&action=Logout";}else{left--; setTimeout("logout_countdown("+ left+")", 1000)}};setTimeout("logout_countdown(10)", 1000)</script>'; // done with soap calls $result = $soapclient->call('logout', array('session' => $session)); ksort($sugar_config); if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) { return; } } } } $errorString = ""; foreach ($errors as $error) { $errorString .= $error . "<br>"; } return $errorString; }
/* * $Id: wsdlclient3b.php,v 1.1 2004/06/15 15:38:29 snichol Exp $ * * WSDL client sample. * * Service: WSDL * Payload: rpc/encoded (params as an XML string; cf. wsdlclient3.php) * Transport: http * Authentication: none */ require_once '../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'] : ''; $client = new nusoapclient('http://www.scottnichol.com/samples/hellowsdl2.php?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $params = '<person xsi:type="tns:Person"><firstname xsi:type="xsd:string">Willi</firstname><age xsi:type="xsd:int">22</age><gender xsi:type="xsd:string">male</gender></person>'; $result = $client->call('hello', $params); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) {
/** * * @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); } }
/* * $Id: wsdlclient3c.php,v 1.2 2004/10/01 19:57:20 snichol Exp $ * * WSDL client sample. * * Service: WSDL * Payload: rpc/literal * Transport: http * Authentication: none */ require_once '../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'] : ''; $client = new nusoapclient('http://www.scottnichol.com/samples/hellowsdl4.php?wsdl&debug=1', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male'); $result = $client->call('hello', array('person' => $person)); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) {
/* * $Id: wsdlclient2.php,v 1.2 2004/01/26 07:15:20 snichol Exp $ * * WSDL client sample. * * Service: WSDL proxy * Payload: rpc/encoded * Transport: http * Authentication: none */ require_once '../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'] : ''; $client = new nusoapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl", true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $proxy = $client->getProxy(); $param = array('browse_node' => 18, 'page' => 1, 'mode' => 'books', 'tag' => 'melonfire-20', 'type' => 'lite', 'devtag' => 'My token is here'); $result = $proxy->BrowseNodeSearchRequest($param); // Check for a fault if ($proxy->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $proxy->getError();
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 nusoapclient($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); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) {
echo '</td></tr></table>'; echo '<table width="100%"><tr><td colspan="2" id="current_msg" valign="top"><div id="show_conflict_div"> <div></td></tr>'; echo '<tr><td colspan="2" id="retrieve_msg" valign="top">'; if ($display_log == 0) { echo '<div id="retrieve_msg_divlink" style="display:inline"><a href="#" onclick="document.getElementById(\'display_log\').value = 1; toggleDisplay(\'retrieve_msg_div\');">display log</a></div><div id="retrieve_msg_div" style="display:none">'; } echo retrieve_msg(); if ($display_log == 0) { echo '</div>'; } echo "</td><td align='right'><A href='http://www.sugarcrm.com' target='_blank'><!--not_in_theme!--><img style='margin-top: 2px' border='0' width='120' height='34' src='" . getJSPath('include/images/poweredby_sugarcrm_65.png') . "' alt='" . $mod_strings['LBL_POWERED_BY_SUGAR'] . "'></a></td></tr></table></div><script>document.getElementById('sync_table').style.display='inline';</script>"; echo str_repeat(' ', 256); flush(); require_once 'vendor/nusoap//nusoap.php'; //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient($soap_server); //define the SOAP Client an $soapclient->response_timeout = 360; if (empty($_SESSION['sync_start_time'])) { //get the what the server says is gmt time $start_time = $soapclient->call('get_gmt_time', array()); $local_time = $timedate->nowDb(); if (has_error()) { add_to_msg('Could not connect to server'); die; } add_to_msg("Sync started at LOCAL:" . $timedate->to_display_date_time($local_time, true) . " SERVER:" . $timedate->to_display_date_time($start_time, true) . "<br>"); flush(); $_SESSION['sync_start_time'] = $start_time; $_SESSION['sync_local_time'] = $local_time; } else {
* $Id: wsdlclient11.php,v 1.1 2004/04/22 14:19:45 snichol Exp $ * * WSDL client sample. * Exercises a document/literal NuSOAP service (added nusoap.php 1.73). * * Service: WSDL * Payload: document/literal * Transport: http * Authentication: none */ require_once '../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'] : ''; $client = new nusoapclient('http://www.scottnichol.com/samples/hellowsdl3.wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male'); $param = array('name' => $person); $result = $client->call('hello', array('parameters' => $param)); if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { $err = $client->getError(); if ($err) { echo '<h2>Error</h2><pre>' . $err . '</pre>';
function ConvertDiscClient() { global $sugar_config; global $app_strings; global $app_list_strings; global $mod_strings; $xtpl = new XTemplate('modules/Administration/ConvertDiscClient.html'); $xtpl->assign("MOD", $mod_strings); $xtpl->assign("APP", $app_strings); echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_UPGRADE_CONVERT_DISC_CLIENT_TITLE']), false); require_once 'vendor/nusoap//nusoap.php'; $errors = array(); $server_url = "http://"; $user_name = ""; $admin_name = ""; $password = ""; // run options are: convert, sync // default behavior of this page $run = "convert"; if (isset($_REQUEST['run'])) { $run = $_REQUEST['run']; } if ($run == "convert") { if (isset($_REQUEST['server_url'])) { $server_url = $_REQUEST['server_url']; if ($server_url == "") { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_SERVER_URL_EMPTY_ERROR']; } } } else { if ($run == "sync") { $server_url = $sugar_config['sync_site_url']; } } if (isset($_REQUEST['user_name'])) { $user_name = $_REQUEST['user_name']; if ($user_name == "") { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_USER_NAME_EMPTY_ERROR']; } } if (isset($_REQUEST['password'])) { if ($_REQUEST['password'] == "") { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_PASSWORD_EMPTY_ERROR']; } } if (isset($_REQUEST['admin_name'])) { $admin_name = $_REQUEST['admin_name']; if ($_REQUEST['admin_name'] == "") { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_ADMIN_NAME_EMPTY']; } } if ($run == "convert") { if (!is_writable("config.php")) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_CONFIG_WRITABLE_ERROR']; } } if (isset($_REQUEST['submitted']) && sizeof($errors) == 0) { if (empty($server_url) || $server_url == 'http://') { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_SERVER_URL_REQUIRED']; } else { $soapclient = new nusoapclient("{$server_url}/soap.php"); $soapclient->response_timeout = 360; if ($soapclient->call('is_loopback', array())) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_SERVER_CLIENT_IP_ERROR']; } if (!$soapclient->call('offline_client_available', array())) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_NO_LICENSE']; } $result = $soapclient->call('login', array('user_auth' => array('user_name' => $admin_name, 'password' => md5($_REQUEST['password']), 'version' => '.01'), 'application_name' => 'Disconnected Client Setup')); if ($soapclient->error_str) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_LOGIN_FAILED_ERROR'] . $soapclient->error_str; } if ($result['error']['number'] != 0) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_LOGIN_FAILED_ERROR'] . $result['error']['name'] . ' ' . $result['error']['description']; } $session = $result['id']; if (empty($errors)) { $data = array($user_name); $result = $soapclient->call('sudo_user', array('session' => $session, 'user_name' => $user_name)); if ($soapclient->error_str) { $errors[] = string_format($mod_strings['LBL_CONVERT_DISC_CLIENT_SWITCH_TO_USER_ERROR'], $data) . $soapclient->error_str; } if (isset($result['error']) && $result['error']['number'] != 0) { $errors[] = string_format($mod_strings['LBL_CONVERT_DISC_CLIENT_SWITCH_TO_USER_ERROR'], $data) . $result['error']['name'] . ' ' . $result['error']['description']; } } } $errorString = ""; if (!empty($errors)) { foreach ($errors as $error) { $errorString .= $error . "<br>"; } } echo '<font color="red"> ' . $errorString . '</font>'; if ($session && empty($errors)) { if ($run == "convert") { // register this client/user with server // update local config.php file $sugar_config['disc_client'] = true; $sugar_config['sync_site_url'] = $server_url; //attempt to obtain the system_id from the server $result = $soapclient->call('get_unique_system_id', array('session' => $session, 'unique_key' => $sugar_config['unique_key'])); if ($soapclient->error_str) { $errors[] = $mod_strings['LBL_CONVERT_DISC_CLIENT_UNIQUE_SYSTEM_ID_ERROR'] . $soapclient->error_str; } else { $admin = BeanFactory::getBean('Administration'); $system_id = $result['id']; if (!isset($system_id)) { $system_id = 1; } $admin->saveSetting('system', 'system_id', $system_id); } } // run the file sync require_once "include/utils/disc_client_utils.php"; disc_client_file_sync($soapclient, $session, true); // data sync triggers require_once "modules/Sync/SyncHelper.php"; sync_users($soapclient, $session, true); ksort($sugar_config); echo $mod_strings['LBL_CONVERT_DISC_CLIENT_UPDATE_LOCAL_INFO']; if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) { $xtpl->assign("COMPLETED_MESSAGE", $mod_strings['LBL_CONVERT_DISC_CLIENT_CONFIG_WRITABLE_AGAIN_ERROR']); $xtpl->parse("main.complete"); return; } echo $mod_strings['LBL_CONVERT_DISC_CLIENT_DONE_LOGOUT'] . '<script> function logout_countdown(left){document.getElementById("seconds_left").innerHTML = left; if(left == 0){document.location.href = "index.php?module=Users&action=Logout";}else{left--; setTimeout("logout_countdown("+ left+")", 1000)}};setTimeout("logout_countdown(10)", 1000)</script>'; // done with soap calls $result = $soapclient->call('logout', array('session' => $session)); $xtpl->assign("COMPLETED_MESSAGE", $mod_strings['LBL_CONVERT_DISC_CLIENT_SYNC_COMPLETE']); $xtpl->parse("main.complete"); return; } } $errorString = ""; foreach ($errors as $error) { $errorString .= $error . "<br>"; } if (!empty($errorString)) { $xtpl->assign("COMPLETED_MESSAGE", $errorString); $xtpl->parse("main.complete"); } if ($run == "convert" && isset($sugar_config['disc_client']) && $sugar_config['disc_client'] == true) { $xtpl->parse("main.existing"); } else { if ($run == "convert") { $xtpl->assign("SERVER_URL", $server_url); } $xtpl->assign("USER_NAME", $user_name); $xtpl->assign("ADMIN_NAME", $admin_name); $xtpl->assign("SUBMITTTED", "true"); $xtpl->assign("RUN", $run); if ($run == "convert") { $xtpl->assign("SUBMIT_MESSAGE", $mod_strings['LBL_CONVERT_DISC_CLIENT_SUBMIT']); } else { if ($run == "sync") { $xtpl->assign("SUBMIT_MESSAGE", $mod_strings['LBL_CONVERT_DISC_CLIENT_SYNC_SUBMIT']); } } $xtpl->parse("main.convert"); } $xtpl->parse("main"); $xtpl->out("main"); }
/** * processes SOAP message returned from server * * @param array $headers The HTTP headers * @param string $data unprocessed response data from server * @return mixed value of the message, decoded into a PHP type * @access private */ function parseResponse($headers, $data) { $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); $this->responseAttachments = array(); if (strstr($headers['content-type'], 'multipart/related')) { $this->debug('Decode multipart/related'); $input = ''; foreach ($headers as $k => $v) { $input .= "{$k}: {$v}\r\n"; } $params['input'] = $input . "\r\n" . $data; $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $structure = Mail_mimeDecode::decode($params); foreach ($structure->parts as $part) { if (!isset($part->disposition)) { $this->debug('Have root part of type ' . $part->headers['content-type']); $return = parent::parseResponse($part->headers, $part->body); } else { $this->debug('Have an attachment of type ' . $part->headers['content-type']); $info['data'] = $part->body; $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; $info['contenttype'] = $part->headers['content-type']; $info['cid'] = $part->headers['content-id']; $this->responseAttachments[] = $info; } } if (isset($return)) { return $return; } $this->setError('No root part found in multipart/related content'); return; } $this->debug('Not multipart/related'); return parent::parseResponse($headers, $data); }
/** * 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 ""; } } } }
<tr><td><input type='submit' value='Submit'></td></tr> </table> </form> EOQ; if (!empty($user_name)) { $offset = 0; if (isset($_REQUEST['offset'])) { $offset = $_REQUEST['offset'] + 20; echo $offset; } require_once 'vendor/nusoap//nusoap.php'; //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient($GLOBALS['sugar_config']['site_url'] . '/soap.php'); //define the SOAP Client an echo '<b>LOGIN:</b><BR>'; $result = $soapclient->call('login', array('user_auth' => array('user_name' => $user_name, 'password' => md5($user_password), 'version' => '.01'), 'application_name' => 'SoapTest')); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>'; echo $soapclient->response; echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; echo print_r($result); $session = $result['id']; echo '<br><br><b>GET Case fields:</b><BR>'; $result = $soapclient->call('get_module_fields', array('session' => $session, 'module_name' => 'Cases')); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : ''; echo 'You must set your own Via Michelin login and password in the source code to run this client!'; exit; $login = ''; $password = ''; $wsdlurl = 'http://www.viamichelin.com/ws/services/Geocoding?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 nusoapclient($wsdl, true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $inputAddresses[] = array('address' => '45 Liberty Blvd.', 'cityName' => 'Malvern', 'countryCode' => 'USA', 'postalCode' => '19355', 'stateName' => 'PA'); $geocodingrequest = array('addressesList' => $inputAddresses); $params = array('request' => $geocodingrequest, 'check' => "{$login}|{$password}"); $result = $client->call('getLocationsList', $params); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors
/* * $Id: getfile1client.php,v 1.1 2005/05/18 14:38:53 snichol Exp $ * * Get file client sample. * * Service: SOAP endpoint * Payload: rpc/encoded * Transport: http * Authentication: none */ require_once '../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'] : ''; $client = new nusoapclient('http://www.scottnichol.com/samples/getfile1.php?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $result = $client->call('getFile', array('filename' => 'getfile1.php')); if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { $err = $client->getError(); if ($err) { echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { echo '<h2>Result</h2><pre>' . htmlspecialchars($result, ENT_QUOTES) . '</pre>';
* * Service: WSDL * Payload: document/literal * Transport: http * Authentication: digest */ require_once '../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 'You must set your username and password in the source'; exit; $username = ''; $password = ''; $client = new nusoapclient("http://staging.mappoint.net/standard-30/mappoint.wsdl", true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $client->setCredentials($username, $password, 'digest'); $address = array('AddressLine' => '563 Park Avenue', 'PrimaryCity' => 'New York', 'SecondaryCity' => 'Brooklyn', 'Subdivision' => '', 'PostalCode' => '', 'CountryRegion' => 'US', 'FormattedAddress' => ''); $findRange = array('StartIndex' => 0, 'Count' => 10); $findResultMask = 'AddressFlag'; $findOptions = array('Range' => $findRange, 'SearchContext' => 1, 'ResultMask' => $findResultMask, 'ThresholdScore' => 0.85); $findAddressSpecification = array('DataSourceName' => 'MapPoint.NA', 'InputAddress' => $address, 'Options' => $findOptions); $findAddress = array('specification' => $findAddressSpecification); $result = $client->call('FindAddress', array('parameters' => $findAddress)); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>';
} 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));
require_once 'soap/SoapHelperFunctions.php'; require_once 'vendor/nusoap//nusoap.php'; require_once 'vendor/nusoap//nusoap.php'; //must also have the nusoap code on the ClientSide. $GLOBALS['log'] =& LoggerManager::getLogger('SugarCRM'); //ignore notices error_reporting(E_ALL ^ E_NOTICE); // check for old config format. if (empty($sugar_config) && isset($dbconfig['db_host_name'])) { make_sugar_config($sugar_config); } // Administration include global $HTTP_RAW_POST_DATA; $administrator = new Administration(); $administrator->retrieveSettings(); $soapclient = new nusoapclient($url . '?wsdl', true); //define the SOAP Client an echo '<b>Get Server info: - get_server_info test</b><BR>'; $result = $soapclient->call('get_server_info'); print_result($result); echo '<b>LOGIN: -login test</b><BR>'; $result = $soapclient->call('login', array('user_auth' => array('user_name' => $user_name, 'password' => md5($user_password), 'version' => '.01'), 'application_name' => 'SoapTest')); print_result($result); $session = $result['id']; echo '<b>Get User Id: - get_user_id test</b><BR>'; $result = $soapclient->call('get_user_id', array('session' => $session)); print_result($result); if (!$quick_test) { echo '<b>Get Contact Module Fields: - get_module_fields test</b><BR>'; $result = $soapclient->call('get_module_fields', array('session' => $session, 'module_name' => 'Contacts')); print_result($result);
</tr> <tr><th colspan='6'>Enter SugarCRM Portal Contact Information (to configure this login to SugarCRM as an admin and edit a contact. You will see Portal Information at the bottom of the Contact EditView Panel)</th></tr> <tr> <td>CONTACT NAME:</td><td><input type='text' name='user_name' value='{$user_name}'></td> </tr> <tr><td><input type='submit' value='Submit'></td></tr> </table> </form> EOQ; if (!empty($portal_name)) { $portal_password = md5($portal_password); require_once '../include/nusoap/nusoap.php'; //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient('http://localhost/sugarcrm/soap.php'); //define the SOAP Client an //application_name is the client application connecting to sugar CRM for example mambo echo '<b>LOGIN:</b><BR>'; $result = $soapclient->call('portal_login', array('portal_auth' => array('user_name' => $portal_name, 'password' => $portal_password, 'version' => '.01'), 'user_name' => $user_name, 'application_name' => 'SoapTestPortal')); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>'; echo $soapclient->response; echo '<BR><BR>'; echo $soapclient->responseHeaders; echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; echo print_r($result); $session = $result['id']; echo '<br><br><b>GET CASES:</b><BR>'; $result = $soapclient->call('portal_get_entry_list', array('session' => $session, 'module_name' => 'Cases', 'where' => "date_entered > '" . date('Y-m-d') . "'", 'order_by' => '', 'select_fields' => array('name', 'description', 'priority', 'status')));
function print_result($result) { global $soapclient; if (!empty($soapclient->error_str)) { echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>'; echo $soapclient->response; } echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; print_r($result); echo '<br>'; } require_once 'vendor/nusoap//nusoap.php'; //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient($sugar_soap_path); //define the SOAP Client an //ignore notices error_reporting(E_ALL ^ E_NOTICE); // check for old config format. if (empty($sugar_config) && isset($dbconfig['db_host_name'])) { make_sugar_config($sugar_config); } // Administration include global $HTTP_RAW_POST_DATA; $administrator = new Administration(); $administrator->retrieveSettings(); echo '<b>Test (ECHO): - test test</b><BR>'; $result = $soapclient->call('test', array('string' => 'hello sugar')); print_result($result); echo '<b>LOGIN: -portal_login test</b><BR>';
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']; }
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; }
$sugarSoapUser = $sugar_config['asterisk_soapuser']; $sugarSoapCredential = ""; $sql = "select user_hash from users where user_name='{$sugarSoapUser}'"; $sqlResult = mysql_query($sql); if ($sqlResult) { $rowData = mysql_fetch_assoc($sqlResult); $sugarSoapCredential = $rowData['user_hash']; } else { echo "! FATAL: Cannot find login credentials for user {$sugarSoapUser}\n"; die; } // // And finally open a SOAP connection to SugarCRM // echo "! Trying SOAP login endpoint=[{$sugarSoapEndpoint}] user=[{$sugarSoapUser}] password=[{$sugarSoapCredential}]\n"; $soapClient = new nusoapclient($sugarSoapEndpoint . '?wsdl', true); $auth_array = array('user_auth' => array('user_name' => $sugarSoapUser, 'password' => $sugarSoapCredential)); $soapLogin = $soapClient->call('login', $auth_array); $soapSessionId = $soapLogin['id']; $userGUID = $soapClient->call('get_user_id', $soapSessionId); print "! Successful SOAP login id=" . $soapSessionId . " user="******" GUID=" . $userGUID . "\n"; fputs($amiSocket, "Action: Login\r\n"); fputs($amiSocket, $asteriskUser); fputs($amiSocket, $asteriskSecret); fputs($amiSocket, "Events: call\r\n\r\n"); // just monitor call data $result = fgets($amiSocket, 4096); echo "! Login action returned with rc={$result}\n"; $event = ''; $stack = 0; $event_started = false;
function call($method, $params) { $params['session'] = $this->sessionid; $result = parent::call($method, $params); if (is_array($result) && array_key_exists("error", $result) && $result['error']['number'] != 0) { $this->login(); $result = parent::call($method, $params); } //print_r($result); return $result; }