public function __doRequest($request, $location, $action, $version, $one_way = FALSE) { if (!$this->timeout) { // Call via parent because we require no timeout $response = parent::__doRequest($request, $location, $action, $version, $one_way); } else { // Call via Curl and use the timeout $curl = curl_init($location); curl_setopt($curl, CURLOPT_VERBOSE, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $request); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); $response = curl_exec($curl); if (curl_errno($curl)) { throw new Exception(curl_error($curl)); } curl_close($curl); } // Return? if (!$one_way) { return $response; } }
/** * __doRequest * * @param string $request * @param string $location * @param string $action * @param int $version * @param int $oneWay * @return string */ public function __doRequest($request, $location, $action, $version, $oneWay = 0) { $aFind = array(":ns1", "ns1:", "\n", "\r"); $sReplace = ''; $newrequest = str_replace($aFind, $sReplace, $request); return parent::__doRequest($newrequest, $location, $action, $version, $oneWay); }
function __doRequest($request, $location, $saction, $version) { $dom = new DOMDocument(); $dom->loadXML($request); $objWSSE = new WSSESoap($dom); /* Sign all headers to include signing the WS-Addressing headers */ $objWSSE->signAllHeaders = TRUE; $objWSSE->addTimestamp(); /* create new XMLSec Key using RSA SHA-1 and type is private key */ $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private')); /* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */ $objKey->loadKey(PRIVATE_KEY, TRUE); // Sign the message - also signs appropraite WS-Security items $objWSSE->signSoapDoc($objKey); /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */ $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE)); $objWSSE->attachTokentoSig($token); $request = $objWSSE->saveXML(); $dom = new DOMDocument(); $dom->loadXML($request); $objWSA = new WSASoap($dom); $objWSA->addAction($saction); $objWSA->addTo($location); $objWSA->addMessageID(); $objWSA->addReplyTo(); $request = $objWSA->getDoc()->saveXML(); return parent::__doRequest($request, $location, $saction, $version); }
/** * Do request * * @param string $request * @param string $location * @param string $action * @param int $version * @param int $one_way * @return string */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { $this->_logRequest($location, $action, $version, $request); $response = parent::__doRequest($request, $location, $action, $version, $one_way); $this->_logResponse($location, $action, $version, $response); return $response; }
function __doRequest($request, $location, $saction, $version) { $doc = new DOMDocument(); $doc->loadXML($request); $objWSSE = new WSSESoap($doc); $objWSSE->addUserToken($this->username, $this->password, FALSE); return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version); }
public function __doRequest($request, $location, $saction, $version) { $doc = new DOMDocument('1.0'); $doc->loadXML($request); $objWSSE = new WSSESoap($doc); /* add Timestamp with no expiration timestamp */ $objWSSE->addTimestamp(); /* create new XMLSec Key using AES256_CBC and type is private key */ $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private')); /* load the private key from file - last arg is bool if key in file (true) or is string (false) */ $objKey->loadKey(PRIVATE_KEY, true); /* Sign the message - also signs appropiate WS-Security items */ $options = array("insertBefore" => false); $objWSSE->signSoapDoc($objKey, $options); /* Add certificate (BinarySecurityToken) to the message */ $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE)); /* Attach pointer to Signature */ $objWSSE->attachTokentoSig($token); $objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC); $objKey->generateSessionKey(); $siteKey = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public')); $siteKey->loadKey(SERVICE_CERT, true, true); $options = array("KeyInfo" => array("X509SubjectKeyIdentifier" => true)); $objWSSE->encryptSoapDoc($siteKey, $objKey, $options); $retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version); $doc = new DOMDocument(); $doc->loadXML($retVal); $options = array("keys" => array("private" => array("key" => PRIVATE_KEY, "isFile" => true, "isCert" => false))); $objWSSE->decryptSoapDoc($doc, $options); return $doc->saveXML(); }
function NewDocRequest($order_id) { global $customer_id, $abo_id; FB::info('NewDocRequest Nummer' . $abo_id); if (SOAP_SERVER != '') { $client = new SoapClient(null, array('location' => SOAP_SERVER, 'uri' => SOAP_NAMESPACE, 'trace' => true, 'connection_timeout' => 5)); $response = $client->__doRequest('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <NewDocRequest xmlns="test"> <Nummer>' . $abo_id . '</Nummer> <Soort>B</Soort> <Weborder>' . $order_id . '</Weborder> </NewDocRequest> </SOAP-ENV:Body> </SOAP-ENV:Envelope>', SOAP_SERVER, SOAP_NAMESPACE, SOAP_1_2); if ($response) { $dom = new DOMDocument(); $dom->loadXML($response); $xPath = new DOMXPath($dom); $result = array(); if ($xPath->evaluate("//Status")->item(0)->nodeValue == 0) { $result = $xPath->evaluate("//StatusTekst")->item(0)->nodeValue; } else { $result = $xPath->evaluate("//Document")->item(0)->nodeValue; } } } return $result; }
public function __doRequest($request, $location, $action, $version = SOAP_1_1, $one_way = NULL) { $xml = explode("\r\n", parent::__doRequest($request, $location, $action, $version, $one_way = NULL)); dump($xml); $response = preg_replace('/^(\\x00\\x00\\xFE\\xFF|\\xFF\\xFE\\x00\\x00|\\xFE\\xFF|\\xFF\\xFE|\\xEF\\xBB\\xBF)/', "", $xml[5]); return $response; }
/** * __doRequest override of SoapClient * * @param string $request The XML SOAP request. * @param string $location The URL to request. * @param string $action The SOAP action. * @param int $version The SOAP version. * @param int|null $oneWay * @uses parent::__doRequest * @return string The XML SOAP response. * @throws Exception When PHP XSL extension is not enabled or WSDL file isn't readable. */ public function __doRequest($request, $location, $action, $version, $oneWay = null) { if (!extension_loaded('xsl')) { throw new Exception('PHP XSL extension is not enabled.'); } $newRequest = $this->transformIncomingRequest($request); return parent::__doRequest($newRequest, $location, $action, $version, $oneWay); }
function getTopology() { $request = "<?xml version='1.0' encoding='UTF-8'?>" . "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " . "xmlns:xsd='http://www.w3.org/2001/XMLSchema' " . "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" . "<soapenv:Header>" . "<SOAPAction></SOAPAction>" . "</soapenv:Header>" . "<soapenv:Body>" . "<nmwg:message type='TSQueryRequest' id='msg1' " . "xmlns:nmwg='http://ggf.org/ns/nmwg/base/2.0/' " . "xmlns:xquery='http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/'>" . "<nmwg:metadata id='meta1'>" . "<nmwg:eventType>http://ggf.org/ns/nmwg/topology/20070809</nmwg:eventType>" . "</nmwg:metadata>" . "<nmwg:data metadataIdRef='meta1' id='d1' />" . "</nmwg:message>" . "</soapenv:Body></soapenv:Envelope>"; //header("Content-Type:text/xml"); //echo $request; //die(); return parent::__doRequest($request, $this->serverUrl, "", 1); }
function __doRequest($request, $location, $action, $version, $one_way = NULL) { $dom = new DomDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; $dom->loadXML($this->getXMLData()); $request = $dom->saveXML(); return parent::__doRequest($request, $location, $action, $version, $one_way); }
public function __doRequest($request, $location, $action, $version, $one_way = 0) { $this->getService()->getLogger()->debug('SENT: ' . $action . PHP_EOL . trim($request)); $start = microtime(true); $result = parent::__doRequest($request, $location, $action, $version, $one_way); $this->getService()->getLogger()->debug('GOT: ' . $action . ' [' . strlen($result) . '] ' . sprintf("%0.4f", microtime(true) - $start) . 's' . PHP_EOL . trim($result) . PHP_EOL); return $result; }
public function __doRequestAndThrowExceptions($request, $location, $action, $version, $one_way = 0) { $returnValue = parent::__doRequest($request, $location, $action, $version, $one_way = 0); if (isset($this->__soap_fault) && $this->__soap_fault !== NULL) { // This is where the exception from __doRequest is stored. throw $this->__soap_fault; } return $returnValue; }
public function __doRequest($request, $location, $action, $version) { $parts = parse_url($location); if ($this->_port) { $parts['port'] = $this->_port; } $location = $this->buildLocation($parts); return parent::__doRequest($request, $location, $action, $version); }
/** * @param string $request * @param string $location * @param string $action * @param int $version * @param int $one_way * * @return string * @throws */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { $request = $this->appendXsiTypeForExtendedDatastructures($request); $result = parent::__doRequest($request, $location, $action, $version, $one_way); if (isset($this->__soap_fault) && $this->__soap_fault) { throw $this->__soap_fault; } return $result; }
/** * Overrides __doRequest to allow logging * the request and response */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { $this->logXML($action, $request, $this->__getLocation()); $response = parent::__doRequest($request, $location, $action, $version, $one_way); if (0 == $one_way) { $this->logXML($action . ':Response', $response); } return $response; }
function GetStockMaat($product_id, $maat, $data) { if (SOAP_SERVER != '') { $get_model_query = tep_db_query("select products_model, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'"); $get_model = tep_db_fetch_array($get_model_query); $client = new SoapClient(null, array('location' => SOAP_SERVER, 'uri' => SOAP_NAMESPACE, 'trace' => true, 'connection_timeout' => 5)); $response = $client->__doRequest('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:stockRequest> <Artikel>' . $get_model['products_model'] . '</Artikel> <Maat>' . $maat . '</Maat> </ns1:stockRequest> </SOAP-ENV:Body> </SOAP-ENV:Envelope>', SOAP_SERVER, SOAP_NAMESPACE, SOAP_1_2); if ($response) { $dom = new DOMDocument(); $dom->loadXML($response); $xPath = new DOMXPath($dom); if ($xPath->evaluate("//Status")->item(0)->nodeValue == 0) { $result = $xPath->evaluate("//StatusTekst")->item(0)->nodeValue; } else { //Article contains XML inside, need to reparse it $dom->loadXML('<xml>' . $xPath->evaluate("//Artikel")->item(0)->nodeValue . '</xml>'); $xPath = new DOMXPath($dom); $elements = $xPath->evaluate("//xml/*"); if ($maat == '') { foreach ($elements as $element) { if ($element->nodeName == 'Maten') { continue; } if ($element->nodeName == $data) { $result .= $element->nodeValue . ' '; } } } else { $maats = $xPath->evaluate("//xml/Maten/Maat"); if ($maats->length > 0) { foreach ($maats as $maat) { $elements = $xPath->evaluate("child::*", $maat); foreach ($elements as $element) { if ($element->nodeName == $data) { $result .= $element->nodeValue; } } } } } } } else { tep_mail('ABO Service Monitor', '*****@*****.**', 'SOAP Server offline', 'De SOAP Server op ' . STORE_NAME . ' - ' . HTTP_SERVER . ' is offline', STORE_NAME, STORE_OWNER_EMAIL_ADDRESS); $result .= $get_model['products_quantity']; } } else { $result = 'No SOAP server defined. Please check configuration'; } return $result; }
/** * {@inheritdoc} */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { $startTime = microtime(true); $response = parent::__doRequest($request, $location, $action, $version, $one_way); $this->lastDuration = (microtime(true) - $startTime) * 1000; $event = new RequestFinishedEvent($this->__getLastRequestHeaders(), $this->__getLastRequest(), $this->__getLastResponseHeaders(), $response, $this->lastDuration); $this->dispatcher->dispatch(NfqSoapEvents::REQUEST_FINISHED, $event); return $response; }
function __doRequest($request, $location, $action, $version) { $namespace = AC_NAMESPACE; $request = preg_replace('/<ns1:(\\w+)/', '<$1 xmlns="' . $namespace . '"', $request, 1); $request = preg_replace('/<ns1:(\\w+)/', '<$1', $request); $request = str_replace(array('/ns1:', 'xmlns:ns1="' . $namespace . '"'), array('/', 'xmlns="' . $namespace . '"'), $request); // parent call return parent::__doRequest($request, $location, $action, $version); }
function __doRequest($request, $location, $action, $version, $one_way = 0) { global $username, $password; $doc = new DOMDocument('1.0'); $doc->loadXML($request); $objWSSE = new WSSESoap($doc); $objWSSE->addUserToken($username, $password); $objWSSE->addTimestamp(); return parent::__doRequest($objWSSE->saveXML(), $location, $action, $version, $one_way); }
/** * {@inheritdoc} */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { $response = parent::__doRequest($request, $location, $action, $version); if (!$response) { return $response; } $matches = array(); preg_match('/<s:Envelope.*<\\/s:Envelope>/s', $response, $matches); return $matches[0]; }
public function __doRequest($request, $location, $action, $version, $one_way = 0){ $return = parent::__doRequest($request, $location, $action, $version, $one_way); /* * tutaj sprawdzamy co się dzieje na soap */ echo('<pre>'.htmlspecialchars(print_r(array($request, $location, $action, $version, $return), true)).'</pre>'); return $return; }
/** * Performs a SOAP request * * @param string $request The XML SOAP request. * @param string $location The URL to request. * @param string $action The SOAP action. * @param int $version The SOAP version. * @param int $oneWay If set to 1, this method returns nothing. Use this where a response is not expected. * @return string The XML SOAP response. */ public function __doRequest($request, $location, $action, $version, $oneWay = 0) { if (Configure::read('debug') === true) { $this->log($request, LogLevel::INFO); $this->log($location, LogLevel::INFO); $this->log($action, LogLevel::INFO); $this->log($version, LogLevel::INFO); } return parent::__doRequest($request, $location, $action, $version, $oneWay); }
/** * @inheritdoc */ public function __doRequest($request, $location, $action, $version, $oneWay = NULL) { if ($this->useCertificate()) { $request = $this->signRequest($request); } $this->logger->debug('Request to {location}: {request}', array('location' => $location, 'request' => $request)); $response = parent::__doRequest($request, $location, $action, $version, $oneWay); $this->logger->debug('Response to {location}: {response}', array('location' => $location, 'response' => $response)); return $response; }
/** * Do request into regon server * * @param string $request request * @param string $location location * @param string $action action * @param int $version version * @return string response */ public function __doRequest($request, $location, $action, $version = SOAP_1_2, $one_way = NULL) { $location = $this->location; $response = parent::__doRequest($request, $location, $action, $version, $one_way); $response = stristr(stristr($response, "<s:"), "</s:Envelope>", true) . "</s:Envelope>"; return $response; }
function __doRequest($request, $location, $action, $version, $one_way = 0) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; $dom->loadXML($request); Yii::trace($request); /** Setting namespaces **/ $dom->documentElement->setAttribute('xmlns:xs', 'http://www.w3.org/2001/XMLSchema'); $dom->documentElement->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $dom->documentElement->setAttribute('xmlns:gns', 'http://nordu.net/namespaces/2013/12/gnsbod'); $dom->documentElement->setAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion'); $dom->documentElement->setAttribute('xmlns:type', 'http://schemas.ogf.org/nsi/2013/12/connection/types'); $dom->documentElement->setAttribute('xmlns:head', 'http://schemas.ogf.org/nsi/2013/12/framework/headers'); /** Generating Correlation ID */ $dom->getElementsByTagName("correlationId")->item(0)->nodeValue = 'urn:uuid:' . $this->newGuid(); /** Setting prefixes of the elements **/ $this->changeTag($dom, "ConnectionTrace", "gns:ConnectionTrace"); $this->changeTag($dom, "reserve", "type:reserve"); $this->changeTag($dom, "reserveCommit", "type:reserveCommit"); $this->changeTag($dom, "provision", "type:provision"); $this->changeTag($dom, "p2ps", "p2p:p2ps"); /** Setting attributes **/ $this->setAttributeByTag($dom, "Connection", "index", "0"); $this->setAttributeByTag($dom, "criteria", "version", $this->version); $this->setAttributeByTag($dom, "p2p:p2ps", "xmlns:p2p", "http://schemas.ogf.org/nsi/2013/12/services/point2point"); $this->setAttributeByTag($dom, "parameter", "type", "protection"); $this->setEro($dom); $request = $dom->saveXML(); Yii::trace($request); return parent::__doRequest($request, $location, $action, $version); }
function __doRequest($request, $location, $action, $version) { $dom = new DomDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; $dom->loadXML($request); $hdr = $dom->createElement('soapenv:Header'); $secNode = $dom->createElement("wsse:Security"); $secNode->setAttribute("soapenv:mustUnderstand", "1"); $secNode->setAttribute("xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); $usernameTokenNode = $dom->createElement("wsse:UsernameToken"); $usernameTokenNode->setAttribute("wsu:Id", "UsernameToken-1"); $usernameTokenNode->setAttribute("xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); $usrNode = $dom->createElement("wsse:Username"); $usrNode->appendChild($dom->createTextNode(WS_USER)); $pwdNode = $dom->createElement("wsse:Password"); $pwdNode->setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); $pwdNode->appendchild($dom->createTextnode(WS_PWD)); $usernameTokenNode->appendChild($usrNode); $usernameTokenNode->appendChild($pwdNode); $secNode->appendChild($usernameTokenNode); $hdr->appendChild($secNode); $dom->documentElement->insertBefore($hdr, $dom->documentElement->firstChild); $request = $dom->saveXML(); $request = str_replace("SOAP-ENV", "soapenv", $request); $request = str_replace("ns1", "cgt", $request); $request = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $request); // echo "Este es el nuevo XML: " . print_r($request, true); return parent::__doRequest($request, $location, $action, $version); }
public function __doRequest($request, $location, $action, $version, $one_way = 0) { $response = parent::__doRequest($request, $location, $action, $version, $one_way); // strip away everything but the xml. $response = preg_replace('#^.*(<\\?xml.*>)[^>]*$#s', '$1', $response); return $response; }
/** * __doRequest. * @param string $request * @param string$location * @param string $action * @param int $version * @param int $oneWay * @return string */ public function __doRequest($request, $location, $action, $version, $oneWay = 0) { $aFind = [':ns1', 'ns1:', "\n", "\r"]; $sReplace = ''; $newrequest = str_replace($aFind, $sReplace, $request); return parent::__doRequest($newrequest, $location, $action, $version, $oneWay); }
public function __doRequest($request, $location, $action, $version, $one_way = null) { $api = $this->getBaseApi(); $user = $api->getConfigData('merchant_id'); $password = $api->getConfigData('security_key'); $soapHeader = "<SOAP-ENV:Header xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><wsse:Security SOAP-ENV:mustUnderstand=\"1\"><wsse:UsernameToken><wsse:Username>{$user}</wsse:Username><wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">{$password}</wsse:Password></wsse:UsernameToken></wsse:Security></SOAP-ENV:Header>"; $requestDOM = new DOMDocument('1.0'); $soapHeaderDOM = new DOMDocument('1.0'); $requestDOM->loadXML($request); $soapHeaderDOM->loadXML($soapHeader); $node = $requestDOM->importNode($soapHeaderDOM->firstChild, true); $requestDOM->firstChild->insertBefore($node, $requestDOM->firstChild->firstChild); $request = $requestDOM->saveXML(); if ($api->getConfigData('debug')) { /*Clean up PAN and CV2 for debug*/ $clean = simplexml_import_dom($requestDOM); $del = $clean->xpath('//ns1:accountNumber | //ns1:cvNumber'); foreach ($del as $el) { $el[0] = ''; } $debugrequest = $clean->asXML(); $debug = Mage::getModel('cybersource/api_debug')->setAction($action)->setRequestBody($debugrequest)->save(); } $response = parent::__doRequest($request, $location, $action, $version); if (!empty($debug)) { $debug->setResponseBody($response)->save(); } return $response; }