MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlproxy.php
Ir para a documentação deste ficheiro.
1<?php
2
3/*
4PhpWsdl - Generate WSDL from PHP
5Copyright (C) 2011 Andreas Zimmermann, wan24.de
6
7This program is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free Software
9Foundation; either version 3 of the License, or (at your option) any later
10version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, see <http://www.gnu.org/licenses/>.
18*/
19
20if(basename($_SERVER['SCRIPT_FILENAME'])==basename(__FILE__))
21 exit;
22
23// This proxy can handle missing parameters with NULL values. This will only
24// work, if the PhpWsdl class doesn't promote the WSDL to the SoapServer. But
25// then returning complex types won't be easy anymore: You have to encode the
26// return value with PHPs SoapVar object by yourself.
27
29 public function __call($method,$param){
31 PhpWsdl::Debug('Proxy call method '.$method.': '.print_r($param,true));
32 PhpWsdl::$ProxyServer->CreateWsdl();
33 $m=PhpWsdl::$ProxyServer->GetMethod($method);
34 if(is_null($m))
35 throw(new SoapFault('MissingMethod','Method "'.$method.'" not found'));
36 // Try to fix the missing parameters issue if the SoapServer is not running in WSDL mode
38 $pLen=sizeof($m->Param);
39 $temp=sizeof($param);
40 if($pLen!=$temp){
41 PhpWsdl::Debug('Wrong parameter count ('.$temp.'/'.$pLen.')');
42 $req=new DOMDocument();
43 if($req->loadXml(file_get_contents('php://input'))){
44 $x=new DOMXPath($req);
45 $temp=$param;
46 $param=Array();
47 $pos=0;// Current index in the received parameter array
48 $i=-1;
49 while(++$i<$pLen){
50 $p=$m->Param[$i];
51 if($x->query("/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='".$m->Name."']/*[local-name()='".$p->Name."']")->length>0){
52 PhpWsdl::Debug('Parameter "'.$p->Name.'" was received');
53 $param[]=$temp[$pos];
54 $pos++;
55 }else{
56 PhpWsdl::Debug('Parameter "'.$p->Name.'" was missing');
57 $param[]=null;
58 }
59 }
60 }else{
61 PhpWsdl::Debug('Could not parse SOAP request XML');
62 }
63 }
64 }
65 // Prepare the method call
66 $call=($m->IsGlobal)
67 ?$method // Global method
68 :Array( // Class method
70 $method
71 );
72 // Call the target method and return the response
73 PhpWsdl::Debug('Call the target method');
74 return (sizeof($param)<1)
75 ?call_user_func(
76 $call
77 )
78 :call_user_func_array(
79 $call,
80 $param
81 );
82 }
83}
__call($method, $param)
static Debug($str)
static $ProxyObject
static $Debugging
static $UseProxyWsdl
static $ProxyServer