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(); } }
/** * 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'); }
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; }
</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>'; echo $soapclient->response; echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; echo print_r($result);
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; }
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"); }
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; }
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>'; $result = $soapclient->call('portal_login', array('user_auth' => array('user_name' => $user_name, 'password' => md5($user_password), 'version' => '.01'), 'user_name' => $contact_name, 'application_name' => 'SoapTest')); print_result($result); $session = $result['id']; echo '<b>Get Portal Contact Id: - portal_get_sugar_id test</b><BR>'; $result = $soapclient->call('portal_get_sugar_id', array('session' => $session)); print_result($result); echo '<br><br><b>Get cases - portal_get_entry test:</b><BR>'; $timestart = microtime(true); $result = $soapclient->call('portal_get_entry_list', array('session' => $session, 'module_name' => 'Cases', 'where' => '', 'order_by' => '', 'offset' => 0, 'select_fields' => array('name', 'date_modified', 'description'))); $diff = microtime(true) - $timestart; echo "<b>Time for retrieving Cases is {$diff} </b> <br><br>"; print_result($result); echo '<br><br><b>Set a case - portal_set_entry test:</b><BR>';
<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>'; echo $soapclient->response; echo '<BR><BR><b>HERE IS RESULT:</b><BR>'; echo print_r($result);
$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 { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
} $client->soap_defencoding = 'UTF-8'; echo 'You must set your own Google key in the source code to run this client!'; exit; $key = 'set your own Google key'; $q = '"Lies and the Lying"'; $start = 1; $maxResults = 10; $filter = false; $restrict = ''; $safeSearch = false; $lr = ''; $ie = ''; $oe = ''; $params = array('key' => $key, 'q' => $q, 'start' => $start, 'maxResults' => $maxResults, 'filter' => $filter, 'restrict' => $restrict, 'safeSearch' => $safeSearch, 'lr' => $lr, 'ie' => $ie, 'oe' => $oe); $result = $client->call('doGoogleSearch', $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) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
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; }
$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) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
* 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) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
$_SESSION['soap_server_available'] = false; echo '<b><font color="red">' . translate('LBL_SERVER_UNAVAILABLE', 'Sync') . '</font></b>'; die; } } if (isset($_REQUEST['go_online'])) { session_start(); global $current_user; if (!isset($current_user)) { $current_user = BeanFactory::getBean('Users'); if (isset($_SESSION['authenticated_user_id'])) { $result = $current_user->retrieve($_SESSION['authenticated_user_id']); if ($result == null) { session_destroy(); header("Location: index.php?action=Login&module=Users"); } } } require_once 'modules/Sync/SyncHelper.php'; $soapclient = new nusoapclient($soap_server); //define the SOAP Client an $result = $soapclient->call('login', array('user_auth' => sync_get_user_auth_data(), 'application_name' => 'MobileClient')); if (!has_error($result)) { $canlogin = $soapclient->call('seamless_login', array('session' => $result['id'])); if ($canlogin == 1) { header('Location:' . $sugar_config['sync_site_url'] . '/index.php?MSID=' . $result['id']); } else { sugar_die('Could not do seamless login'); } } }
} 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 { $start_time = $_SESSION['sync_start_time']; $local_time = $_SESSION['sync_local_time']; 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(); }
* 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>'; } else { echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } echo '<h2>Request</h2>';
$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(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r(!is_bool($result) ? $result : ($result ? 'true' : 'false'));
* 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/onca/soap2", false, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } // This is an archaic parameter list $params = array('manufacturer' => "O'Reilly", 'page' => '1', 'mode' => 'books', 'tag' => 'trachtenberg-20', 'type' => 'lite', 'devtag' => 'D35PWRR0R0URC3', 'sort' => '+title'); $result = $client->call('ManufacturerSearchRequest', $params, 'http://soap.amazon.com', 'http://soap.amazon.com'); if ($client->fault) { echo '<h2>Fault (This is expected)</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>'; print_r($result); echo '</pre>'; } } echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
* 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>'; } } echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
* 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) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
{ 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(); if ($err) { die_error($err); } $contacts = $result[entry_list]; if (!($fp = fopen("/tmp/SugarCRMContacts.csv", "w"))) { die_error("Could not open /tmp/SugarCRMContacts.csv for writing");
/** * 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> <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'))); echo '<b>HERE IS ERRORS:</b><BR>'; echo $soapclient->error_str; echo '<BR><BR><b>HERE IS RESPONSE:</b><BR>'; echo $soapclient->response;
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 $err = $client->getError(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
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']; }
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>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result);
$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; // Keep a loop going to read the socket and parse the resulting commands. while (!feof($amiSocket)) {
//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); } echo '<br><br><b>Set A Contact - set_entry test:</b><BR>'; $time = date($GLOBALS['timedate']->get_db_date_time_format());