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 $xml_encoding = ''; // character set encoding of incoming (response) messages 00043 var $http_encoding = false; 00044 var $timeout = 0; // HTTP connection timeout 00045 var $response_timeout = 30; // HTTP response timeout 00046 var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error 00047 var $persistentConnection = false; 00048 var $defaultRpcParams = false; // This is no longer used 00049 var $request = ''; // HTTP request 00050 var $response = ''; // HTTP response 00051 var $responseData = ''; // SOAP payload of response 00052 var $cookies = array(); // Cookies from response or for request 00053 var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() 00054 var $operations = array(); // WSDL operations, empty for WSDL initialization error 00055 var $curl_options = array(); // User-specified cURL options 00056 var $bindingType = ''; // WSDL operation binding type 00057 var $use_curl = false; // whether to always try to use cURL 00058 00059 /* 00060 * fault related variables 00061 */ 00066 var $fault; 00071 var $faultcode; 00076 var $faultstring; 00081 var $faultdetail; 00082 00097 function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30){ 00098 parent::nusoap_base(); 00099 $this->endpoint = $endpoint; 00100 $this->proxyhost = $proxyhost; 00101 $this->proxyport = $proxyport; 00102 $this->proxyusername = $proxyusername; 00103 $this->proxypassword = $proxypassword; 00104 $this->timeout = $timeout; 00105 $this->response_timeout = $response_timeout; 00106 00107 $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); 00108 $this->appendDebug('endpoint=' . $this->varDump($endpoint)); 00109 00110 // make values 00111 if($wsdl){ 00112 if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) { 00113 $this->wsdl = $endpoint; 00114 $this->endpoint = $this->wsdl->wsdl; 00115 $this->wsdlFile = $this->endpoint; 00116 $this->debug('existing wsdl instance created from ' . $this->endpoint); 00117 $this->checkWSDL(); 00118 } else { 00119 $this->wsdlFile = $this->endpoint; 00120 $this->wsdl = null; 00121 $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint); 00122 } 00123 $this->endpointType = 'wsdl'; 00124 } else { 00125 $this->debug("instantiate SOAP with endpoint at $endpoint"); 00126 $this->endpointType = 'soap'; 00127 } 00128 } 00129 00155 function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){ 00156 $this->operation = $operation; 00157 $this->fault = false; 00158 $this->setError(''); 00159 $this->request = ''; 00160 $this->response = ''; 00161 $this->responseData = ''; 00162 $this->faultstring = ''; 00163 $this->faultcode = ''; 00164 $this->opData = array(); 00165 00166 $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType"); 00167 $this->appendDebug('params=' . $this->varDump($params)); 00168 $this->appendDebug('headers=' . $this->varDump($headers)); 00169 if ($headers) { 00170 $this->requestHeaders = $headers; 00171 } 00172 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00173 $this->loadWSDL(); 00174 if ($this->getError()) 00175 return false; 00176 } 00177 // serialize parameters 00178 if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){ 00179 // use WSDL for operation 00180 $this->opData = $opData; 00181 $this->debug("found operation"); 00182 $this->appendDebug('opData=' . $this->varDump($opData)); 00183 if (isset($opData['soapAction'])) { 00184 $soapAction = $opData['soapAction']; 00185 } 00186 if (! $this->forceEndpoint) { 00187 $this->endpoint = $opData['endpoint']; 00188 } else { 00189 $this->endpoint = $this->forceEndpoint; 00190 } 00191 $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; 00192 $style = $opData['style']; 00193 $use = $opData['input']['use']; 00194 // add ns to ns array 00195 if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){ 00196 $nsPrefix = 'ns' . rand(1000, 9999); 00197 $this->wsdl->namespaces[$nsPrefix] = $namespace; 00198 } 00199 $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); 00200 // serialize payload 00201 if (is_string($params)) { 00202 $this->debug("serializing param string for WSDL operation $operation"); 00203 $payload = $params; 00204 } elseif (is_array($params)) { 00205 $this->debug("serializing param array for WSDL operation $operation"); 00206 $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); 00207 } else { 00208 $this->debug('params must be array or string'); 00209 $this->setError('params must be array or string'); 00210 return false; 00211 } 00212 $usedNamespaces = $this->wsdl->usedNamespaces; 00213 if (isset($opData['input']['encodingStyle'])) { 00214 $encodingStyle = $opData['input']['encodingStyle']; 00215 } else { 00216 $encodingStyle = ''; 00217 } 00218 $this->appendDebug($this->wsdl->getDebug()); 00219 $this->wsdl->clearDebug(); 00220 if ($errstr = $this->wsdl->getError()) { 00221 $this->debug('got wsdl error: '.$errstr); 00222 $this->setError('wsdl error: '.$errstr); 00223 return false; 00224 } 00225 } elseif($this->endpointType == 'wsdl') { 00226 // operation not in WSDL 00227 $this->appendDebug($this->wsdl->getDebug()); 00228 $this->wsdl->clearDebug(); 00229 $this->setError( 'operation '.$operation.' not present.'); 00230 $this->debug("operation '$operation' not present."); 00231 return false; 00232 } else { 00233 // no WSDL 00234 //$this->namespaces['ns1'] = $namespace; 00235 $nsPrefix = 'ns' . rand(1000, 9999); 00236 // serialize 00237 $payload = ''; 00238 if (is_string($params)) { 00239 $this->debug("serializing param string for operation $operation"); 00240 $payload = $params; 00241 } elseif (is_array($params)) { 00242 $this->debug("serializing param array for operation $operation"); 00243 foreach($params as $k => $v){ 00244 $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); 00245 } 00246 } else { 00247 $this->debug('params must be array or string'); 00248 $this->setError('params must be array or string'); 00249 return false; 00250 } 00251 $usedNamespaces = array(); 00252 if ($use == 'encoded') { 00253 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; 00254 } else { 00255 $encodingStyle = ''; 00256 } 00257 } 00258 // wrap RPC calls with method element 00259 if ($style == 'rpc') { 00260 if ($use == 'literal') { 00261 $this->debug("wrapping RPC request with literal method element"); 00262 if ($namespace) { 00263 // 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 00264 $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 00265 $payload . 00266 "</$nsPrefix:$operation>"; 00267 } else { 00268 $payload = "<$operation>" . $payload . "</$operation>"; 00269 } 00270 } else { 00271 $this->debug("wrapping RPC request with encoded method element"); 00272 if ($namespace) { 00273 $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 00274 $payload . 00275 "</$nsPrefix:$operation>"; 00276 } else { 00277 $payload = "<$operation>" . 00278 $payload . 00279 "</$operation>"; 00280 } 00281 } 00282 } 00283 // serialize envelope 00284 $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); 00285 $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle"); 00286 $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000)); 00287 // send 00288 $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); 00289 if($errstr = $this->getError()){ 00290 $this->debug('Error: '.$errstr); 00291 return false; 00292 } else { 00293 $this->return = $return; 00294 $this->debug('sent message successfully and got a(n) '.gettype($return)); 00295 $this->appendDebug('return=' . $this->varDump($return)); 00296 00297 // fault? 00298 if(is_array($return) && isset($return['faultcode'])){ 00299 $this->debug('got fault'); 00300 $this->setError($return['faultcode'].': '.$return['faultstring']); 00301 $this->fault = true; 00302 foreach($return as $k => $v){ 00303 $this->$k = $v; 00304 $this->debug("$k = $v<br>"); 00305 } 00306 return $return; 00307 } elseif ($style == 'document') { 00308 // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), 00309 // we are only going to return the first part here...sorry about that 00310 return $return; 00311 } else { 00312 // array of return values 00313 if(is_array($return)){ 00314 // multiple 'out' parameters, which we return wrapped up 00315 // in the array 00316 if(sizeof($return) > 1){ 00317 return $return; 00318 } 00319 // single 'out' parameter (normally the return value) 00320 $return = array_shift($return); 00321 $this->debug('return shifted value: '); 00322 $this->appendDebug($this->varDump($return)); 00323 return $return; 00324 // nothing returned (ie, echoVoid) 00325 } else { 00326 return ""; 00327 } 00328 } 00329 } 00330 } 00331 00337 function checkWSDL() { 00338 $this->appendDebug($this->wsdl->getDebug()); 00339 $this->wsdl->clearDebug(); 00340 $this->debug('checkWSDL'); 00341 // catch errors 00342 if ($errstr = $this->wsdl->getError()) { 00343 $this->debug('got wsdl error: '.$errstr); 00344 $this->setError('wsdl error: '.$errstr); 00345 } elseif ($this->operations = $this->wsdl->getOperations('soap')) { 00346 $this->bindingType = 'soap'; 00347 $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 00348 } elseif ($this->operations = $this->wsdl->getOperations('soap12')) { 00349 $this->bindingType = 'soap12'; 00350 $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 00351 $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************'); 00352 } else { 00353 $this->debug('getOperations returned false'); 00354 $this->setError('no operations defined in the WSDL document!'); 00355 } 00356 } 00357 00363 function loadWSDL() { 00364 $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile); 00365 $this->wsdl =& new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl); 00366 $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); 00367 $this->wsdl->fetchWSDL($this->wsdlFile); 00368 $this->checkWSDL(); 00369 } 00370 00378 function getOperationData($operation){ 00379 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00380 $this->loadWSDL(); 00381 if ($this->getError()) 00382 return false; 00383 } 00384 if(isset($this->operations[$operation])){ 00385 return $this->operations[$operation]; 00386 } 00387 $this->debug("No data for operation: $operation"); 00388 } 00389 00404 function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) { 00405 $this->checkCookies(); 00406 // detect transport 00407 switch(true){ 00408 // http(s) 00409 case ereg('^http',$this->endpoint): 00410 $this->debug('transporting via HTTP'); 00411 if($this->persistentConnection == true && is_object($this->persistentConnection)){ 00412 $http =& $this->persistentConnection; 00413 } else { 00414 $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); 00415 if ($this->persistentConnection) { 00416 $http->usePersistentConnection(); 00417 } 00418 } 00419 $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); 00420 $http->setSOAPAction($soapaction); 00421 if($this->proxyhost && $this->proxyport){ 00422 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); 00423 } 00424 if($this->authtype != '') { 00425 $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); 00426 } 00427 if($this->http_encoding != ''){ 00428 $http->setEncoding($this->http_encoding); 00429 } 00430 $this->debug('sending message, length='.strlen($msg)); 00431 if(ereg('^http:',$this->endpoint)){ 00432 //if(strpos($this->endpoint,'http:')){ 00433 $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); 00434 } elseif(ereg('^https',$this->endpoint)){ 00435 //} elseif(strpos($this->endpoint,'https:')){ 00436 //if(phpversion() == '4.3.0-dev'){ 00437 //$response = $http->send($msg,$timeout,$response_timeout); 00438 //$this->request = $http->outgoing_payload; 00439 //$this->response = $http->incoming_payload; 00440 //} else 00441 $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); 00442 } else { 00443 $this->setError('no http/s in endpoint url'); 00444 } 00445 $this->request = $http->outgoing_payload; 00446 $this->response = $http->incoming_payload; 00447 $this->appendDebug($http->getDebug()); 00448 $this->UpdateCookies($http->incoming_cookies); 00449 00450 // save transport object if using persistent connections 00451 if ($this->persistentConnection) { 00452 $http->clearDebug(); 00453 if (!is_object($this->persistentConnection)) { 00454 $this->persistentConnection = $http; 00455 } 00456 } 00457 00458 if($err = $http->getError()){ 00459 $this->setError('HTTP Error: '.$err); 00460 return false; 00461 } elseif($this->getError()){ 00462 return false; 00463 } else { 00464 $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']); 00465 return $this->parseResponse($http->incoming_headers, $this->responseData); 00466 } 00467 break; 00468 default: 00469 $this->setError('no transport found, or selected transport is not yet supported!'); 00470 return false; 00471 break; 00472 } 00473 } 00474 00483 function parseResponse($headers, $data) { 00484 $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:'); 00485 $this->appendDebug($this->varDump($headers)); 00486 if (!strstr($headers['content-type'], 'text/xml')) { 00487 $this->setError('Response not of type text/xml: ' . $headers['content-type']); 00488 return false; 00489 } 00490 if (strpos($headers['content-type'], '=')) { 00491 $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); 00492 $this->debug('Got response encoding: ' . $enc); 00493 if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ 00494 $this->xml_encoding = strtoupper($enc); 00495 } else { 00496 $this->xml_encoding = 'US-ASCII'; 00497 } 00498 } else { 00499 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 00500 $this->xml_encoding = 'ISO-8859-1'; 00501 } 00502 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser'); 00503 $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); 00504 // add parser debug data to our debug 00505 $this->appendDebug($parser->getDebug()); 00506 // if parse errors 00507 if($errstr = $parser->getError()){ 00508 $this->setError( $errstr); 00509 // destroy the parser object 00510 unset($parser); 00511 return false; 00512 } else { 00513 // get SOAP headers 00514 $this->responseHeaders = $parser->getHeaders(); 00515 // get SOAP headers 00516 $this->responseHeader = $parser->get_soapheader(); 00517 // get decoded message 00518 $return = $parser->get_soapbody(); 00519 // add document for doclit support 00520 $this->document = $parser->document; 00521 // destroy the parser object 00522 unset($parser); 00523 // return decode message 00524 return $return; 00525 } 00526 } 00527 00535 function setCurlOption($option, $value) { 00536 $this->debug("setCurlOption option=$option, value="); 00537 $this->appendDebug($this->varDump($value)); 00538 $this->curl_options[$option] = $value; 00539 } 00540 00547 function setEndpoint($endpoint) { 00548 $this->debug("setEndpoint(\"$endpoint\")"); 00549 $this->forceEndpoint = $endpoint; 00550 } 00551 00558 function setHeaders($headers){ 00559 $this->debug("setHeaders headers="); 00560 $this->appendDebug($this->varDump($headers)); 00561 $this->requestHeaders = $headers; 00562 } 00563 00570 function getHeaders(){ 00571 return $this->responseHeaders; 00572 } 00573 00580 function getHeader(){ 00581 return $this->responseHeader; 00582 } 00583 00593 function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') { 00594 $this->proxyhost = $proxyhost; 00595 $this->proxyport = $proxyport; 00596 $this->proxyusername = $proxyusername; 00597 $this->proxypassword = $proxypassword; 00598 } 00599 00609 function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { 00610 $this->debug("setCredentials username=$username authtype=$authtype certRequest="); 00611 $this->appendDebug($this->varDump($certRequest)); 00612 $this->username = $username; 00613 $this->password = $password; 00614 $this->authtype = $authtype; 00615 $this->certRequest = $certRequest; 00616 } 00617 00624 function setHTTPEncoding($enc='gzip, deflate'){ 00625 $this->debug("setHTTPEncoding(\"$enc\")"); 00626 $this->http_encoding = $enc; 00627 } 00628 00635 function setUseCURL($use) { 00636 $this->debug("setUseCURL($use)"); 00637 $this->use_curl = $use; 00638 } 00639 00645 function useHTTPPersistentConnection(){ 00646 $this->debug("useHTTPPersistentConnection"); 00647 $this->persistentConnection = true; 00648 } 00649 00661 function getDefaultRpcParams() { 00662 return $this->defaultRpcParams; 00663 } 00664 00676 function setDefaultRpcParams($rpcParams) { 00677 $this->defaultRpcParams = $rpcParams; 00678 } 00679 00687 function getProxy() { 00688 $r = rand(); 00689 $evalStr = $this->_getProxyClassCode($r); 00690 //$this->debug("proxy class: $evalStr"); 00691 if ($this->getError()) { 00692 $this->debug("Error from _getProxyClassCode, so return NULL"); 00693 return null; 00694 } 00695 // eval the class 00696 eval($evalStr); 00697 // instantiate proxy object 00698 eval("\$proxy = new nusoap_proxy_$r('');"); 00699 // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice 00700 $proxy->endpointType = 'wsdl'; 00701 $proxy->wsdlFile = $this->wsdlFile; 00702 $proxy->wsdl = $this->wsdl; 00703 $proxy->operations = $this->operations; 00704 $proxy->defaultRpcParams = $this->defaultRpcParams; 00705 // transfer other state 00706 $proxy->soap_defencoding = $this->soap_defencoding; 00707 $proxy->username = $this->username; 00708 $proxy->password = $this->password; 00709 $proxy->authtype = $this->authtype; 00710 $proxy->certRequest = $this->certRequest; 00711 $proxy->requestHeaders = $this->requestHeaders; 00712 $proxy->endpoint = $this->endpoint; 00713 $proxy->forceEndpoint = $this->forceEndpoint; 00714 $proxy->proxyhost = $this->proxyhost; 00715 $proxy->proxyport = $this->proxyport; 00716 $proxy->proxyusername = $this->proxyusername; 00717 $proxy->proxypassword = $this->proxypassword; 00718 $proxy->http_encoding = $this->http_encoding; 00719 $proxy->timeout = $this->timeout; 00720 $proxy->response_timeout = $this->response_timeout; 00721 $proxy->persistentConnection = &$this->persistentConnection; 00722 $proxy->decode_utf8 = $this->decode_utf8; 00723 $proxy->curl_options = $this->curl_options; 00724 $proxy->bindingType = $this->bindingType; 00725 $proxy->use_curl = $this->use_curl; 00726 return $proxy; 00727 } 00728 00735 function _getProxyClassCode($r) { 00736 $this->debug("in getProxy endpointType=$this->endpointType"); 00737 $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); 00738 if ($this->endpointType != 'wsdl') { 00739 $evalStr = 'A proxy can only be created for a WSDL client'; 00740 $this->setError($evalStr); 00741 $evalStr = "echo \"$evalStr\";"; 00742 return $evalStr; 00743 } 00744 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 00745 $this->loadWSDL(); 00746 if ($this->getError()) { 00747 return "echo \"" . $this->getError() . "\";"; 00748 } 00749 } 00750 $evalStr = ''; 00751 foreach ($this->operations as $operation => $opData) { 00752 if ($operation != '') { 00753 // create param string and param comment string 00754 if (sizeof($opData['input']['parts']) > 0) { 00755 $paramStr = ''; 00756 $paramArrayStr = ''; 00757 $paramCommentStr = ''; 00758 foreach ($opData['input']['parts'] as $name => $type) { 00759 $paramStr .= "\$$name, "; 00760 $paramArrayStr .= "'$name' => \$$name, "; 00761 $paramCommentStr .= "$type \$$name, "; 00762 } 00763 $paramStr = substr($paramStr, 0, strlen($paramStr)-2); 00764 $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); 00765 $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); 00766 } else { 00767 $paramStr = ''; 00768 $paramArrayStr = ''; 00769 $paramCommentStr = 'void'; 00770 } 00771 $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; 00772 $evalStr .= "// $paramCommentStr 00773 function " . str_replace('.', '__', $operation) . "($paramStr) { 00774 \$params = array($paramArrayStr); 00775 return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."'); 00776 } 00777 "; 00778 unset($paramStr); 00779 unset($paramCommentStr); 00780 } 00781 } 00782 $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client { 00783 '.$evalStr.' 00784 }'; 00785 return $evalStr; 00786 } 00787 00794 function getProxyClassCode() { 00795 $r = rand(); 00796 return $this->_getProxyClassCode($r); 00797 } 00798 00806 function getHTTPBody($soapmsg) { 00807 return $soapmsg; 00808 } 00809 00818 function getHTTPContentType() { 00819 return 'text/xml'; 00820 } 00821 00831 function getHTTPContentTypeCharset() { 00832 return $this->soap_defencoding; 00833 } 00834 00835 /* 00836 * whether or not parser should decode utf8 element content 00837 * 00838 * @return always returns true 00839 * @access public 00840 */ 00841 function decodeUTF8($bool){ 00842 $this->decode_utf8 = $bool; 00843 return true; 00844 } 00845 00854 function setCookie($name, $value) { 00855 if (strlen($name) == 0) { 00856 return false; 00857 } 00858 $this->cookies[] = array('name' => $name, 'value' => $value); 00859 return true; 00860 } 00861 00868 function getCookies() { 00869 return $this->cookies; 00870 } 00871 00878 function checkCookies() { 00879 if (sizeof($this->cookies) == 0) { 00880 return true; 00881 } 00882 $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies'); 00883 $curr_cookies = $this->cookies; 00884 $this->cookies = array(); 00885 foreach ($curr_cookies as $cookie) { 00886 if (! is_array($cookie)) { 00887 $this->debug('Remove cookie that is not an array'); 00888 continue; 00889 } 00890 if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) { 00891 if (strtotime($cookie['expires']) > time()) { 00892 $this->cookies[] = $cookie; 00893 } else { 00894 $this->debug('Remove expired cookie ' . $cookie['name']); 00895 } 00896 } else { 00897 $this->cookies[] = $cookie; 00898 } 00899 } 00900 $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array'); 00901 return true; 00902 } 00903 00911 function UpdateCookies($cookies) { 00912 if (sizeof($this->cookies) == 0) { 00913 // no existing cookies: take whatever is new 00914 if (sizeof($cookies) > 0) { 00915 $this->debug('Setting new cookie(s)'); 00916 $this->cookies = $cookies; 00917 } 00918 return true; 00919 } 00920 if (sizeof($cookies) == 0) { 00921 // no new cookies: keep what we've got 00922 return true; 00923 } 00924 // merge 00925 foreach ($cookies as $newCookie) { 00926 if (!is_array($newCookie)) { 00927 continue; 00928 } 00929 if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) { 00930 continue; 00931 } 00932 $newName = $newCookie['name']; 00933 00934 $found = false; 00935 for ($i = 0; $i < count($this->cookies); $i++) { 00936 $cookie = $this->cookies[$i]; 00937 if (!is_array($cookie)) { 00938 continue; 00939 } 00940 if (!isset($cookie['name'])) { 00941 continue; 00942 } 00943 if ($newName != $cookie['name']) { 00944 continue; 00945 } 00946 $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; 00947 $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; 00948 if ($newDomain != $domain) { 00949 continue; 00950 } 00951 $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; 00952 $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; 00953 if ($newPath != $path) { 00954 continue; 00955 } 00956 $this->cookies[$i] = $newCookie; 00957 $found = true; 00958 $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']); 00959 break; 00960 } 00961 if (! $found) { 00962 $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']); 00963 $this->cookies[] = $newCookie; 00964 } 00965 } 00966 return true; 00967 } 00968 } 00969 00970 if (!extension_loaded('soap')) { 00974 class soapclient extends nusoap_client { 00975 } 00976 } 00977 ?>
For more help developing with SiT! see http://sitracker.org/wiki/DevelopmentHowTo