private function _setWSSEHeaders() { $user = new \SoapVar($this->_config->merchantID, XSD_STRING, null, $this->_config->wsseNS, null, $this->_config->wsseNS); $pass = new \SoapVar($this->_config->apiKey, XSD_STRING, null, $this->_config->typeNS, null, $this->_config->wsseNS); $username_token = new \stdClass(); $username_token->Username = $user; $username_token->Password = $pass; $username_token = new \SoapVar($username_token, SOAP_ENC_OBJECT, null, $this->_config->wsseNS, 'UsernameToken', $this->_config->wsseNS); $security = new \stdClass(); $security->UsernameToken = $username_token; $security = new \SoapVar($security, SOAP_ENC_OBJECT, null, $this->_config->wsseNS, 'Security', $this->_config->wsseNS); $header = new \SoapHeader($this->_config->wsseNS, 'Security', $security, true); $this->_soapClient->__setSoapHeaders($header); }
/** * 获取客户端, 会设置一些header * @param unknown $clazz * @param unknown $method * @param unknown $beanId * @return SoapClient */ private function getSoapClient($clazz, $method, $beanId, $userId = '') { $soapClient = new SoapClient(null, array('uri' => SOAP_URI, 'location' => SOAP_LOCATION, 'soap_version' => SOAP_1_2, 'style' => SOAP_RPC, 'trace' => true)); $header = new SoapHeader(SOAP_NAMESPACE, 'field', (object) array(new SoapVar($beanId, XSD_STRING, null, null, 'beanId', SOAP_NAMESPACE), new SoapVar($clazz, XSD_STRING, null, null, 'clazz', SOAP_NAMESPACE), new SoapVar($method, XSD_STRING, null, null, 'methodName', SOAP_NAMESPACE), new SoapVar($userId, XSD_STRING, null, null, 'userId', SOAP_NAMESPACE), new SoapVar('testing', XSD_STRING, null, null, 'token', SOAP_NAMESPACE))); $soapClient->__setSoapHeaders($header); return $soapClient; }
function createRatesClient() { $client = new SoapClient("EstimatingService.wsdl", array('trace' => true, 'location' => "https://webservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx", 'uri' => "http://purolator.com/pws/datatypes/v1", 'login' => PRODUCTION_KEY, 'password' => PRODUCTION_PASS)); $headers[] = new SoapHeader('http://purolator.com/pws/datatypes/v1', 'RequestContext', array('Version' => '1.0', 'Language' => 'en', 'GroupID' => 'xxx', 'RequestReference' => 'Rating Example')); $client->__setSoapHeaders($headers); return $client; }
/** * You can specify a custom import. * @return bool */ public function fetchData() { $wsdl = FleximportConfig::get("SEMIRO_SOAP_PARTICIPANTS_WSDL"); $soap = new SoapClient($wsdl, array('trace' => 1, 'exceptions' => 0, 'cache_wsdl' => $GLOBALS['CACHING_ENABLE'] || !isset($GLOBALS['CACHING_ENABLE']) ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); $file = strtolower(substr($wsdl, strrpos($wsdl, "/") + 1)); $soapHeaders = new SoapHeader($file, 'Header', array('pw' => FleximportConfig::get("SEMIRO_SOAP_PASSWORD"))); $soap->__setSoapHeaders($soapHeaders); $result = $soap->getTeilnehmerXML(array('pw' => FleximportConfig::get("SEMIRO_SOAP_PASSWORD"))); if (is_a($result, "SoapFault")) { throw new Exception("SOAP-error: " . $result->faultstring); } $fields = array(); $doc = new DOMDocument(); $doc->loadXML(studip_utf8decode($result->return)); $seminar_data = array(); foreach ($doc->getElementsByTagName("teilnehmer") as $seminar) { $seminar_data_row = array(); foreach ($seminar->childNodes as $attribute) { if ($attribute->tagName) { if (!in_array(studip_utf8decode(trim($attribute->tagName)), $fields)) { $fields[] = studip_utf8decode(trim($attribute->tagName)); } $seminar_data_row[] = studip_utf8decode(trim($attribute->nodeValue)); } } $seminar_data[] = $seminar_data_row; } $this->table->createTable($fields, $seminar_data); }
private function getSoapClient() { ini_set('max_execution_time', 3600); date_default_timezone_set("CET"); $settings = SoapSetting::getDefaultSetting($this->ID); $this->ID = $settings->ID; if ($version) { $settings->version = $version; } $soapClient = new \SoapClient($settings->connection_uri . "version" . $settings->version . "/?xml", array('trace' => 1)); $soapHeader = $settings->soap_header; $lastToken = $settings->last_token; if (!$soapHeader || date("z", $lastToken) != date("z", time())) { $authentification = $soapClient->GetAuthentificationToken(array('Username' => $settings->username, 'Userpass' => $settings->password)); if (isset($authentification->Token)) { $headerbody = new \stdClass(); $headerbody->UserID = $authentification->UserID; $headerbody->Token = $authentification->Token; $headerbody->Username = $settings->username; $serializedHeader = serialize($headerbody); $settings->soap_header = $serializedHeader; $settings->last_token = time(); $settings->save(); } } $soapHeader = $settings->soap_header; $headerbody = unserialize($soapHeader); $header = new \SOAPHeader('Authentification', 'verifyingToken', $headerbody, false); $this->instance = $soapClient->__setSoapHeaders($header); }
public function soapClient($method, $callParams, $scOptions = array()) { $wsdl = $this->_getWsdl($method); $result = null; if (!isset($scOptions['soap_version'])) { $scOptions['soap_version'] = SOAP_1_2; } if (!isset($scOptions['trace'])) { $scOptions['trace'] = 1; } if (!isset($scOptions['exceptions'])) { $scOptions['exceptions'] = 0; } try { $soapClient = new SoapClient($wsdl, $scOptions); if ($actionHeader = $this->_getSoapHeader($method)) { $soapClient->__setSoapHeaders($actionHeader); } $result = $this->_soapClientCall($method, $soapClient, $callParams); if ($result instanceof SoapFault) { $this->log($result->faultstring); $result = '[soapfault]'; } } catch (SoapFault $sf) { $this->log($sf->faultstring); $result = '[soapfault]'; } return $result; }
/** * Get the SOAP client * @return \SoapClient */ private function getClient() { if (!isset($this->client)) { $this->client = new \SoapClient($this->wsdl['rates'], ['trace' => 1]); $this->client->__setSoapHeaders($this->requestHeader); } return $this->client; }
/** * @param Zend_Config $xml */ public function __construct(Zend_Config $xml) { // init $this->environment = $xml->mode == 'sandbox' ? 'sandbox' : ''; $credentials = $xml->config->{$xml->mode}; // create paypal interface $wsdl = sprintf('https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl', $this->environment); $location = sprintf('https://api-3t.sandbox.paypal.com/2.0', $this->environment); $this->client = new SoapClient($wsdl, array('location' => $location)); // auth $auth = new stdClass(); $auth->Credentials = new stdClass(); $auth->Credentials->Username = $credentials->api_username; $auth->Credentials->Password = $credentials->api_password; $auth->Credentials->Signature = $credentials->api_signature; $header = new SoapHeader('urn:ebay:api:PayPalAPI', 'RequesterCredentials', $auth); $this->client->__setSoapHeaders($header); }
public function getClient() { $params = Yii::app()->params['dorogiMos']; $username = $params['login']; $password = $params['password']; $wsse_header = new WsseAuthHeader($username, $password); $client = new SoapClient($params['server']); $client->__setSoapHeaders(array($wsse_header)); return $client; }
function cvm_get_client() { global $cvm; $client = new SoapClient($cvm['wsdl'], array("trace" => true, "exceptions" => true, "cache_wsdl" => false)); if (isset($cvm['token'])) { $header = new SoapHeader($cvm['ns'], 'sessaoIdHeader', $cvm['token']); $client->__setSoapHeaders($header); } return $client; }
private function _temandoConnect($connect_url, $username, $password) { ini_set("soap.wsdl_cache_enabled", "1"); $wsse_url = 'wsse:http://schemas.xmlsoap.org/ws/2002/04/secext'; $soap_client = new \SoapClient($connect_url, array('soap_version' => SOAP_1_2)); $headerSecurityStr = '<Security><UsernameToken><Username>' . $username . '</Username><Password>' . $password . '</Password></UsernameToken></Security>'; $headerSecurityVar = new \SoapVar($headerSecurityStr, XSD_ANYXML); $soapHeader = new \SoapHeader($wsse_url, 'soapenv:Header', $headerSecurityVar); $soap_client->__setSoapHeaders(array($soapHeader)); return $soap_client; }
/** * @throws Exception\ConnectionException */ protected function initializeClient() { try { $this->client = $this->factory->create($this->url, $this->options); if ($this->headers) { $this->client->__setSoapHeaders($this->headers); } } catch (\SoapFault $soapFault) { throw new ConnectionException('Client failed to connect', 0, $soapFault); } }
public function register(Application $app) { $app['database_connection'] = $app->share(function ($app) { $config = new Configuration(); $connectionParams = ['dbname' => 'app', 'user' => 'some_user', 'password' => 'some_password', 'host' => 'some_host', 'charset' => 'utf8']; return DriverManager::getConnection($connectionParams, $config); }); $app['entity_manager'] = $app->share(function ($app) { return EntityManager::create($app['database_connection'], Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Entity/'])); }); $app['billing_service_client'] = $app->share(function ($app) { $soapClient = new \SoapClient(__DIR__ . "/../../config/billing-service.wsdl", ['features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'classmap' => $app['soap_classmap']]); $soapClient->__setLocation('http://192.168.99.100:81/api/64.0'); $result = $soapClient->login(['username' => '*****@*****.**', 'password' => 'vA71jAPgJFG83a7v']); $sessionKey = $result->result->Session; $sessionHeader = new SoapHeader('http://api.zuora.com/', 'SessionHeader', ['session' => $sessionKey]); $soapClient->__setSoapHeaders($sessionHeader); return $soapClient; }); $app['zuora_client'] = $app->share(function ($app) { $soapClient = new \SoapClient(__DIR__ . "/../../config/billing-service.wsdl", ['features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'classmap' => $app['soap_classmap']]); $soapClient->__setLocation('https://apisandbox.zuora.com/apps/services/a/64.0'); $result = $soapClient->login(['username' => '*****@*****.**', 'password' => 'vA71jAPgJFG83a7v']); $sessionKey = $result->result->Session; $sessionHeader = new SoapHeader('http://api.zuora.com/', 'SessionHeader', ['session' => $sessionKey]); $soapClient->__setSoapHeaders($sessionHeader); return $soapClient; }); $app['zuora_production_client'] = $app->share(function ($app) { $soapClient = new \SoapClient(__DIR__ . "/../../config/billing-service-read-only.wsdl", ['features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'classmap' => $app['soap_classmap']]); $soapClient->__setLocation('https://www.zuora.com/apps/services/a/64.0'); $result = $soapClient->login(['username' => '*****@*****.**', 'password' => 'rFBDQfJvPsDoN5r7']); $sessionKey = $result->result->Session; $sessionHeader = new SoapHeader('http://api.zuora.com/', 'SessionHeader', ['session' => $sessionKey]); $soapClient->__setSoapHeaders($sessionHeader); return $soapClient; }); $app['account_finder'] = $app->share(function ($app) { return new AccountFinder($app['zuora_client'], $app['entity_manager']); }); $app['replay'] = $app->share(function ($app) { return new Replay($app['entity_manager']->getRepository('\\Jimdo\\Payment\\Billing\\ReplayAndCompare\\Entity\\Log'), $app['zuora_client'], new IdFinder(new ZObjectRepository($app['zuora_production_client']), new ZObjectRepository($app['zuora_client']))); }); $app['compare'] = $app->share(function ($app) { return new Compare(new ObjectTree($app['zuora_production_client']), new ObjectTree($app['zuora_client']), new Differ(new Comparator([]))); }); $app['some_account'] = $app->share(function ($app) { return new SomeAccount($app['database_connection']); }); $app['product_catalog'] = $app->share(function ($app) { return new ProductCatalog($app['zuora_client']); }); $app->register(new MonologServiceProvider(), ['monolog.logfile' => 'php://stderr']); }
/** * Creates a SOAP client and initializes the headers etc * * @return \SoapClient|SoapClient */ protected function getSoapClient() { if ($this->soap === null) { // Refactor to somewhere $options = array('trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS); $this->soap = new \SoapClient($this->provider->getBaseURL() . '/' . $this->service->getServiceURI(), $options); if ($this->needsAuthentication) { $this->soap->__setSoapHeaders(array($this->provider->getAuthentication()->getHeader())); } } return $this->soap; }
/** * Constructor */ function __construct($storeId = NULL) { $this->setStoreId($storeId); $this->_config = $config = Mage::getModel('mailup/config'); /* @var $config MailUp_MailUpSync_Model_Config */ $urlConsole = Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $this->storeId); $WSDLUrl = 'http://' . $urlConsole . '/services/WSMailUpImport.asmx?WSDL'; $user = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId); $password = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId); $headers = array('User' => $user, 'Password' => $password); $this->header = new SOAPHeader($this->ns, 'Authentication', $headers); if ($this->_config()->isLogEnabled($this->storeId)) { Mage::log("Connecting to {$urlConsole} as {$user}"); } try { $this->soapClient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10)); $this->soapClient->__setSoapHeaders($this->header); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper("mailup")->__("Unable to connect to MailUp console")); } }
function soap_mpesa_get() { $userId = $this->post('userId'); ini_set('default_socket_timeout', '300'); ini_set("soap.wsdl_cache_enabled", 0); //$soapURL ='https://182.19.20.182:81/mcommerce/pgService?wsdl'; $soapURL = 'http://182.19.20.182:81/mcommerce.webservices/pgService?wsdl'; echo '<pre>API URL : ' . $soapURL . '<br>'; $soapParameters = array('Userid' => "aJtlkG0NQTRBaLgVt4YC4A==", 'Password' => "7p/MAUl80KP+FdRERRyvlQ=="); echo 'Authentication Data <br>'; print_r($soapParameters); //$soapParameters = Array('login' => "aJtlkG0NQTRBaLgVt4YC4A==", 'password' => "7p/MAUl80KP+FdRERRyvlQ==") ; $soapFunction = "processPayment"; echo 'soap method : ' . $soapFunction . ' <br>'; //$soapFunctionParameters = Array('MCODE'=>'0021225252','TXNDATE' =>date('dmY'),'TRANSREFNO'=>time(),'MSISDN'=>'9556644964','AMT'=>'1.00','NARRATION'=>'shopping with mpes','mPIN'=>'1111'); ; $soapFunctionParameters = array('MCODE' => '0001000269', 'txnDate' => date('dmY'), 'transRefNo' => time(), 'MSISDN' => '9556644964', 'amt' => '1.00', 'narration' => 'shopping with mpes', 'surcharge' => '0', 'mPin' => '1111'); echo 'soap method parameter <br>'; print_r($soapFunctionParameters); $soapClient = new SoapClient($soapURL); // soap header $headerbody = array(); $ns = "http://paymentgateway.mcommerce/"; //$headerbody=array('Userid' => "", 'Password' => "7p/MAUl80KP+FdRERRyvlQ=="); $username = new SoapHeader($ns, 'Userid', 'aJtlkG0NQTRBaLgVt4YC4A=='); $password = new SoapHeader($ns, 'Password', '7p/MAUl80KP+FdRERRyvlQ=='); echo '<b>add soap header :</b> <br>'; //$soapClient->__setSoapHeaders($ns,null,$headerbody); $soapClient->__setSoapHeaders(array($username, $password)); echo '<b>soap header set done:</b> <br>'; echo '<b>soap client init :</b> <br>'; print_r($soapClient); echo 'calling soap method and show result <br>'; //$soapResult = $soapClient->__soapCall($soapFunction, $soapFunctionParameters) ; //$soapResult = $soapClient->processPayment('0021225252',date('dmY'),time(),'9556644964','1.0','shopping with mpesa','0','1111') ; //$soapResult = $soapClient->processPayment($soapFunctionParameters) ; $soapResult = $soapClient->{$soapFunction}($soapFunctionParameters); print_r($soapResult); echo '</pre>'; die; //if(is_array($soapResult) && isset($soapResult['someFunctionResult'])) { if (is_array($soapResult)) { // Process result. echo '<pre>'; print_r($soapResult); die; } else { // Unexpected result if (function_exists("debug_message")) { debug_message("Unexpected soapResult for {$soapFunction}: " . print_r($soapResult, TRUE)); } } }
function createPWSSOAPClient() { /** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and * header information **/ //Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials $client = new SoapClient("./wsdl/serviceavailabilityservice.wsdl", array('trace' => true, 'location' => "https://webservices.purolator.com/PWS/V1/ServiceAvailability/ServiceAvailabilityService.asmx", 'uri' => "http://purolator.com/pws/datatypes/v1", 'login' => PRODUCTION_KEY, 'password' => PRODUCTION_PASS)); //Define the SOAP Envelope Headers $headers[] = new SoapHeader('http://purolator.com/pws/datatypes/v1', 'RequestContext', array('Version' => '1.3', 'Language' => 'en', 'GroupID' => 'xxx', 'RequestReference' => 'Rating Example', 'UserToken' => USER_TOKEN)); //Apply the SOAP Header to your client $client->__setSoapHeaders($headers); return $client; }
/** * Method to return the SoapClient object, initiating a connection if one doesn't already exist. * * @return \SoapClient * @throws \SoapFault */ protected function getSoapClient() { switch (true) { case !$this->SoapClient instanceof SoapClient: if ($this->SoapOpts) { $this->SoapClient = new SoapClient($this->SoapUrl, $this->SoapOpts); } else { $this->SoapClient = new SoapClient($this->SoapUrl); } default: $this->SoapClient->__setSoapHeaders($this->Auth->doLogin()); return $this->SoapClient; } }
private function getSoapSingleton() { if (self::$soapClient == null) { $headerXml = $this->getSoapHeaderXml(); $baseUrl = $this->getTransactionServer(); $soapWsdlUrl = $baseUrl . '/service/PayUAPI?wsdl'; $headerbody = new SoapVar($headerXml, XSD_ANYXML, null, null, null); $soapHeader = new SOAPHeader(self::NS, 'Security', $headerbody, true); $soap_client = new SoapClient($soapWsdlUrl, array('trace' => 1, 'exception' => 0)); $soap_client->__setSoapHeaders($soapHeader); self::$soapClient = $soap_client; return $soap_client; } return self::$soapClient; }
/** * Create a PHP SOAP client and configure it * * @return PiSoapClientManager */ public function create() { if (empty($this->wsdl)) { throw new \InvalidArgumentException('The wsdl is not defined'); } // we create the client SOAP $this->soapClient = new \SoapClient($this->wsdl, $this->options); // we add headers if (count($this->headers) >= 1) { $this->soapClient->__setSoapHeaders($this->headers); } if (!empty($this->url)) { $this->soapClient->__setLocation($this->url); } return $this; }
/** * @return mixed * * @throws \Collector\ClientException */ public function call($method, $data) { $path = $this->environment . $this->wsdl . self::WSDL_SUFFIX; $client = new \SoapClient($path, $this->options); $headers = array(); $namespace = self::SCHEMA_PREFIX . $this->schema; $headers[] = new \SoapHeader($namespace, 'ClientIpAddress', $this->ip); $headers[] = new \SoapHeader($namespace, 'Username', $this->username); $headers[] = new \SoapHeader($namespace, 'Password', $this->password); $client->__setSoapHeaders($headers); try { $results = $client->{$method}($data); } catch (\Exception $e) { throw new ClientException($e->getMessage(), $e->getCode(), $e); } return $results; }
/** * Получене отчета * @param $inn * @return SimpleXMLElement */ public function Statement($inn) { $client = new SoapClient($this->wsdlUrl, array("trace" => 1, "exceptions" => 0)); $AuthCredentialHeader = array('UserName' => $this->UserName, 'Password' => $this->Password); $uthenticationIdentity = array("Name" => $this->Name, 'Key' => $this->Key); $headers = array(); $headers[] = new SoapHeader($this->url, 'AuthenticationCredential', $AuthCredentialHeader, 'false'); $headers[] = new SoapHeader($this->url, 'AuthenticationIdentity', $uthenticationIdentity, 'false'); $client->__setSoapHeaders($headers); $result = $client->Statement(array('forID' => $inn)); //проверка на соеденения // $this->prn($result); // $this->prn($result->faultcode); if (is_soap_fault($result)) { if ($result->faultcode == 'StatementFailed') { $this->result['zona'] = 1; $this->result['messege'] = 'Неправельный код ИНН.'; $this->result['status'] = false; return $this->result; } elseif ($result->faultcode == 'soap:Server') { $this->result['zona'] = 1; $this->result['messege'] = 'Ошибка при виполнении запроса в ПВБКИ'; $this->result['status'] = false; return $this->result; } } $arr = (array) $result; $load = simplexml_load_string($arr["Report-StatementResult"]); // $this->prn($load->); //проверка на данные if (isset($load->Contract) && !empty($load->Contract)) { $this->result['zona'] = 0; $this->result['messege'] = 'В базе ПВБКИ нет информации про клиента.'; $this->result['status'] = false; return $this->result; } //провенрка на ощибки //todo:реалезовать даный метод if ($this->debag) { $this->writeFile('tmp/PvbkiResult.xml', $arr["Report-StatementResult"]); } return $this->getOverdueAmount($load); }
private function preparerequest() { //PASSWORD DIGEST $time = gmdate('Y-m-d\\TH:i:s'); $created = gmdate('Y-m-d\\TH:i:s\\Z'); $nonce = mt_rand(); $nonce_date_pwd = pack("A*", $nonce) . pack("A*", $created) . pack("H*", sha1($this->api_password)); $passwordDigest = base64_encode(pack('H*', sha1($nonce_date_pwd))); $ENCODEDNONCE = base64_encode($nonce); //SET CONNECTION DETAILS $soapclient_options = array(); $soapclient_options['cache_wsdl'] = 'WSDL_CACHE_NONE'; $soapclient_options['stream_context'] = stream_context_create(array('http' => array('protocol_version' => '1.0', 'header' => 'Connection: Close'))); $soapclient_options['local_cert'] = dirname(__FILE__) . "/certificate.pem"; $soapclient_options['passphrase'] = $this->api_certificate_passphrase; $soapclient_options['trace'] = true; $soapclient_options['ssl_method'] = 'SOAP_SSL_METHOD_SSLv3'; $soapclient_options['location'] = $this->locationforrequest; $soapclient_options['soap_version'] = 'SOAP_1_1'; //launch soap client //$client = new SoapClient(dirname(__FILE__) . "/SAPI/ShippingAPI_V2_0_8.wsdl", $soapclient_options); $client = new SoapClient(dirname(__FILE__) . "/reference/ShippingAPI_V2_0_8.wsdl", $soapclient_options); $client->__setLocation($soapclient_options['location']); //headers needed for royal mail//D8D094FC22716E3EDE14258880881317 $HeaderObjectXML = '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-D8D094FC22716E3EDE14258880881317"> <wsse:Username>' . $this->api_username . '</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' . $passwordDigest . '</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $ENCODEDNONCE . '</wsse:Nonce> <wsu:Created>' . $created . '</wsu:Created> </wsse:UsernameToken> </wsse:Security>'; //push the header into soap $HeaderObject = new SoapVar($HeaderObjectXML, XSD_ANYXML); //push soap header $header = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd', 'Security', $HeaderObject); $client->__setSoapHeaders($header); return $client; }
function Image2PdfConvert() { if ($this->apiKey == "") { return "Please specify ApiKey"; } if ($this->outputPdfLocation == "") { return "Please specify Output pdf File Location"; } if ($this->inputImageLocation == "") { return "Please specify input Image Location"; } else { $fileStream = file_get_contents($this->inputImageLocation); } $parameters = array("FileByteStream" => $fileStream); $wsdl = "http://apis.pdfaid.com/pdfaidservices/Service1.svc?wsdl"; $endpoint = "http://apis.pdfaid.com/pdfaidservices/Service1.svc"; $option = array('trace' => 1); $client = new SoapClient($wsdl, $option); $headers[] = new SoapHeader('http://tempuri.org/', 'apikey', $this->apiKey); $headers[] = new SoapHeader('http://tempuri.org/', 'imageQuality', $this->imageQuality); $headers[] = new SoapHeader('http://tempuri.org/', 'pdfTitle', $this->pdfTitle); $headers[] = new SoapHeader('http://tempuri.org/', 'pdfAuthor', $this->pdfAuthor); $headers[] = new SoapHeader('http://tempuri.org/', 'pdfSubject', $this->pdfSubject); $headers[] = new SoapHeader('http://tempuri.org/', 'pdfKeywords', $this->pdfKeywords); $headers[] = new SoapHeader('http://tempuri.org/', 'responseResult', "test"); $client->__setSoapHeaders($headers); $result = $client->Image2Pdf($parameters); $clientResponse = $client->__getLastResponse(); if ($clientResponse == "APINOK") { return "API is not Valid"; } if ($clientResponse == "NOK") { return "Error Occured"; } else { $fp = fopen($this->outputPdfLocation, 'wb'); fwrite($fp, $result->FileByteStream); fclose($fp); return "OK"; } }
public static function runServiceFunc($url, $func, $parame) { //set_time_limit(18000); ini_set('default_socket_timeout', 600); $begin_time = microtime(); $soap = new SoapClient($url, array('connection_timeout' => 600)); $token = wcf_comm::get_user_token(); if (!empty($token)) { $header = new SoapHeader('wy', 'UserToken', $token, false, SOAP_ACTOR_NEXT); $soap->__setSoapHeaders(array($header)); } //动态调用func对应的函数,并使用参数parame // var_dump($func); // var_dump($parame); $result = $soap->{$func}($parame); $endtime_time = microtime(); $excute_time = $endtime_time - $begin_time; //write_wcf_execute_logs($func, "$begin_time,$endtime_time,$excute_time"); //设空 unset($soap); //返回 return $result; }
/** * Query the SOAP webservice. * * @param string $method Name of the method to call. * @param array $query Parameters for the query. * @return array Results of the query. * @throws CakeException */ public function query($method, $query = null) { if (!$this->connected) { throw new CakeException(__('Not connected')); } if ($method == 'describe') { return $this->listSources(); } if ($query) { $query = $query[0]; } if (!class_exists($method)) { throw new CakeException(sprintf(__('Method %s does not exist in this API. Try rebuilding the classes from the WSDL.'), $method)); } $Class = new $method($query); $error = '-'; $this->startTimer($method); $start = microtime(true); try { $this->_SoapClient->__setSoapHeaders($this->_soapHeaders); $response = $this->_SoapClient->{$method}($Class); } catch (SoapFault $SoapFault) { $response = $SoapFault; $error = $SoapFault->faultstring; } $took = round((microtime(true) - $start) * 1000, 0); $this->stopTimer($method); $affected = '-'; if ($response instanceof SoapFault) { $this->_log($method, $query, $error, $affected, 0, $took); throw new CakeException($SoapFault->faultstring); } $result = $this->resultSet($response, $method); $count = $result ? count(Set::flatten((array) $result)) : 0; $this->_log($method, $query, $error, $affected, $count, $took); return $result; }
/** * Retrieves the calculated rate based on the shipment information. * * @return integer|float */ public function getResponse() { // initialize SOAP client $client = new SoapClient(self::RATE_WSDL); $funcs = $client->__getFunctions(); // initialize SOAP header $headerbody = array(self::USER_TOKEN => $this->_userToken); $header = new SoapHeader(self::HEADER, self::AUTH_HEADER, $headerbody); $client->__setSoapHeaders($header); // prepare parameters $query = array(self::SERVICE_TYPE => $this->_serviceType, self::SHIPMENT_TYPE => $this->_shipmentType, self::DESTINATION_VALUE => $this->_destinationValue, self::WEIGHT => $this->_weight, self::LENGTH => $this->_length, self::WIDTH => $this->_width, self::HEIGHT => $this->_height, self::VALUE => $this->_declaredValue, self::INSURANCE => true); // execute SOAP method try { $result = $client->Calculate($query); //catch soap fault } catch (SoapFault $soapfault) { $this->_exceptionFlag = true; $exception = $soapfault->getMessage(); preg_match_all('/: (.*?). at/s', $exception, $error, PREG_SET_ORDER); //Print error return $error[0][1]; } return $result->CalculateResult; }
/** * Creates a SoapClient with configured SoapConfig object and given additional settings. * * @param array $settings additional settings go here * * @return SoapClient * @throws InputException * @throws NoServerAvailableException * @throws \InvalidArgumentException */ public function create(array $settings = []) { // create soap settings, with given settings and platform settings $soapSettings = SoapSettings::loadFromArray($settings); // create a manager for endpoint management $manager = $this->createEndpointManager($settings); // replace the native soap client transport with a curl client $curlClient = $this->createCurlClient($soapSettings->toArray(), $manager); // build a SoapClient (extends the native soap client) $soapClient = new SoapClient($soapSettings, $manager, $curlClient); // set custom headers $soapHeaders = array_key_exists('soapHeaders', $settings) ? array_merge($settings['soapHeaders'], $this->config->getSoapHeaders()) : $this->config->getSoapHeaders(); $soapClient->__setSoapHeaders($soapHeaders); if ($this->config->hasConverter() === true) { $soapClient->setConverter($this->config->getConverter()); } if ($this->hasLogger() === true) { $soapClient->setLogger($this->logger); $this->logger->info('Created SoapClient for ' . $this->config->getPlatformConfig()->getPlatformName()); $this->logger->debug('Created SoapClient', ['SoapClient' => print_r($soapClient, true)]); $this->logger->debug('Settings', ['settings' => (array) $settings]); } return $soapClient; }
/** * Retrieving tracking information given the waybill number of the * shipment. * * @return array */ public function getTracking() { // initialize SOAP client $client = new SoapClient(self::TRACKING_WSDL, array()); $funcs = $client->__getFunctions(); // initialize SOAP header $headerbody = array(self::USER_TOKEN => $this->_userToken); $header = new SoapHeader(self::HEADER, self::AUTH_HEADER, $headerbody); $client->__setSoapHeaders($header); // prepare parameters $query = array(self::WAY_BILL_NO => $this->_wayBillNo); // execute SOAP method try { $result = $client->GetList($query); //catch soap fault } catch (SoapFault $soapfault) { $this->_exceptionFlag = true; $exception = $soapfault->getMessage(); preg_match_all('/: (.*?). at/s', $exception, $error, PREG_SET_ORDER); //Print error return $error[0][1]; } return $result; }
public function updateorderstatus() { //$from = 'Robin'; // sender //$subject = 'ABCD'; $message = 'Cron Job Running123456'; // message lines should not exceed 70 characters (PHP rule), so wrap it //$message = wordwrap($message, 70); // send mail $from = 'Arun'; // sender $subject = 'ABCD12345'; $wsdlUrl = Mage::getStoreConfig('unicom_options/unigroup/uniurl'); $wsdllUrl = Mage::getStoreConfig('unicom_options/unigroup/unilurl'); $username = Mage::getStoreConfig('unicom_options/unigroup/uniusername'); $password = Mage::getStoreConfig('unicom_options/unigroup/unipass'); /*$wsdlUrl = "https://demo.unicommerce.com/services/soap/uniware15.wsdl"; $wsdllUrl = "http://demo.unicommerce.com/services/soap/?version=1.5&facility=01"; $username = "******"; $password = "******"; */ $soapClient = new SoapClient($wsdlUrl, array('trace' => 1, 'exception' => 0)); $soapClient->__setLocation($wsdllUrl); $strWSSENS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; $objSoapVarUser = new SoapVar($username, XSD_STRING, NULL, $strWSSENS, "UserName", $strWSSENS); $objSoapVarPass = new SoapVar($password, XSD_STRING, NULL, $strWSSENS, "Password", $strWSSENS); $objWSSEAuth = new clsWSSEAuth($objSoapVarUser, $objSoapVarPass); $objSoapVarWSSEAuth = new SoapVar($objWSSEAuth, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS); $objWSSEToken = new clsWSSEToken($objSoapVarWSSEAuth); $objSoapVarWSSEToken = new SoapVar($objWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS); $objSoapVarHeaderVal = new SoapVar($objSoapVarWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'Security', $strWSSENS); $objSoapVarWSSEHeader = new SoapHeader($strWSSENS, 'Security', $objSoapVarHeaderVal, true); $soapClient->__setSoapHeaders(array($objSoapVarWSSEHeader)); //Mage::app('default'); $model = Mage::getModel('rcredit/rcredit'); $order = new Mage_Sales_Model_Order(); $order_details = $model->orderids(); //print_r($order_details); $i = 0; $check = array(); $msg = array(); foreach ($order_details as $details) { $msg[] = $details[order_id]; $shipping = $soapClient->GetSaleOrder(array('SaleOrder' => array('Code' => $details[order_id]))); //echo '<pre>'; //print_r($shipping); $delivcnt = count($shipping->SaleOrder->ShippingPackages->ShippingPackage); foreach ($shipping->SaleOrder->ShippingPackages as $v) { $order->loadByIncrementId($details[order_id]); $payment = $order->getPayment()->getMethodInstance()->getCode(); $customer_status = $model->customerstatus($order->getCustomerEmail()); if ($delivcnt > 1) { $deliverDate = $v[$delivcnt - 1]->DeliveredOn; $vstatus = $v[$delivcnt - 1]->StatusCode; } else { $deliverDate = $v->DeliveredOn; $vstatus = $v->StatusCode; } if ($vstatus == 'DELIVERED') { $day = explode('T', $deliverDate); if ($day[0] >= $customer_status['credit_start_date']) { //echo 'In Second Cycle'.$details[cycle].'-->'.$details[order_id].'-->'.$details[order_value].'-->'.$order->getCustomerEmail().'-->'.$customer_status[credit_cycle].'-->'.$customer_status[utlized_amt]; //echo '<br/>'; $model->updateordercycle($details[order_id], $customer_status[credit_cycle]); } $model->updateorderdate($details[order_id], $day[0]); } $i++; } //mail("*****@*****.**",$subject,$details[order_id],"From: $from\n"); $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('increment_id', $details[order_id])->getFirstItem(); if ($order->getStatus() == 'Canceled' || $order->getStatus() == 'canceled') { $order->loadByIncrementId($details[order_id]); $payment = $order->getPayment()->getMethodInstance()->getCode(); if ($payment == 'rcredit') { $payment_status = 'Refund'; $order_cycle_value = $model->ordercyclehistory($details[order_id]); //Getting the cycle using the order_id. $cycle = $order_cycle_value['cycle']; $customer_email = $order->getCustomerEmail(); $grandtotal = round($details[order_value], 2); $customer_status = $model->customerstatus($customer_email); // Getting the customer status from the Shopper Credit Module $customer_credit_limit = $customer_status['credit_limit']; // Getting customer's credit limit. $customer_current_bal = $customer_status['bal_amt']; // Getting customer's current balance $balance_amount = $customer_status['bal_amt'] + $grandtotal; // Calculating the updated balance after sucessful purchase. $utlized_amt = $customer_status['utlized_amt']; // Getting customer's current balance $total_used_amt = $utlized_amt - $grandtotal; // Getting the total utlized amt. $pay_interval = $customer_status['pay_interval']; // Getting customer's payinterval date $expiry_date = $customer_status['enddate']; // Getting expiry date for the customer $action = 'Refund due to cancellation'; $todate = date("Y-m-d"); $order_status = "Cancel"; if ($order_cycle_value['action'] != 'Cancel') { $model->cancelledorderdetails($details[order_id], $total_used_amt, $balance_amount, $action, $order_status); $model->updateoncancel($grandtotal, $customer_email, $cycle); } } } } }