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