I was looking around for an easy way to get started with web services in PHP, and found
an article here on Code Project extolling the virtues of NuSOAP. After grabbing the latest version from Sourceforge I set to getting the basic helloWorld service described in both that Code Project article and
this, more comprehensive article working.
A normal PHP script works fine in my environment, but both my client and server scripts are giving a cryptic error:
HTTP Error 500.0 - Internal Server Error
C:\Program Files (x86)\PHP\php-cgi.exe - The FastCGI process exited unexpectedly
The first thing I started doing was commenting out lines of my client.php page from the bottom up, eventually isolating the problem to this line:
$client = new soapclient('http://localhost:81/site/helloWorld.php');
Going to "http://localhost:81/site/helloWorld.php" in my browser gives me the same 500 error, not a 404, so I know there's no problem with path/virtual directory.
So I did some more searching online and found that some people have debugged FastCGI errors by running the PHP script from the command-line and noticing an invalid DLL reference.
So, first I tried my service:
C:\Program Files (x86)\PHP>php-cgi.exe D:\webdir\helloWorld.php
X-Powered-By: PHP/5.2.14
Content-Type: text/html; charset=ISO-8859-1
This service does not provide a Web Description
Running my client script the same way just causes php-cgi.exe to crash in typical Windows "... has stopped working" alert fashion. But at least the service gave me some sort of an error message!
Next natural step was to
search for "This service does not provide a Web Description" which returned a number of results of the NuSOAP documentation...
Specifically,
class.soap_server.php. And there on line 304 is:
print "This service does not provide a Web description";
But why am I getting this?!
Both of the (suspiciously similar, ahem) articles linked earlier are pretty clear-cut and don't waste words explaining any special hosting requirements for the server. From the best I can parse that part of class.soap_server.php, it looks to me like it's checking the Request Method (GET/POST), determining that it's GET, and then trying to identify what the caller wanted and failing.
Which kind of makes sense when I call the script directly either from the browser or command-line, but why would there be a problem with the client constructor?!
Am I reading the code wrong, or is this error just a red herring masking a different problem when I call the constructor?
For the lazy, here's the entire function from class.soap_server.php which is generating the only error I'm seeing (right at the bottom):
function service($data){
237 global $HTTP_SERVER_VARS;
238
239 if (isset($_SERVER['REQUEST_METHOD'])) {
240 $rm = $_SERVER['REQUEST_METHOD'];
241 } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
242 $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
243 } else {
244 $rm = '';
245 }
246
247 if (isset($_SERVER['QUERY_STRING'])) {
248 $qs = $_SERVER['QUERY_STRING'];
249 } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
250 $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
251 } else {
252 $qs = '';
253 }
254 $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
255
256 if ($rm == 'POST') {
257 $this->debug("In service, invoke the request");
258 $this->parse_request($data);
259 if (! $this->fault) {
260 $this->invoke_method();
261 }
262 if (! $this->fault) {
263 $this->serialize_return();
264 }
265 $this->send_response();
266 } elseif (preg_match('/wsdl/', $qs) ){
267 $this->debug("In service, this is a request for WSDL");
268 if ($this->externalWSDLURL){
269 if (strpos($this->externalWSDLURL, "http://") !== false) {
270 $this->debug("In service, re-direct for WSDL");
271 header('Location: '.$this->externalWSDLURL);
272 } else {
273 $this->debug("In service, use file passthru for WSDL");
274 header("Content-Type: text/xml\r\n");
275 $pos = strpos($this->externalWSDLURL, "file://");
276 if ($pos === false) {
277 $filename = $this->externalWSDLURL;
278 } else {
279 $filename = substr($this->externalWSDLURL, $pos + 7);
280 }
281 $fp = fopen($this->externalWSDLURL, 'r');
282 fpassthru($fp);
283 }
284 } elseif ($this->wsdl) {
285 $this->debug("In service, serialize WSDL");
286 header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
287 print $this->wsdl->serialize($this->debug_flag);
288 if ($this->debug_flag) {
289 $this->debug('wsdl:');
290 $this->appendDebug($this->varDump($this->wsdl));
291 print $this->getDebugAsXMLComment();
292 }
293 } else {
294 $this->debug("In service, there is no WSDL");
295 header("Content-Type: text/html; charset=ISO-8859-1\r\n");
296 print "This service does not provide WSDL";
297 }
298 } elseif ($this->wsdl) {
299 $this->debug("In service, return Web description");
300 print $this->wsdl->webDescription();
301 } else {
302 $this->debug("In service, no Web description");
303 header("Content-Type: text/html; charset=ISO-8859-1\r\n");
304 print "This service does not provide a Web description";
305 }
306 }
As for my code, it's exactly the same as described in the
second tutorial article I linked earlier.
HELP! :confused: