class.soap_server.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. <?php
  2. /**
  3. *
  4. * nusoap_server allows the user to create a SOAP server
  5. * that is capable of receiving messages and returning responses
  6. *
  7. * @author Dietrich Ayala <dietrich@ganx4.com>
  8. * @author Scott Nichol <snichol@users.sourceforge.net>
  9. * @version $Id: class.soap_server.php,v 1.63 2010/04/26 20:15:08 snichol Exp $
  10. * @access public
  11. */
  12. class nusoap_server extends nusoap_base {
  13. /**
  14. * HTTP headers of request
  15. * @var array
  16. * @access private
  17. */
  18. var $headers = array();
  19. /**
  20. * HTTP request
  21. * @var string
  22. * @access private
  23. */
  24. var $request = '';
  25. /**
  26. * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
  27. * @var string
  28. * @access public
  29. */
  30. var $requestHeaders = '';
  31. /**
  32. * SOAP Headers from request (parsed)
  33. * @var mixed
  34. * @access public
  35. */
  36. var $requestHeader = NULL;
  37. /**
  38. * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
  39. * @var string
  40. * @access public
  41. */
  42. var $document = '';
  43. /**
  44. * SOAP payload for request (text)
  45. * @var string
  46. * @access public
  47. */
  48. var $requestSOAP = '';
  49. /**
  50. * requested method namespace URI
  51. * @var string
  52. * @access private
  53. */
  54. var $methodURI = '';
  55. /**
  56. * name of method requested
  57. * @var string
  58. * @access private
  59. */
  60. var $methodname = '';
  61. /**
  62. * method parameters from request
  63. * @var array
  64. * @access private
  65. */
  66. var $methodparams = array();
  67. /**
  68. * SOAP Action from request
  69. * @var string
  70. * @access private
  71. */
  72. var $SOAPAction = '';
  73. /**
  74. * character set encoding of incoming (request) messages
  75. * @var string
  76. * @access public
  77. */
  78. var $xml_encoding = '';
  79. /**
  80. * toggles whether the parser decodes element content w/ utf8_decode()
  81. * @var boolean
  82. * @access public
  83. */
  84. var $decode_utf8 = true;
  85. /**
  86. * HTTP headers of response
  87. * @var array
  88. * @access public
  89. */
  90. var $outgoing_headers = array();
  91. /**
  92. * HTTP response
  93. * @var string
  94. * @access private
  95. */
  96. var $response = '';
  97. /**
  98. * SOAP headers for response (text or array of soapval or associative array)
  99. * @var mixed
  100. * @access public
  101. */
  102. var $responseHeaders = '';
  103. /**
  104. * SOAP payload for response (text)
  105. * @var string
  106. * @access private
  107. */
  108. var $responseSOAP = '';
  109. /**
  110. * method return value to place in response
  111. * @var mixed
  112. * @access private
  113. */
  114. var $methodreturn = false;
  115. /**
  116. * whether $methodreturn is a string of literal XML
  117. * @var boolean
  118. * @access public
  119. */
  120. var $methodreturnisliteralxml = false;
  121. /**
  122. * SOAP fault for response (or false)
  123. * @var mixed
  124. * @access private
  125. */
  126. var $fault = false;
  127. /**
  128. * text indication of result (for debugging)
  129. * @var string
  130. * @access private
  131. */
  132. var $result = 'successful';
  133. /**
  134. * assoc array of operations => opData; operations are added by the register()
  135. * method or by parsing an external WSDL definition
  136. * @var array
  137. * @access private
  138. */
  139. var $operations = array();
  140. /**
  141. * wsdl instance (if one)
  142. * @var mixed
  143. * @access private
  144. */
  145. var $wsdl = false;
  146. /**
  147. * URL for WSDL (if one)
  148. * @var mixed
  149. * @access private
  150. */
  151. var $externalWSDLURL = false;
  152. /**
  153. * whether to append debug to response as XML comment
  154. * @var boolean
  155. * @access public
  156. */
  157. var $debug_flag = false;
  158. /**
  159. * constructor
  160. * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
  161. *
  162. * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
  163. * @access public
  164. */
  165. public function __construct($wsdl = false)
  166. {
  167. parent::__construct();
  168. // turn on debugging?
  169. global $debug;
  170. global $HTTP_SERVER_VARS;
  171. if (isset($_SERVER)) {
  172. $this->debug("_SERVER is defined:");
  173. $this->appendDebug($this->varDump($_SERVER));
  174. } elseif (isset($HTTP_SERVER_VARS)) {
  175. $this->debug("HTTP_SERVER_VARS is defined:");
  176. $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
  177. } else {
  178. $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
  179. }
  180. if (isset($debug)) {
  181. $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
  182. $this->debug_flag = $debug;
  183. } elseif (isset($_SERVER['QUERY_STRING'])) {
  184. $qs = explode('&', $_SERVER['QUERY_STRING']);
  185. foreach ($qs as $v) {
  186. if (substr($v, 0, 6) == 'debug=') {
  187. $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
  188. $this->debug_flag = substr($v, 6);
  189. }
  190. }
  191. } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  192. $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
  193. foreach ($qs as $v) {
  194. if (substr($v, 0, 6) == 'debug=') {
  195. $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
  196. $this->debug_flag = substr($v, 6);
  197. }
  198. }
  199. }
  200. // wsdl
  201. if ($wsdl){
  202. $this->debug("In nusoap_server, WSDL is specified");
  203. if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
  204. $this->wsdl = $wsdl;
  205. $this->wsdl->soap_defencoding = $this->soap_defencoding;
  206. $this->externalWSDLURL = $this->wsdl->wsdl;
  207. $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
  208. } else {
  209. $this->debug('Create wsdl from ' . $wsdl);
  210. $this->wsdl = new wsdl($wsdl);
  211. $this->wsdl->soap_defencoding = $this->soap_defencoding;
  212. $this->externalWSDLURL = $wsdl;
  213. }
  214. $this->appendDebug($this->wsdl->getDebug());
  215. $this->wsdl->clearDebug();
  216. if($err = $this->wsdl->getError()){
  217. die('WSDL ERROR: '.$err);
  218. }
  219. }
  220. }
  221. /**
  222. * processes request and returns response
  223. *
  224. * @param string $data usually is the value of $HTTP_RAW_POST_DATA
  225. * @access public
  226. */
  227. function service($data){
  228. global $HTTP_SERVER_VARS;
  229. if (isset($_SERVER['REQUEST_METHOD'])) {
  230. $rm = $_SERVER['REQUEST_METHOD'];
  231. } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
  232. $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
  233. } else {
  234. $rm = '';
  235. }
  236. if (isset($_SERVER['QUERY_STRING'])) {
  237. $qs = $_SERVER['QUERY_STRING'];
  238. } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  239. $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
  240. } else {
  241. $qs = '';
  242. }
  243. $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
  244. if ($rm == 'POST') {
  245. $this->debug("In service, invoke the request");
  246. $this->parse_request($data);
  247. if (! $this->fault) {
  248. $this->invoke_method();
  249. }
  250. if (! $this->fault) {
  251. $this->serialize_return();
  252. }
  253. $this->send_response();
  254. } elseif (preg_match('/wsdl/', $qs) ){
  255. $this->debug("In service, this is a request for WSDL");
  256. if ($this->externalWSDLURL){
  257. if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
  258. $this->debug("In service, re-direct for WSDL");
  259. header('Location: '.$this->externalWSDLURL);
  260. } else { // assume file
  261. $this->debug("In service, use file passthru for WSDL");
  262. header("Content-Type: text/xml\r\n");
  263. $pos = strpos($this->externalWSDLURL, "file://");
  264. if ($pos === false) {
  265. $filename = $this->externalWSDLURL;
  266. } else {
  267. $filename = substr($this->externalWSDLURL, $pos + 7);
  268. }
  269. $fp = fopen($this->externalWSDLURL, 'r');
  270. fpassthru($fp);
  271. }
  272. } elseif ($this->wsdl) {
  273. $this->debug("In service, serialize WSDL");
  274. header("Content-Type: text/xml; charset=".$this->soap_defencoding."\r\n");
  275. print $this->wsdl->serialize($this->debug_flag);
  276. if ($this->debug_flag) {
  277. $this->debug('wsdl:');
  278. $this->appendDebug($this->varDump($this->wsdl));
  279. print $this->getDebugAsXMLComment();
  280. }
  281. } else {
  282. $this->debug("In service, there is no WSDL");
  283. header("Content-Type: text/html; charset=".$this->soap_defencoding."\r\n");
  284. print "This service does not provide WSDL";
  285. }
  286. } elseif ($this->wsdl) {
  287. $this->debug("In service, return Web description");
  288. print $this->wsdl->webDescription();
  289. } else {
  290. $this->debug("In service, no Web description");
  291. header("Content-Type: text/html; charset=ISO-8859-1\r\n");
  292. print "This service does not provide a Web description";
  293. }
  294. }
  295. /**
  296. * parses HTTP request headers.
  297. *
  298. * The following fields are set by this function (when successful)
  299. *
  300. * headers
  301. * request
  302. * xml_encoding
  303. * SOAPAction
  304. *
  305. * @access private
  306. */
  307. function parse_http_headers() {
  308. global $HTTP_SERVER_VARS;
  309. $this->request = '';
  310. $this->SOAPAction = '';
  311. if(function_exists('getallheaders')){
  312. $this->debug("In parse_http_headers, use getallheaders");
  313. $headers = getallheaders();
  314. foreach($headers as $k=>$v){
  315. $k = strtolower($k);
  316. $this->headers[$k] = $v;
  317. $this->request .= "$k: $v\r\n";
  318. $this->debug("$k: $v");
  319. }
  320. // get SOAPAction header
  321. if(isset($this->headers['soapaction'])){
  322. $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
  323. }
  324. // get the character encoding of the incoming request
  325. if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
  326. $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
  327. if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
  328. $this->xml_encoding = strtoupper($enc);
  329. } else {
  330. $this->xml_encoding = 'US-ASCII';
  331. }
  332. } else {
  333. // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
  334. $this->xml_encoding = 'ISO-8859-1';
  335. }
  336. } elseif(isset($_SERVER) && is_array($_SERVER)){
  337. $this->debug("In parse_http_headers, use _SERVER");
  338. foreach ($_SERVER as $k => $v) {
  339. if (substr($k, 0, 5) == 'HTTP_') {
  340. $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
  341. } else {
  342. $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
  343. }
  344. if ($k == 'soapaction') {
  345. // get SOAPAction header
  346. $k = 'SOAPAction';
  347. $v = str_replace('"', '', $v);
  348. $v = str_replace('\\', '', $v);
  349. $this->SOAPAction = $v;
  350. } else if ($k == 'content-type') {
  351. // get the character encoding of the incoming request
  352. if (strpos($v, '=')) {
  353. $enc = substr(strstr($v, '='), 1);
  354. $enc = str_replace('"', '', $enc);
  355. $enc = str_replace('\\', '', $enc);
  356. if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
  357. $this->xml_encoding = strtoupper($enc);
  358. } else {
  359. $this->xml_encoding = 'US-ASCII';
  360. }
  361. } else {
  362. // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
  363. $this->xml_encoding = 'ISO-8859-1';
  364. }
  365. }
  366. $this->headers[$k] = $v;
  367. $this->request .= "$k: $v\r\n";
  368. $this->debug("$k: $v");
  369. }
  370. } elseif (is_array($HTTP_SERVER_VARS)) {
  371. $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
  372. foreach ($HTTP_SERVER_VARS as $k => $v) {
  373. if (substr($k, 0, 5) == 'HTTP_') {
  374. $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
  375. } else {
  376. $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
  377. }
  378. if ($k == 'soapaction') {
  379. // get SOAPAction header
  380. $k = 'SOAPAction';
  381. $v = str_replace('"', '', $v);
  382. $v = str_replace('\\', '', $v);
  383. $this->SOAPAction = $v;
  384. } else if ($k == 'content-type') {
  385. // get the character encoding of the incoming request
  386. if (strpos($v, '=')) {
  387. $enc = substr(strstr($v, '='), 1);
  388. $enc = str_replace('"', '', $enc);
  389. $enc = str_replace('\\', '', $enc);
  390. if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
  391. $this->xml_encoding = strtoupper($enc);
  392. } else {
  393. $this->xml_encoding = 'US-ASCII';
  394. }
  395. } else {
  396. // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
  397. $this->xml_encoding = 'ISO-8859-1';
  398. }
  399. }
  400. $this->headers[$k] = $v;
  401. $this->request .= "$k: $v\r\n";
  402. $this->debug("$k: $v");
  403. }
  404. } else {
  405. $this->debug("In parse_http_headers, HTTP headers not accessible");
  406. $this->setError("HTTP headers not accessible");
  407. }
  408. }
  409. /**
  410. * parses a request
  411. *
  412. * The following fields are set by this function (when successful)
  413. *
  414. * headers
  415. * request
  416. * xml_encoding
  417. * SOAPAction
  418. * request
  419. * requestSOAP
  420. * methodURI
  421. * methodname
  422. * methodparams
  423. * requestHeaders
  424. * document
  425. *
  426. * This sets the fault field on error
  427. *
  428. * @param string $data XML string
  429. * @access private
  430. */
  431. function parse_request($data='') {
  432. $this->debug('entering parse_request()');
  433. $this->parse_http_headers();
  434. $this->debug('got character encoding: '.$this->xml_encoding);
  435. // uncompress if necessary
  436. if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
  437. $this->debug('got content encoding: ' . $this->headers['content-encoding']);
  438. if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
  439. // if decoding works, use it. else assume data wasn't gzencoded
  440. if (function_exists('gzuncompress')) {
  441. if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
  442. $data = $degzdata;
  443. } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
  444. $data = $degzdata;
  445. } else {
  446. $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
  447. return;
  448. }
  449. } else {
  450. $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
  451. return;
  452. }
  453. }
  454. }
  455. $this->request .= "\r\n".$data;
  456. $data = $this->parseRequest($this->headers, $data);
  457. $this->requestSOAP = $data;
  458. $this->debug('leaving parse_request');
  459. }
  460. /**
  461. * invokes a PHP function for the requested SOAP method
  462. *
  463. * The following fields are set by this function (when successful)
  464. *
  465. * methodreturn
  466. *
  467. * Note that the PHP function that is called may also set the following
  468. * fields to affect the response sent to the client
  469. *
  470. * responseHeaders
  471. * outgoing_headers
  472. *
  473. * This sets the fault field on error
  474. *
  475. * @access private
  476. */
  477. function invoke_method() {
  478. $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
  479. //
  480. // if you are debugging in this area of the code, your service uses a class to implement methods,
  481. // you use SOAP RPC, and the client is .NET, please be aware of the following...
  482. // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
  483. // method name. that is fine for naming the .NET methods. it is not fine for properly constructing
  484. // the XML request and reading the XML response. you need to add the RequestElementName and
  485. // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
  486. // generates for the method. these parameters are used to specify the correct XML element names
  487. // for .NET to use, i.e. the names with the '.' in them.
  488. //
  489. $orig_methodname = $this->methodname;
  490. if ($this->wsdl) {
  491. if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
  492. $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
  493. $this->appendDebug('opData=' . $this->varDump($this->opData));
  494. } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
  495. // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
  496. $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
  497. $this->appendDebug('opData=' . $this->varDump($this->opData));
  498. $this->methodname = $this->opData['name'];
  499. } else {
  500. $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
  501. $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
  502. return;
  503. }
  504. } else {
  505. $this->debug('in invoke_method, no WSDL to validate method');
  506. }
  507. // if a . is present in $this->methodname, we see if there is a class in scope,
  508. // which could be referred to. We will also distinguish between two deliminators,
  509. // to allow methods to be called a the class or an instance
  510. if (strpos($this->methodname, '..') > 0) {
  511. $delim = '..';
  512. } else if (strpos($this->methodname, '.') > 0) {
  513. $delim = '.';
  514. } else {
  515. $delim = '';
  516. }
  517. $this->debug("in invoke_method, delim=$delim");
  518. $class = '';
  519. $method = '';
  520. if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
  521. $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
  522. if (class_exists($try_class)) {
  523. // get the class and method name
  524. $class = $try_class;
  525. $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
  526. $this->debug("in invoke_method, class=$class method=$method delim=$delim");
  527. } else {
  528. $this->debug("in invoke_method, class=$try_class not found");
  529. }
  530. } else {
  531. $try_class = '';
  532. $this->debug("in invoke_method, no class to try");
  533. }
  534. // does method exist?
  535. if ($class == '') {
  536. if (!function_exists($this->methodname)) {
  537. $this->debug("in invoke_method, function '$this->methodname' not found!");
  538. $this->result = 'fault: method not found';
  539. $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
  540. return;
  541. }
  542. } else {
  543. $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
  544. if (!in_array($method_to_compare, get_class_methods($class))) {
  545. $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
  546. $this->result = 'fault: method not found';
  547. $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
  548. return;
  549. }
  550. }
  551. // evaluate message, getting back parameters
  552. // verify that request parameters match the method's signature
  553. if(! $this->verify_method($this->methodname,$this->methodparams)){
  554. // debug
  555. $this->debug('ERROR: request not verified against method signature');
  556. $this->result = 'fault: request failed validation against method signature';
  557. // return fault
  558. $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
  559. return;
  560. }
  561. // if there are parameters to pass
  562. $this->debug('in invoke_method, params:');
  563. $this->appendDebug($this->varDump($this->methodparams));
  564. $this->debug("in invoke_method, calling '$this->methodname'");
  565. if (!function_exists('call_user_func_array')) {
  566. if ($class == '') {
  567. $this->debug('in invoke_method, calling function using eval()');
  568. $funcCall = "\$this->methodreturn = $this->methodname(";
  569. } else {
  570. if ($delim == '..') {
  571. $this->debug('in invoke_method, calling class method using eval()');
  572. $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
  573. } else {
  574. $this->debug('in invoke_method, calling instance method using eval()');
  575. // generate unique instance name
  576. $instname = "\$inst_".time();
  577. $funcCall = $instname." = new ".$class."(); ";
  578. $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
  579. }
  580. }
  581. if ($this->methodparams) {
  582. foreach ($this->methodparams as $param) {
  583. if (is_array($param) || is_object($param)) {
  584. $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
  585. return;
  586. }
  587. $funcCall .= "\"$param\",";
  588. }
  589. $funcCall = substr($funcCall, 0, -1);
  590. }
  591. $funcCall .= ');';
  592. $this->debug('in invoke_method, function call: '.$funcCall);
  593. @eval($funcCall);
  594. } else {
  595. if ($class == '') {
  596. $this->debug('in invoke_method, calling function using call_user_func_array()');
  597. $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array()
  598. } elseif ($delim == '..') {
  599. $this->debug('in invoke_method, calling class method using call_user_func_array()');
  600. $call_arg = array ($class, $method);
  601. } else {
  602. $this->debug('in invoke_method, calling instance method using call_user_func_array()');
  603. $instance = new $class ();
  604. $call_arg = array(&$instance, $method);
  605. }
  606. if (is_array($this->methodparams)) {
  607. $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
  608. } else {
  609. $this->methodreturn = call_user_func_array($call_arg, array());
  610. }
  611. }
  612. $this->debug('in invoke_method, methodreturn:');
  613. $this->appendDebug($this->varDump($this->methodreturn));
  614. $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
  615. }
  616. /**
  617. * serializes the return value from a PHP function into a full SOAP Envelope
  618. *
  619. * The following fields are set by this function (when successful)
  620. *
  621. * responseSOAP
  622. *
  623. * This sets the fault field on error
  624. *
  625. * @access private
  626. */
  627. function serialize_return() {
  628. $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
  629. // if fault
  630. if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
  631. $this->debug('got a fault object from method');
  632. $this->fault = $this->methodreturn;
  633. return;
  634. } elseif ($this->methodreturnisliteralxml) {
  635. $return_val = $this->methodreturn;
  636. // returned value(s)
  637. } else {
  638. $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
  639. $this->debug('serializing return value');
  640. if($this->wsdl){
  641. $opParams = "";
  642. if (sizeof($this->opData['output']['parts']) > 1) {
  643. $this->debug('more than one output part, so use the method return unchanged');
  644. $opParams = $this->methodreturn;
  645. } elseif (sizeof($this->opData['output']['parts']) == 1) {
  646. $this->debug('exactly one output part, so wrap the method return in a simple array');
  647. // TODO: verify that it is not already wrapped!
  648. //foreach ($this->opData['output']['parts'] as $name => $type) {
  649. // $this->debug('wrap in element named ' . $name);
  650. //}
  651. $opParams = array($this->methodreturn);
  652. }
  653. $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
  654. $this->appendDebug($this->wsdl->getDebug());
  655. $this->wsdl->clearDebug();
  656. if($errstr = $this->wsdl->getError()){
  657. $this->debug('got wsdl error: '.$errstr);
  658. $this->fault('SOAP-ENV:Server', 'unable to serialize result');
  659. return;
  660. }
  661. } else {
  662. if (isset($this->methodreturn)) {
  663. $return_val = $this->serialize_val($this->methodreturn, 'return');
  664. } else {
  665. $return_val = '';
  666. $this->debug('in absence of WSDL, assume void return for backward compatibility');
  667. }
  668. }
  669. }
  670. $this->debug('return value:');
  671. $this->appendDebug($this->varDump($return_val));
  672. $this->debug('serializing response');
  673. if ($this->wsdl) {
  674. $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
  675. if ($this->opData['style'] == 'rpc') {
  676. $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
  677. if ($this->opData['output']['use'] == 'literal') {
  678. // 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
  679. if ($this->methodURI) {
  680. $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
  681. } else {
  682. $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
  683. }
  684. } else {
  685. if ($this->methodURI) {
  686. $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
  687. } else {
  688. $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
  689. }
  690. }
  691. } else {
  692. $this->debug('style is not rpc for serialization: assume document');
  693. $payload = $return_val;
  694. }
  695. } else {
  696. $this->debug('do not have WSDL for serialization: assume rpc/encoded');
  697. $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
  698. }
  699. $this->result = 'successful';
  700. if($this->wsdl){
  701. //if($this->debug_flag){
  702. $this->appendDebug($this->wsdl->getDebug());
  703. // }
  704. if (isset($this->opData['output']['encodingStyle'])) {
  705. $encodingStyle = $this->opData['output']['encodingStyle'];
  706. } else {
  707. $encodingStyle = '';
  708. }
  709. // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
  710. $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
  711. } else {
  712. $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
  713. }
  714. $this->debug("Leaving serialize_return");
  715. }
  716. /**
  717. * sends an HTTP response
  718. *
  719. * The following fields are set by this function (when successful)
  720. *
  721. * outgoing_headers
  722. * response
  723. *
  724. * @access private
  725. */
  726. function send_response() {
  727. $this->debug('Enter send_response');
  728. if ($this->fault) {
  729. $payload = $this->fault->serialize();
  730. $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
  731. $this->outgoing_headers[] = "Status: 500 Internal Server Error";
  732. } else {
  733. $payload = $this->responseSOAP;
  734. // Some combinations of PHP+Web server allow the Status
  735. // to come through as a header. Since OK is the default
  736. // just do nothing.
  737. // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
  738. // $this->outgoing_headers[] = "Status: 200 OK";
  739. }
  740. // add debug data if in debug mode
  741. if(isset($this->debug_flag) && $this->debug_flag){
  742. $payload .= $this->getDebugAsXMLComment();
  743. }
  744. $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
  745. preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
  746. $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
  747. // Let the Web server decide about this
  748. //$this->outgoing_headers[] = "Connection: Close\r\n";
  749. $payload = $this->getHTTPBody($payload);
  750. $type = $this->getHTTPContentType();
  751. $charset = $this->getHTTPContentTypeCharset();
  752. $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
  753. //begin code to compress payload - by John
  754. // NOTE: there is no way to know whether the Web server will also compress
  755. // this data.
  756. if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
  757. if (strstr($this->headers['accept-encoding'], 'gzip')) {
  758. if (function_exists('gzencode')) {
  759. if (isset($this->debug_flag) && $this->debug_flag) {
  760. $payload .= "<!-- Content being gzipped -->";
  761. }
  762. $this->outgoing_headers[] = "Content-Encoding: gzip";
  763. $payload = gzencode($payload);
  764. } else {
  765. if (isset($this->debug_flag) && $this->debug_flag) {
  766. $payload .= "<!-- Content will not be gzipped: no gzencode -->";
  767. }
  768. }
  769. } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
  770. // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
  771. // instead of gzcompress output,
  772. // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
  773. if (function_exists('gzdeflate')) {
  774. if (isset($this->debug_flag) && $this->debug_flag) {
  775. $payload .= "<!-- Content being deflated -->";
  776. }
  777. $this->outgoing_headers[] = "Content-Encoding: deflate";
  778. $payload = gzdeflate($payload);
  779. } else {
  780. if (isset($this->debug_flag) && $this->debug_flag) {
  781. $payload .= "<!-- Content will not be deflated: no gzcompress -->";
  782. }
  783. }
  784. }
  785. }
  786. //end code
  787. $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
  788. reset($this->outgoing_headers);
  789. foreach($this->outgoing_headers as $hdr){
  790. header($hdr, false);
  791. }
  792. print $payload;
  793. $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
  794. }
  795. /**
  796. * takes the value that was created by parsing the request
  797. * and compares to the method's signature, if available.
  798. *
  799. * @param string $operation The operation to be invoked
  800. * @param array $request The array of parameter values
  801. * @return boolean Whether the operation was found
  802. * @access private
  803. */
  804. function verify_method($operation,$request){
  805. if(isset($this->wsdl) && is_object($this->wsdl)){
  806. if($this->wsdl->getOperationData($operation)){
  807. return true;
  808. }
  809. } elseif(isset($this->operations[$operation])){
  810. return true;
  811. }
  812. return false;
  813. }
  814. /**
  815. * processes SOAP message received from client
  816. *
  817. * @param array $headers The HTTP headers
  818. * @param string $data unprocessed request data from client
  819. * @return mixed value of the message, decoded into a PHP type
  820. * @access privatet
  821. */
  822. function parseRequest($headers, $data) {
  823. $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
  824. $this->appendDebug($this->varDump($headers));
  825. if (!isset($headers['content-type'])) {
  826. $this->setError('Request not of type text/xml (no content-type header)');
  827. return false;
  828. }
  829. if (!strstr($headers['content-type'], 'text/xml')) {
  830. $this->setError('Request not of type text/xml');
  831. return false;
  832. }
  833. if (strpos($headers['content-type'], '=')) {
  834. $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
  835. $this->debug('Got response encoding: ' . $enc);
  836. if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
  837. $this->xml_encoding = strtoupper($enc);
  838. } else {
  839. $this->xml_encoding = 'US-ASCII';
  840. }
  841. } else {
  842. // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
  843. $this->xml_encoding = 'ISO-8859-1';
  844. }
  845. $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
  846. // parse response, get soap parser obj
  847. $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
  848. // parser debug
  849. $this->debug("parser debug: \n".$parser->getDebug());
  850. // if fault occurred during message parsing
  851. if($err = $parser->getError()){
  852. $this->result = 'fault: error in msg parsing: '.$err;
  853. $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
  854. // else successfully parsed request into soapval object
  855. } else {
  856. // get/set methodname
  857. $this->methodURI = $parser->root_struct_namespace;
  858. $this->methodname = $parser->root_struct_name;
  859. $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
  860. $this->debug('calling parser->get_soapbody()');
  861. $this->methodparams = $parser->get_soapbody();
  862. // get SOAP headers
  863. $this->requestHeaders = $parser->getHeaders();
  864. // get SOAP Header
  865. $this->requestHeader = $parser->get_soapheader();
  866. // add document for doclit support
  867. $this->document = $parser->document;
  868. }
  869. }
  870. /**
  871. * gets the HTTP body for the current response.
  872. *
  873. * @param string $soapmsg The SOAP payload
  874. * @return string The HTTP body, which includes the SOAP payload
  875. * @access private
  876. */
  877. function getHTTPBody($soapmsg) {
  878. return $soapmsg;
  879. }
  880. /**
  881. * gets the HTTP content type for the current response.
  882. *
  883. * Note: getHTTPBody must be called before this.
  884. *
  885. * @return string the HTTP content type for the current response.
  886. * @access private
  887. */
  888. function getHTTPContentType() {
  889. return 'text/xml';
  890. }
  891. /**
  892. * gets the HTTP content type charset for the current response.
  893. * returns false for non-text content types.
  894. *
  895. * Note: getHTTPBody must be called before this.
  896. *
  897. * @return string the HTTP content type charset for the current response.
  898. * @access private
  899. */
  900. function getHTTPContentTypeCharset() {
  901. return $this->soap_defencoding;
  902. }
  903. /**
  904. * add a method to the dispatch map (this has been replaced by the register method)
  905. *
  906. * @param string $methodname
  907. * @param string $in array of input values
  908. * @param string $out array of output values
  909. * @access public
  910. * @deprecated
  911. */
  912. function add_to_map($methodname,$in,$out){
  913. $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
  914. }
  915. /**
  916. * register a service function with the server
  917. *
  918. * @param string $name the name of the PHP function, class.method or class..method
  919. * @param array $in assoc array of input values: key = param name, value = param type
  920. * @param array $out assoc array of output values: key = param name, value = param type
  921. * @param mixed $namespace the element namespace for the method or false
  922. * @param mixed $soapaction the soapaction for the method or false
  923. * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
  924. * @param mixed $use optional (encoded|literal) or false
  925. * @param string $documentation optional Description to include in WSDL
  926. * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
  927. * @access public
  928. */
  929. function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
  930. global $HTTP_SERVER_VARS;
  931. if($this->externalWSDLURL){
  932. die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
  933. }
  934. if (! $name) {
  935. die('You must specify a name when you register an operation');
  936. }
  937. if (!is_array($in)) {
  938. die('You must provide an array for operation inputs');
  939. }
  940. if (!is_array($out)) {
  941. die('You must provide an array for operation outputs');
  942. }
  943. if(false == $namespace) {
  944. }
  945. if(false == $soapaction) {
  946. if (isset($_SERVER)) {
  947. $SERVER_NAME = $_SERVER['SERVER_NAME'];
  948. $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
  949. $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
  950. } elseif (isset($HTTP_SERVER_VARS)) {
  951. $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
  952. $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
  953. $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
  954. } else {
  955. $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
  956. }
  957. if ($HTTPS == '1' || $HTTPS == 'on') {
  958. $SCHEME = 'https';
  959. } else {
  960. $SCHEME = 'http';
  961. }
  962. $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
  963. }
  964. if(false == $style) {
  965. $style = "rpc";
  966. }
  967. if(false == $use) {
  968. $use = "encoded";
  969. }
  970. if ($use == 'encoded' && $encodingStyle == '') {
  971. $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
  972. }
  973. $this->operations[$name] = array(
  974. 'name' => $name,
  975. 'in' => $in,
  976. 'out' => $out,
  977. 'namespace' => $namespace,
  978. 'soapaction' => $soapaction,
  979. 'style' => $style);
  980. if($this->wsdl){
  981. $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
  982. }
  983. return true;
  984. }
  985. /**
  986. * Specify a fault to be returned to the client.
  987. * This also acts as a flag to the server that a fault has occured.
  988. *
  989. * @param string $faultcode
  990. * @param string $faultstring
  991. * @param string $faultactor
  992. * @param string $faultdetail
  993. * @access public
  994. */
  995. function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
  996. if ($faultdetail == '' && $this->debug_flag) {
  997. $faultdetail = $this->getDebug();
  998. }
  999. $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
  1000. $this->fault->soap_defencoding = $this->soap_defencoding;
  1001. }
  1002. /**
  1003. * Sets up wsdl object.
  1004. * Acts as a flag to enable internal WSDL generation
  1005. *
  1006. * @param string $serviceName, name of the service
  1007. * @param mixed $namespace optional 'tns' service namespace or false
  1008. * @param mixed $endpoint optional URL of service endpoint or false
  1009. * @param string $style optional (rpc|document) WSDL style (also specified by operation)
  1010. * @param string $transport optional SOAP transport
  1011. * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
  1012. */
  1013. function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
  1014. {
  1015. global $HTTP_SERVER_VARS;
  1016. if (isset($_SERVER)) {
  1017. $SERVER_NAME = $_SERVER['SERVER_NAME'];
  1018. $SERVER_PORT = $_SERVER['SERVER_PORT'];
  1019. $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
  1020. $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
  1021. } elseif (isset($HTTP_SERVER_VARS)) {
  1022. $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
  1023. $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
  1024. $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
  1025. $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
  1026. } else {
  1027. $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
  1028. }
  1029. // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
  1030. $colon = strpos($SERVER_NAME,":");
  1031. if ($colon) {
  1032. $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
  1033. }
  1034. if ($SERVER_PORT == 80) {
  1035. $SERVER_PORT = '';
  1036. } else {
  1037. $SERVER_PORT = ':' . $SERVER_PORT;
  1038. }
  1039. if(false == $namespace) {
  1040. $namespace = "http://$SERVER_NAME/soap/$serviceName";
  1041. }
  1042. if(false == $endpoint) {
  1043. if ($HTTPS == '1' || $HTTPS == 'on') {
  1044. $SCHEME = 'https';
  1045. } else {
  1046. $SCHEME = 'http';
  1047. }
  1048. $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
  1049. }
  1050. if(false == $schemaTargetNamespace) {
  1051. $schemaTargetNamespace = $namespace;
  1052. }
  1053. $this->wsdl = new wsdl();
  1054. $this->wsdl->soap_defencoding = $this->soap_defencoding;
  1055. $this->wsdl->serviceName = $serviceName;
  1056. $this->wsdl->endpoint = $endpoint;
  1057. $this->wsdl->namespaces['tns'] = $namespace;
  1058. $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
  1059. $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
  1060. if ($schemaTargetNamespace != $namespace) {
  1061. $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
  1062. }
  1063. $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
  1064. if ($style == 'document') {
  1065. $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
  1066. }
  1067. $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
  1068. $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
  1069. $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
  1070. $this->wsdl->bindings[$serviceName.'Binding'] = array(
  1071. 'name'=>$serviceName.'Binding',
  1072. 'style'=>$style,
  1073. 'transport'=>$transport,
  1074. 'portType'=>$serviceName.'PortType');
  1075. $this->wsdl->ports[$serviceName.'Port'] = array(
  1076. 'binding'=>$serviceName.'Binding',
  1077. 'location'=>$endpoint,
  1078. 'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
  1079. }
  1080. }
  1081. /**
  1082. * Backward compatibility
  1083. */
  1084. class soap_server extends nusoap_server
  1085. {
  1086. }