00001 <?php 00002 00003 00004 00005 00026 class nusoap_client extends nusoap_base { 00027 00028 var $username = ''; // Username for HTTP authentication 00029 var $password = ''; // Password for HTTP authentication 00030 var $authtype = ''; // Type of HTTP authentication 00031 var $certRequest = array(); // Certificate for HTTP SSL authentication 00032 var $requestHeaders = false; // SOAP headers in request (text) 00033 var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) 00034 var $responseHeader = NULL; // SOAP Header from response (parsed) 00035 var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) 00036 var $endpoint; 00037 var $forceEndpoint = ''; // overrides WSDL endpoint 00038 var $proxyhost = ''; 00039 var $proxyport = ''; 00040 var $proxyusername = ''; 00041 var $proxypassword = ''; 00042 var $portName = ''; // port name to use in WSDL 00043 var $xml_encoding = ''; // character set encoding of incoming (response) messages 00044 var $http_encoding = false; 00045 var $timeout = 0; // HTTP connection timeout 00046 var $response_timeout = 30; // HTTP response timeout 00047 var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error 00048 var $persistentConnection = false; 00049 var $defaultRpcParams = false; // This is no longer used 00050 var $request = ''; // HTTP request 00051 var $response = ''; // HTTP response 00052 var $responseData = ''; // SOAP payload of response 00053 var $cookies = array(); // Cookies from response or for request 00054 var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() 00055 var $operations = array(); // WSDL operations, empty for WSDL initialization error 00056 var $curl_options = array(); // User-specified cURL options 00057 var $bindingType = ''; // WSDL operation binding type 00058 var $use_curl = false; // whether to always try to use cURL 00059 00060 /* 00061 * fault related variables 00062 */ 00067 var $fault; 00072 var $faultcode; 00077 var $faultstring; 00082 var $faultdetail; 00083 00098 function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){ 00099 parent::nusoap_base(); 00100 $this->endpoint = $endpoint; 00101 $this->proxyhost = $proxyhost; 00102 $this->proxyport = $proxyport; 00103 $this->proxyusername = $proxyusername; 00104 $this->proxypassword = $proxypassword; 00105 $this->timeout = $timeout; 00106 $this->response_timeout = $response_timeout; 00107 $this->portName = $portName; 00108 00109 $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); 00110 $this->appendDebug('endpoint=' . $this->varDump($endpoint)); 00111 00112 // make values 00113 if($wsdl){ 00114 if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) { 00115 $this->wsdl = $endpoint; 00116 $this->endpoint = $this->wsdl->wsdl; 00117 $this->wsdlFile = $this->endpoint; 00118 $this->debug('existing wsdl instance created from ' . $this->endpoint); 00119 $this->checkWSDL(); 00120 } else { 00121 $this->wsdlFile = $this->endpoint; 00122 $this->wsdl = null; 00123 $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint); 00124 } 00125 $this->endpointType = 'wsdl'; 00126 } else { 00127 $this->debug("instantiate SOAP with endpoint at $endpoint"); 00128 $this->endpointType = 'soap'; 00129 } 00130 } 00131 00157 function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){ 00158 $this->operation = $operation; 00159 $this->fault = false; 00160 $this->setError(''); 00161 $this->request = ''; 00162 $this->response = ''; 00163 $this->responseData = ''; 00164 $this->faultstring = ''; 00165 $this->faultcode = ''; 00166 $this->opData = array(); 00167 00168 $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType"); 00169 $this->appendDebug('params=' . $this->varDump($params)); 00170 $this->appendDebug('headers=' . $this->varDump($headers)); 00171 if ($headers) { 00172 $this->requestHeaders = $headers; 00173 } 00174 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00175 $this->loadWSDL(); 00176 if ($this->getError()) 00177 return false; 00178 } 00179 // serialize parameters 00180 if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){ 00181 // use WSDL for operation 00182 $this->opData = $opData; 00183 $this->debug("found operation"); 00184 $this->appendDebug('opData=' . $this->varDump($opData)); 00185 if (isset($opData['soapAction'])) { 00186 $soapAction = $opData['soapAction']; 00187 } 00188 if (! $this->forceEndpoint) { 00189 $this->endpoint = $opData['endpoint']; 00190 } else { 00191 $this->endpoint = $this->forceEndpoint; 00192 } 00193 $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; 00194 $style = $opData['style']; 00195 $use = $opData['input']['use']; 00196 // add ns to ns array 00197 if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){ 00198 $nsPrefix = 'ns' . rand(1000, 9999); 00199 $this->wsdl->namespaces[$nsPrefix] = $namespace; 00200 } 00201 $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); 00202 // serialize payload 00203 if (is_string($params)) { 00204 $this->debug("serializing param string for WSDL operation $operation"); 00205 $payload = $params; 00206 } elseif (is_array($params)) { 00207 $this->debug("serializing param array for WSDL operation $operation"); 00208 $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); 00209 } else { 00210 $this->debug('params must be array or string'); 00211 $this->setError('params must be array or string'); 00212 return false; 00213 } 00214 $usedNamespaces = $this->wsdl->usedNamespaces; 00215 if (isset($opData['input']['encodingStyle'])) { 00216 $encodingStyle = $opData['input']['encodingStyle']; 00217 } else { 00218 $encodingStyle = ''; 00219 } 00220 $this->appendDebug($this->wsdl->getDebug()); 00221 $this->wsdl->clearDebug(); 00222 if ($errstr = $this->wsdl->getError()) { 00223 $this->debug('got wsdl error: '.$errstr); 00224 $this->setError('wsdl error: '.$errstr); 00225 return false; 00226 } 00227 } elseif($this->endpointType == 'wsdl') { 00228 // operation not in WSDL 00229 $this->appendDebug($this->wsdl->getDebug()); 00230 $this->wsdl->clearDebug(); 00231 $this->setError( 'operation '.$operation.' not present.'); 00232 $this->debug("operation '$operation' not present."); 00233 return false; 00234 } else { 00235 // no WSDL 00236 //$this->namespaces['ns1'] = $namespace; 00237 $nsPrefix = 'ns' . rand(1000, 9999); 00238 // serialize 00239 $payload = ''; 00240 if (is_string($params)) { 00241 $this->debug("serializing param string for operation $operation"); 00242 $payload = $params; 00243 } elseif (is_array($params)) { 00244 $this->debug("serializing param array for operation $operation"); 00245 foreach($params as $k => $v){ 00246 $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); 00247 } 00248 } else { 00249 $this->debug('params must be array or string'); 00250 $this->setError('params must be array or string'); 00251 return false; 00252 } 00253 $usedNamespaces = array(); 00254 if ($use == 'encoded') { 00255 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; 00256 } else { 00257 $encodingStyle = ''; 00258 } 00259 } 00260 // wrap RPC calls with method element 00261 if ($style == 'rpc') { 00262 if ($use == 'literal') { 00263 $this->debug("wrapping RPC request with literal method element"); 00264 if ($namespace) { 00265 // 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 00266 $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 00267 $payload . 00268 "</$nsPrefix:$operation>"; 00269 } else { 00270 $payload = "<$operation>" . $payload . "</$operation>"; 00271 } 00272 } else { 00273 $this->debug("wrapping RPC request with encoded method element"); 00274 if ($namespace) { 00275 $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 00276 $payload . 00277 "</$nsPrefix:$operation>"; 00278 } else { 00279 $payload = "<$operation>" . 00280 $payload . 00281 "</$operation>"; 00282 } 00283 } 00284 } 00285 // serialize envelope 00286 $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); 00287 $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle"); 00288 $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000)); 00289 // send 00290 $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); 00291 if($errstr = $this->getError()){ 00292 $this->debug('Error: '.$errstr); 00293 return false; 00294 } else { 00295 $this->return = $return; 00296 $this->debug('sent message successfully and got a(n) '.gettype($return)); 00297 $this->appendDebug('return=' . $this->varDump($return)); 00298 00299 // fault? 00300 if(is_array($return) && isset($return['faultcode'])){ 00301 $this->debug('got fault'); 00302 $this->setError($return['faultcode'].': '.$return['faultstring']); 00303 $this->fault = true; 00304 foreach($return as $k => $v){ 00305 $this->$k = $v; 00306 $this->debug("$k = $v<br>"); 00307 } 00308 return $return; 00309 } elseif ($style == 'document') { 00310 // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), 00311 // we are only going to return the first part here...sorry about that 00312 return $return; 00313 } else { 00314 // array of return values 00315 if(is_array($return)){ 00316 // multiple 'out' parameters, which we return wrapped up 00317 // in the array 00318 if(sizeof($return) > 1){ 00319 return $return; 00320 } 00321 // single 'out' parameter (normally the return value) 00322 $return = array_shift($return); 00323 $this->debug('return shifted value: '); 00324 $this->appendDebug($this->varDump($return)); 00325 return $return; 00326 // nothing returned (ie, echoVoid) 00327 } else { 00328 return ""; 00329 } 00330 } 00331 } 00332 } 00333 00339 function checkWSDL() { 00340 $this->appendDebug($this->wsdl->getDebug()); 00341 $this->wsdl->clearDebug(); 00342 $this->debug('checkWSDL'); 00343 // catch errors 00344 if ($errstr = $this->wsdl->getError()) { 00345 $this->appendDebug($this->wsdl->getDebug()); 00346 $this->wsdl->clearDebug(); 00347 $this->debug('got wsdl error: '.$errstr); 00348 $this->setError('wsdl error: '.$errstr); 00349 } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) { 00350 $this->appendDebug($this->wsdl->getDebug()); 00351 $this->wsdl->clearDebug(); 00352 $this->bindingType = 'soap'; 00353 $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 00354 } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) { 00355 $this->appendDebug($this->wsdl->getDebug()); 00356 $this->wsdl->clearDebug(); 00357 $this->bindingType = 'soap12'; 00358 $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 00359 $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************'); 00360 } else { 00361 $this->appendDebug($this->wsdl->getDebug()); 00362 $this->wsdl->clearDebug(); 00363 $this->debug('getOperations returned false'); 00364 $this->setError('no operations defined in the WSDL document!'); 00365 } 00366 } 00367 00373 function loadWSDL() { 00374 $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile); 00375 $this->wsdl =& new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl); 00376 $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); 00377 $this->wsdl->fetchWSDL($this->wsdlFile); 00378 $this->checkWSDL(); 00379 } 00380 00388 function getOperationData($operation){ 00389 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00390 $this->loadWSDL(); 00391 if ($this->getError()) 00392 return false; 00393 } 00394 if(isset($this->operations[$operation])){ 00395 return $this->operations[$operation]; 00396 } 00397 $this->debug("No data for operation: $operation"); 00398 } 00399 00414 function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) { 00415 $this->checkCookies(); 00416 // detect transport 00417 switch(true){ 00418 // http(s) 00419 case ereg('^http',$this->endpoint): 00420 $this->debug('transporting via HTTP'); 00421 if($this->persistentConnection == true && is_object($this->persistentConnection)){ 00422 $http =& $this->persistentConnection; 00423 } else { 00424 $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); 00425 if ($this->persistentConnection) { 00426 $http->usePersistentConnection(); 00427 } 00428 } 00429 $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); 00430 $http->setSOAPAction($soapaction); 00431 if($this->proxyhost && $this->proxyport){ 00432 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); 00433 } 00434 if($this->authtype != '') { 00435 $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); 00436 } 00437 if($this->http_encoding != ''){ 00438 $http->setEncoding($this->http_encoding); 00439 } 00440 $this->debug('sending message, length='.strlen($msg)); 00441 if(ereg('^http:',$this->endpoint)){ 00442 //if(strpos($this->endpoint,'http:')){ 00443 $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); 00444 } elseif(ereg('^https',$this->endpoint)){ 00445 //} elseif(strpos($this->endpoint,'https:')){ 00446 //if(phpversion() == '4.3.0-dev'){ 00447 //$response = $http->send($msg,$timeout,$response_timeout); 00448 //$this->request = $http->outgoing_payload; 00449 //$this->response = $http->incoming_payload; 00450 //} else 00451 $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); 00452 } else { 00453 $this->setError('no http/s in endpoint url'); 00454 } 00455 $this->request = $http->outgoing_payload; 00456 $this->response = $http->incoming_payload; 00457 $this->appendDebug($http->getDebug()); 00458 $this->UpdateCookies($http->incoming_cookies); 00459 00460 // save transport object if using persistent connections 00461 if ($this->persistentConnection) { 00462 $http->clearDebug(); 00463 if (!is_object($this->persistentConnection)) { 00464 $this->persistentConnection = $http; 00465 } 00466 } 00467 00468 if($err = $http->getError()){ 00469 $this->setError('HTTP Error: '.$err); 00470 return false; 00471 } elseif($this->getError()){ 00472 return false; 00473 } else { 00474 $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']); 00475 return $this->parseResponse($http->incoming_headers, $this->responseData); 00476 } 00477 break; 00478 default: 00479 $this->setError('no transport found, or selected transport is not yet supported!'); 00480 return false; 00481 break; 00482 } 00483 } 00484 00493 function parseResponse($headers, $data) { 00494 $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:'); 00495 $this->appendDebug($this->varDump($headers)); 00496 if (!isset($headers['content-type'])) { 00497 $this->setError('Response not of type text/xml (no content-type header)'); 00498 return false; 00499 } 00500 if (!strstr($headers['content-type'], 'text/xml')) { 00501 $this->setError('Response not of type text/xml: ' . $headers['content-type']); 00502 return false; 00503 } 00504 if (strpos($headers['content-type'], '=')) { 00505 $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); 00506 $this->debug('Got response encoding: ' . $enc); 00507 if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ 00508 $this->xml_encoding = strtoupper($enc); 00509 } else { 00510 $this->xml_encoding = 'US-ASCII'; 00511 } 00512 } else { 00513 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 00514 $this->xml_encoding = 'ISO-8859-1'; 00515 } 00516 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser'); 00517 $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); 00518 // add parser debug data to our debug 00519 $this->appendDebug($parser->getDebug()); 00520 // if parse errors 00521 if($errstr = $parser->getError()){ 00522 $this->setError( $errstr); 00523 // destroy the parser object 00524 unset($parser); 00525 return false; 00526 } else { 00527 // get SOAP headers 00528 $this->responseHeaders = $parser->getHeaders(); 00529 // get SOAP headers 00530 $this->responseHeader = $parser->get_soapheader(); 00531 // get decoded message 00532 $return = $parser->get_soapbody(); 00533 // add document for doclit support 00534 $this->document = $parser->document; 00535 // destroy the parser object 00536 unset($parser); 00537 // return decode message 00538 return $return; 00539 } 00540 } 00541 00549 function setCurlOption($option, $value) { 00550 $this->debug("setCurlOption option=$option, value="); 00551 $this->appendDebug($this->varDump($value)); 00552 $this->curl_options[$option] = $value; 00553 } 00554 00561 function setEndpoint($endpoint) { 00562 $this->debug("setEndpoint(\"$endpoint\")"); 00563 $this->forceEndpoint = $endpoint; 00564 } 00565 00572 function setHeaders($headers){ 00573 $this->debug("setHeaders headers="); 00574 $this->appendDebug($this->varDump($headers)); 00575 $this->requestHeaders = $headers; 00576 } 00577 00584 function getHeaders(){ 00585 return $this->responseHeaders; 00586 } 00587 00594 function getHeader(){ 00595 return $this->responseHeader; 00596 } 00597 00607 function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') { 00608 $this->proxyhost = $proxyhost; 00609 $this->proxyport = $proxyport; 00610 $this->proxyusername = $proxyusername; 00611 $this->proxypassword = $proxypassword; 00612 } 00613 00623 function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { 00624 $this->debug("setCredentials username=$username authtype=$authtype certRequest="); 00625 $this->appendDebug($this->varDump($certRequest)); 00626 $this->username = $username; 00627 $this->password = $password; 00628 $this->authtype = $authtype; 00629 $this->certRequest = $certRequest; 00630 } 00631 00638 function setHTTPEncoding($enc='gzip, deflate'){ 00639 $this->debug("setHTTPEncoding(\"$enc\")"); 00640 $this->http_encoding = $enc; 00641 } 00642 00649 function setUseCURL($use) { 00650 $this->debug("setUseCURL($use)"); 00651 $this->use_curl = $use; 00652 } 00653 00659 function useHTTPPersistentConnection(){ 00660 $this->debug("useHTTPPersistentConnection"); 00661 $this->persistentConnection = true; 00662 } 00663 00675 function getDefaultRpcParams() { 00676 return $this->defaultRpcParams; 00677 } 00678 00690 function setDefaultRpcParams($rpcParams) { 00691 $this->defaultRpcParams = $rpcParams; 00692 } 00693 00701 function getProxy() { 00702 $r = rand(); 00703 $evalStr = $this->_getProxyClassCode($r); 00704 //$this->debug("proxy class: $evalStr"); 00705 if ($this->getError()) { 00706 $this->debug("Error from _getProxyClassCode, so return NULL"); 00707 return null; 00708 } 00709 // eval the class 00710 eval($evalStr); 00711 // instantiate proxy object 00712 eval("\$proxy = new nusoap_proxy_$r('');"); 00713 // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice 00714 $proxy->endpointType = 'wsdl'; 00715 $proxy->wsdlFile = $this->wsdlFile; 00716 $proxy->wsdl = $this->wsdl; 00717 $proxy->operations = $this->operations; 00718 $proxy->defaultRpcParams = $this->defaultRpcParams; 00719 // transfer other state 00720 $proxy->soap_defencoding = $this->soap_defencoding; 00721 $proxy->username = $this->username; 00722 $proxy->password = $this->password; 00723 $proxy->authtype = $this->authtype; 00724 $proxy->certRequest = $this->certRequest; 00725 $proxy->requestHeaders = $this->requestHeaders; 00726 $proxy->endpoint = $this->endpoint; 00727 $proxy->forceEndpoint = $this->forceEndpoint; 00728 $proxy->proxyhost = $this->proxyhost; 00729 $proxy->proxyport = $this->proxyport; 00730 $proxy->proxyusername = $this->proxyusername; 00731 $proxy->proxypassword = $this->proxypassword; 00732 $proxy->http_encoding = $this->http_encoding; 00733 $proxy->timeout = $this->timeout; 00734 $proxy->response_timeout = $this->response_timeout; 00735 $proxy->persistentConnection = &$this->persistentConnection; 00736 $proxy->decode_utf8 = $this->decode_utf8; 00737 $proxy->curl_options = $this->curl_options; 00738 $proxy->bindingType = $this->bindingType; 00739 $proxy->use_curl = $this->use_curl; 00740 return $proxy; 00741 } 00742 00749 function _getProxyClassCode($r) { 00750 $this->debug("in getProxy endpointType=$this->endpointType"); 00751 $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); 00752 if ($this->endpointType != 'wsdl') { 00753 $evalStr = 'A proxy can only be created for a WSDL client'; 00754 $this->setError($evalStr); 00755 $evalStr = "echo \"$evalStr\";"; 00756 return $evalStr; 00757 } 00758 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00759 $this->loadWSDL(); 00760 if ($this->getError()) { 00761 return "echo \"" . $this->getError() . "\";"; 00762 } 00763 } 00764 $evalStr = ''; 00765 foreach ($this->operations as $operation => $opData) { 00766 if ($operation != '') { 00767 // create param string and param comment string 00768 if (sizeof($opData['input']['parts']) > 0) { 00769 $paramStr = ''; 00770 $paramArrayStr = ''; 00771 $paramCommentStr = ''; 00772 foreach ($opData['input']['parts'] as $name => $type) { 00773 $paramStr .= "\$$name, "; 00774 $paramArrayStr .= "'$name' => \$$name, "; 00775 $paramCommentStr .= "$type \$$name, "; 00776 } 00777 $paramStr = substr($paramStr, 0, strlen($paramStr)-2); 00778 $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); 00779 $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); 00780 } else { 00781 $paramStr = ''; 00782 $paramArrayStr = ''; 00783 $paramCommentStr = 'void'; 00784 } 00785 $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; 00786 $evalStr .= "// $paramCommentStr 00787 function " . str_replace('.', '__', $operation) . "($paramStr) { 00788 \$params = array($paramArrayStr); 00789 return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."'); 00790 } 00791 "; 00792 unset($paramStr); 00793 unset($paramCommentStr); 00794 } 00795 } 00796 $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client { 00797 '.$evalStr.' 00798 }'; 00799 return $evalStr; 00800 } 00801 00808 function getProxyClassCode() { 00809 $r = rand(); 00810 return $this->_getProxyClassCode($r); 00811 } 00812 00820 function getHTTPBody($soapmsg) { 00821 return $soapmsg; 00822 } 00823 00832 function getHTTPContentType() { 00833 return 'text/xml'; 00834 } 00835 00845 function getHTTPContentTypeCharset() { 00846 return $this->soap_defencoding; 00847 } 00848 00849 /* 00850 * whether or not parser should decode utf8 element content 00851 * 00852 * @return always returns true 00853 * @access public 00854 */ 00855 function decodeUTF8($bool){ 00856 $this->decode_utf8 = $bool; 00857 return true; 00858 } 00859 00868 function setCookie($name, $value) { 00869 if (strlen($name) == 0) { 00870 return false; 00871 } 00872 $this->cookies[] = array('name' => $name, 'value' => $value); 00873 return true; 00874 } 00875 00882 function getCookies() { 00883 return $this->cookies; 00884 } 00885 00892 function checkCookies() { 00893 if (sizeof($this->cookies) == 0) { 00894 return true; 00895 } 00896 $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies'); 00897 $curr_cookies = $this->cookies; 00898 $this->cookies = array(); 00899 foreach ($curr_cookies as $cookie) { 00900 if (! is_array($cookie)) { 00901 $this->debug('Remove cookie that is not an array'); 00902 continue; 00903 } 00904 if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) { 00905 if (strtotime($cookie['expires']) > time()) { 00906 $this->cookies[] = $cookie; 00907 } else { 00908 $this->debug('Remove expired cookie ' . $cookie['name']); 00909 } 00910 } else { 00911 $this->cookies[] = $cookie; 00912 } 00913 } 00914 $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array'); 00915 return true; 00916 } 00917 00925 function UpdateCookies($cookies) { 00926 if (sizeof($this->cookies) == 0) { 00927 // no existing cookies: take whatever is new 00928 if (sizeof($cookies) > 0) { 00929 $this->debug('Setting new cookie(s)'); 00930 $this->cookies = $cookies; 00931 } 00932 return true; 00933 } 00934 if (sizeof($cookies) == 0) { 00935 // no new cookies: keep what we've got 00936 return true; 00937 } 00938 // merge 00939 foreach ($cookies as $newCookie) { 00940 if (!is_array($newCookie)) { 00941 continue; 00942 } 00943 if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) { 00944 continue; 00945 } 00946 $newName = $newCookie['name']; 00947 00948 $found = false; 00949 for ($i = 0; $i < count($this->cookies); $i++) { 00950 $cookie = $this->cookies[$i]; 00951 if (!is_array($cookie)) { 00952 continue; 00953 } 00954 if (!isset($cookie['name'])) { 00955 continue; 00956 } 00957 if ($newName != $cookie['name']) { 00958 continue; 00959 } 00960 $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; 00961 $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; 00962 if ($newDomain != $domain) { 00963 continue; 00964 } 00965 $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; 00966 $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; 00967 if ($newPath != $path) { 00968 continue; 00969 } 00970 $this->cookies[$i] = $newCookie; 00971 $found = true; 00972 $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']); 00973 break; 00974 } 00975 if (! $found) { 00976 $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']); 00977 $this->cookies[] = $newCookie; 00978 } 00979 } 00980 return true; 00981 } 00982 } 00983 00984 if (!extension_loaded('soap')) { 00988 class soapclient extends nusoap_client { 00989 } 00990 } 00991 ?>
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|