class.soap_server.php 39 KB

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