88 $this->endpointType =
'wsdl';
93 $this->
debug(
'existing wsdl instance created from ' . $this->endpoint);
99 $this->
wsdl =&
new wsdl($this->wsdlFile,$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout);
101 $this->
debug(
"wsdl debug...\n".$this->
wsdl->debug_str);
102 $this->
wsdl->debug_str =
'';
105 $this->
debug(
'got wsdl error: '.$errstr);
106 $this->
setError(
'wsdl error: '.$errstr);
108 $this->
debug(
'got '.count($this->operations).
' operations from wsdl '.$this->wsdlFile);
110 $this->
debug(
'getOperations returned false');
111 $this->
setError(
'no operations defined in the WSDL document!');
141 function call($operation,
$params=array(),
$namespace=
'',$soapAction=
'',$headers=
false,$rpcParams=null,$style=
'rpc',$use=
'encoded'){
142 $this->operation = $operation;
143 $this->fault =
false;
144 $this->error_str =
'';
146 $this->response =
'';
147 $this->responseData =
'';
148 $this->faultstring =
'';
149 $this->faultcode =
'';
150 $this->opData = array();
152 $this->
debug(
"call: $operation, $params, $namespace, $soapAction, $headers, $style, $use; endpointType: $this->endpointType");
154 $this->requestHeaders = $headers;
157 if($this->endpointType ==
'wsdl' && $opData = $this->
getOperationData($operation)){
159 $this->opData = $opData;
160 foreach($opData as
$key => $value){
161 $this->
debug(
"$key -> $value");
163 if (isset($opData[
'soapAction'])) {
164 $soapAction = $opData[
'soapAction'];
166 $this->endpoint = $opData[
'endpoint'];
168 $style = $opData[
'style'];
169 $use = $opData[
'input'][
'use'];
177 $this->
debug(
"serializing param string for WSDL operation $operation");
180 $this->
debug(
"serializing param array for WSDL operation $operation");
183 $this->
debug(
'params must be array or string');
184 $this->
setError(
'params must be array or string');
189 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
190 if (isset($opData[
'output'][
'encodingStyle']) && $encodingStyle != $opData[
'output'][
'encodingStyle']) {
191 $methodEncodingStyle =
' SOAP-ENV:encodingStyle="' . $opData[
'output'][
'encodingStyle'] .
'"';
193 $methodEncodingStyle =
'';
195 $this->
debug(
"wsdl debug: \n".$this->
wsdl->debug_str);
196 $this->
wsdl->debug_str =
'';
198 $this->
debug(
'got wsdl error: '.$errstr);
199 $this->
setError(
'wsdl error: '.$errstr);
202 }
elseif($this->endpointType ==
'wsdl') {
204 $this->
setError(
'operation '.$operation.
' not present.');
205 $this->
debug(
"operation '$operation' not present.");
206 $this->
debug(
"wsdl debug: \n".$this->
wsdl->debug_str);
207 $this->
wsdl->debug_str =
'';
219 $this->
debug(
"serializing param string for operation $operation");
222 $this->
debug(
"serializing param array for operation $operation");
224 $payload .= $this->
serialize_val($v,$k,
false,
false,
false,
false,$use);
227 $this->
debug(
'params must be array or string');
228 $this->
setError(
'params must be array or string');
232 $methodEncodingStyle =
'';
235 if ($style ==
'rpc') {
236 if ($use ==
'literal') {
237 $this->
debug(
"wrapping RPC request with literal method element");
238 $payload =
"<$operation xmlns=\"$namespace\">" . $payload .
"</$operation>";
240 $this->
debug(
"wrapping RPC request with encoded method element");
241 $payload =
"<$nsPrefix:$operation$methodEncodingStyle xmlns:$nsPrefix=\"$namespace\">" .
243 "</$nsPrefix:$operation>";
248 $this->
debug(
"endpoint: $this->endpoint, soapAction: $soapAction, namespace: $namespace, style: $style, use: $use");
249 $this->
debug(
'SOAP message length: ' . strlen($soapmsg) .
' contents: ' . substr($soapmsg, 0, 1000));
251 $return = $this->
send($this->
getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
253 $this->
debug(
'Error: '.$errstr);
256 $this->
return = $return;
257 $this->
debug(
'sent message successfully and got a(n) '.gettype($return).
' back');
260 if(is_array($return) && isset($return[
'faultcode'])){
261 $this->
debug(
'got fault');
262 $this->
setError($return[
'faultcode'].
': '.$return[
'faultstring']);
264 foreach($return as $k => $v){
266 $this->
debug(
"$k = $v<br>");
271 if(is_array($return)){
273 if(
sizeof($return) > 1){
277 return array_shift($return);
294 if(isset($this->operations[$operation])){
295 return $this->operations[$operation];
297 $this->
debug(
"No data for operation: $operation");
318 case ereg(
'^http',$this->endpoint):
319 $this->
debug(
'transporting via HTTP');
320 if($this->persistentConnection ==
true && is_object($this->persistentConnection)){
324 if ($this->persistentConnection) {
325 $http->usePersistentConnection();
329 $http->setSOAPAction($soapaction);
330 if($this->proxyhost && $this->proxyport){
331 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
333 if($this->username !=
'' && $this->password !=
'') {
334 $http->setCredentials($this->username, $this->password, $this->authtype);
336 if($this->http_encoding !=
''){
337 $http->setEncoding($this->http_encoding);
339 $this->
debug(
'sending message, length: '.strlen($msg));
340 if(ereg(
'^http:',$this->endpoint)){
343 }
elseif(ereg(
'^https',$this->endpoint)){
350 if (extension_loaded(
'curl')) {
353 $this->
setError(
'CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
356 $this->
setError(
'no http/s in endpoint url');
358 $this->request = $http->outgoing_payload;
359 $this->response = $http->incoming_payload;
360 $this->
debug(
"transport debug data...\n".$http->debug_str);
363 if ($this->persistentConnection) {
364 $http->debug_str =
'';
365 if (!is_object($this->persistentConnection)) {
366 $this->persistentConnection = $http;
370 if(
$err = $http->getError()){
376 $this->
debug(
'got response, length: '. strlen($this->responseData).
' type: '.$http->incoming_headers[
'content-type']);
377 return $this->
parseResponse($http->incoming_headers, $this->responseData);
381 $this->
setError(
'no transport found, or selected transport is not yet supported!');
396 $this->
debug(
'Entering parseResponse() for data of length ' . strlen(
$data) .
' and type ' . $headers[
'content-type']);
397 if (!strstr($headers[
'content-type'],
'text/xml')) {
398 $this->
setError(
'Response not of type text/xml');
401 if (strpos($headers[
'content-type'],
'=')) {
402 $enc = str_replace(
'"',
'', substr(strstr($headers[
"content-type"],
'='), 1));
403 $this->
debug(
'Got response encoding: ' .
$enc);
404 if(eregi(
'^(ISO-8859-1|US-ASCII|UTF-8)$',
$enc)){
405 $this->xml_encoding = strtoupper(
$enc);
407 $this->xml_encoding =
'US-ASCII';
411 $this->xml_encoding =
'UTF-8';
413 $this->
debug(
'Use encoding: ' . $this->xml_encoding .
' when creating soap_parser');
414 $parser =
new soap_parser(
$data,$this->xml_encoding,$this->operation,$this->decode_utf8);
416 $this->
debug($parser->debug_str);
418 if($errstr = $parser->getError()){
425 $this->responseHeaders = $parser->getHeaders();
427 $return = $parser->get_response();
429 $this->document = $parser->document;
444 $this->requestHeaders = $headers;
454 if($this->responseHeaders !=
'') {
496 $this->http_encoding =
$enc;
505 $this->persistentConnection =
true;
531 $this->defaultRpcParams = $rpcParams;
542 foreach($this->operations as $operation => $opData){
543 if($operation !=
''){
546 if(
sizeof($opData[
'input'][
'parts']) > 0){
547 foreach($opData[
'input'][
'parts'] as
$name =>
$type){
548 $paramStr .=
"\$$name,";
550 $paramStr = substr($paramStr,0,strlen($paramStr)-1);
552 $opData[
'namespace'] = !isset($opData[
'namespace']) ?
'http://testuri.com' : $opData[
'namespace'];
553 $evalStr .=
"function $operation ($paramStr){
554 // load params into array
555 \$params = array($paramStr);
556 return \$this->call('$operation',\$params,'".$opData[
'namespace'].
"','".(isset($opData[
'soapAction']) ? $opData[
'soapAction'] :
'').
"');
562 $evalStr =
'class soap_proxy_'.$r.
' extends soap_client {
569 eval(
"\$proxy = new soap_proxy_$r('');");
571 $proxy->endpointType =
'wsdl';
572 $proxy->wsdlFile = $this->wsdlFile;
633 $this->decode_utf8 = $bool;