/** * send the SOAP message * * Note: if the operation has multiple return values * the return value of this method will be an array * of those values. * * @param string $msg a SOAPx4 soapmsg object * @param string $soapaction SOAPAction value * @param integer $timeout set timeout in seconds * @return mixed native PHP types. * @access private */ function send($msg, $soapaction = '', $timeout = 0) { // detect transport switch (true) { // http(s) case ereg('^http', $this->endpoint): $this->debug('transporting via HTTP'); if ($this->persistentConnection && is_object($this->persistentConnection)) { $http =& $this->persistentConnection; } else { $http = new soap_transport_http($this->endpoint); // pass encoding into transport layer, so appropriate http headers are sent $http->soap_defencoding = $this->soap_defencoding; } $http->setSOAPAction($soapaction); if ($this->proxyhost && $this->proxyport) { $http->setProxy($this->proxyhost, $this->proxyport); } if ($this->username != '' && $this->password != '') { $http->setCredentials($this->username, $this->password); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length: ' . strlen($msg)); if (ereg('^http:', $this->endpoint)) { //if(strpos($this->endpoint,'http:')){ $response = $http->send($msg, $timeout); } elseif (ereg('^https', $this->endpoint)) { //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout); //$this->request = $http->outgoing_payload; //$this->response = $http->incoming_payload; //} else if (extension_loaded('curl')) { $response = $http->sendHTTPS($msg, $timeout); } else { $this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); } } else { $this->setError('no http/s in endpoint url'); } $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; $this->debug("transport debug data...\n" . $http->debug_str); // save transport object if using persistent connections if ($this->persistentConnection && !is_object($this->persistentConnection)) { $this->persistentConnection = $http; } if ($err = $http->getError()) { $this->setError('HTTP Error: ' . $err); return false; } elseif ($this->getError()) { return false; } else { $this->debug('got response, length: ' . strlen($response)); return $this->parseResponse($response); } break; default: $this->setError('no transport found, or selected transport is not yet supported!'); return false; break; } }
/** * send the SOAP message * * Note: if the operation has multiple return values * the return value of this method will be an array * of those values. * * @param string $msg a SOAPx4 soapmsg object * @param string $soapaction SOAPAction value * @param integer $timeout set connection timeout in seconds * @param integer $response_timeout set response timeout in seconds * @return mixed native PHP types. * @access private */ function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) { $this->checkCookies(); // detect transport switch (true) { // http(s) case ereg('^http', $this->endpoint): $this->debug('transporting via HTTP'); if ($this->persistentConnection == true && is_object($this->persistentConnection)) { $http =& $this->persistentConnection; } else { $http = new soap_transport_http($this->endpoint); if ($this->persistentConnection) { $http->usePersistentConnection(); } } $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); $http->setSOAPAction($soapaction); if ($this->proxyhost && $this->proxyport) { $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->authtype != '') { $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length=' . strlen($msg)); if (ereg('^http:', $this->endpoint)) { //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies); } elseif (ereg('^https', $this->endpoint)) { //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); //$this->request = $http->outgoing_payload; //$this->response = $http->incoming_payload; //} else $this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies); } else { $this->setError('no http/s in endpoint url'); } $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; $this->appendDebug($http->getDebug()); $this->UpdateCookies($http->incoming_cookies); // save transport object if using persistent connections if ($this->persistentConnection) { $http->clearDebug(); if (!is_object($this->persistentConnection)) { $this->persistentConnection = $http; } } if ($err = $http->getError()) { $this->setError('HTTP Error: ' . $err); return false; } elseif ($this->getError()) { return false; } else { $this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']); return $this->parseResponse($http->incoming_headers, $this->responseData); } break; default: $this->setError('no transport found, or selected transport is not yet supported!'); return false; break; } }
/** * parses the wsdl document * * @param string $wsdl path or URL * @access private */ function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path={$wsdl}"); if ($wsdl == '') { $this->debug('no wsdl passed to parseWSDL()!!'); $this->setError('no wsdl passed to parseWSDL()!!'); return false; } // parse $wsdl for url format $wsdl_props = parse_url($wsdl); if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { $this->debug('getting WSDL http(s) URL ' . $wsdl); // get wsdl $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); $tr->request_method = 'GET'; $tr->useSOAPAction = false; if ($this->proxyhost && $this->proxyport) { $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->authtype != '') { $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); } $tr->setEncoding('gzip, deflate'); $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout); //$this->debug("WSDL request\n" . $tr->outgoing_payload); //$this->debug("WSDL response\n" . $tr->incoming_payload); $this->appendDebug($tr->getDebug()); // catch errors if ($err = $tr->getError()) { $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err; $this->debug($errstr); $this->setError($errstr); unset($tr); return false; } unset($tr); $this->debug("got WSDL URL"); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path if (isset($wsdl_props['scheme']) && $wsdl_props['scheme'] == 'file' && isset($wsdl_props['path'])) { $path = isset($wsdl_props['host']) ? $wsdl_props['host'] . ':' . $wsdl_props['path'] : $wsdl_props['path']; } else { $path = $wsdl; } $this->debug('getting WSDL file ' . $path); if ($fp = @fopen($path, 'r')) { $wsdl_string = ''; while ($data = fread($fp, 32768)) { $wsdl_string .= $data; } fclose($fp); } else { $errstr = "Bad path to WSDL file {$path}"; $this->debug($errstr); $this->setError($errstr); return false; } } $this->debug('Parse WSDL'); // end new code added // Create an XML parser. $this->parser = xml_parser_create(); // Set the options for parsing the XML data. // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); // Set the object for the parser. xml_set_object($this->parser, $this); // Set the element handlers for the parser. xml_set_element_handler($this->parser, 'start_element', 'end_element'); xml_set_character_data_handler($this->parser, 'character_data'); // Parse the XML file. if (!xml_parse($this->parser, $wsdl_string, true)) { // Display an error message. $errstr = sprintf('XML error parsing WSDL from %s on line %d: %s', $wsdl, xml_get_current_line_number($this->parser), xml_error_string(xml_get_error_code($this->parser))); $this->debug($errstr); $this->debug("XML payload:\n" . $wsdl_string); $this->setError($errstr); return false; } // free the parser xml_parser_free($this->parser); $this->debug('Parsing WSDL done'); // catch wsdl parse errors if ($this->getError()) { return false; } return true; }
/** * send the SOAP message * * Note: if the operation has multiple return values * the return value of this method will be an array * of those values. * * @param string $msg a SOAPx4 soapmsg object * @param string $soapaction SOAPAction value * @param integer $timeout set timeout in seconds * @return mixed native PHP types. * @access private */ function send($msg, $soapaction = '', $timeout = 0) { // detect transport switch (true) { // http(s) case preg_match('/^http/', $this->endpoint): $this->debug('transporting via HTTP'); if ($this->persistentConnection == true && is_object($this->persistentConnection)) { $http =& $this->persistentConnection; } else { $http = new soap_transport_http($this->endpoint); // pass encoding into transport layer, so appropriate http headers are sent $http->soap_defencoding = $this->soap_defencoding; if ($this->persistentConnection) { $http->usePersistentConnection(); } } $http->setSOAPAction($soapaction); if ($this->proxyhost && $this->proxyport) { $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->username != '' && $this->password != '') { $http->setCredentials($this->username, $this->password); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length: ' . strlen($msg)); if (preg_match('/^http:/', $this->endpoint)) { //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg, $timeout); } elseif (preg_match('/^https/', $this->endpoint)) { //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout); //$this->request = $http->outgoing_payload; //$this->response = $http->incoming_payload; //} else if (extension_loaded('curl')) { $this->responseData = $http->sendHTTPS($msg, $timeout); } else { $this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); } } else { $this->setError('no http/s in endpoint url'); } $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; $this->debug("transport debug data...\n" . $http->debug_str); // save transport object if using persistent connections if ($this->persistentConnection && !is_object($this->persistentConnection)) { $this->persistentConnection = $http; } if ($err = $http->getError()) { $this->setError('HTTP Error: ' . $err); return false; } elseif ($this->getError()) { return false; } else { if (strpos($http->incoming_headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($http->incoming_headers["content-type"], '='), 1)); $this->debug('got response encoding: ' . $enc); if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; } } else { // should be US-ASCII, but for XML, let's be pragmatic and admit UTF-8 is most common $this->xml_encoding = 'UTF-8'; } $this->debug('got response, length: ' . strlen($this->responseData) . ' use encoding: ' . $this->xml_encoding); return $this->parseResponse($this->responseData); } break; default: $this->setError('no transport found, or selected transport is not yet supported!'); return false; break; } }
/** * send the SOAP message * * Note: if the operation has multiple return values * the return value of this method will be an array * of those values. * * @param string $msg a SOAPx4 soapmsg object * @param string $soapaction SOAPAction value * @param integer $timeout set connection timeout in seconds * @param integer $response_timeout set response timeout in seconds * @return mixed native PHP types. * @access private */ function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) { // detect transport switch (true) { // http(s) case preg_match('/^http/', $this->endpoint): $this->debug('transporting via HTTP'); if ($this->persistentConnection == true && is_object($this->persistentConnection)) { $http =& $this->persistentConnection; } else { $http = new soap_transport_http($this->endpoint); if ($this->persistentConnection) { $http->usePersistentConnection(); } } $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); $http->setSOAPAction($soapaction); if ($this->proxyhost && $this->proxyport) { $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->username != '' && $this->password != '') { $http->setCredentials($this->username, $this->password); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length: ' . strlen($msg)); if (preg_match('#^http:#', $this->endpoint)) { //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg, $timeout, $response_timeout); } elseif (preg_match('#^https#', $this->endpoint)) { //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); //$this->request = $http->outgoing_payload; //$this->response = $http->incoming_payload; //} else if (extension_loaded('curl')) { $this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout); } else { $this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); } } else { $this->setError('no http/s in endpoint url'); } $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; $this->debug("transport debug data...\n" . $http->debug_str); // save transport object if using persistent connections if ($this->persistentConnection) { $http->debug_str = ''; if (!is_object($this->persistentConnection)) { $this->persistentConnection = $http; } } if ($err = $http->getError()) { $this->setError('HTTP Error: ' . $err); return false; } elseif ($this->getError()) { return false; } else { $this->debug('got response, length: ' . strlen($this->responseData) . ' type: ' . $http->incoming_headers['content-type']); return $this->parseResponse($http->incoming_headers, $this->responseData); } break; default: $this->setError('no transport found, or selected transport is not yet supported!'); return false; break; } }
/** * send the SOAP message * * Note: if the operation has multiple return values * the return value of this method will be an array * of those values. * * @param string $msg a SOAPx4 soapmsg object * @param string $soapaction SOAPAction value * @param integer $timeout set timeout in seconds * @return mixed native PHP types. * @access private */ function send($msg, $soapaction = '', $timeout = 0) { // detect transport switch (true) { // http(s) case ereg('^http', $this->endpoint): $this->debug('transporting via HTTP'); $http = new soap_transport_http($this->endpoint); $http->setSOAPAction($soapaction); if ($this->proxyhost && $this->proxyport) { $http->setProxy($this->proxyhost, $this->proxyport); } if ($this->username != '' && $this->password != '') { $http->setCredentials($this->username, $this->password); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length: ' . strlen($msg)); if (ereg('^http:', $this->endpoint)) { $response = $http->send($msg, $timeout); $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; } elseif (ereg('^https', $this->endpoint)) { if (!extension_loaded('curl')) { $this->setError('CURL Extension is required for HTTPS'); return false; } $response = $http->sendHTTPS($msg, $timeout); $this->request = $http->outgoing_payload; $this->response = $http->incoming_payload; } $this->debug("transport debug data...\n" . $http->debug_str); if ($err = $http->getError()) { $this->setError('HTTP Error: ' . $err); return false; } $this->debug('got response, length: ' . strlen($response)); return $this->parseResponse($response); break; default: $this->setError('no transport found, or selected transport is not yet supported!'); return false; break; } }