Page 1 of 1

Problem running basic Web Service on XAMPP

Posted: Tue Jun 29, 2010 1:12 pm
by emmbec
Hi all, I am trying to create a PHP web service using the nusoap.php library. I read the tutorial at http://www.codewalkers.com/c/a/Miscella ... -with-PHP/ but I just can't get it to work :banghead: I keep getting the following error:

[text]Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/webservices/stockserver.php' : Premature end of data in tag html line 2 in E:\xampp\htdocs\webservices\client.php:3 Stack trace: #0 E:\xampp\htdocs\webservices\client.php(3): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in E:\xampp\htdocs\webservices\client.php on line 3[/text]

The server side code is:

Code: Select all

<?php
function getStockQuote($symbol) {

    mysql_pconnect('localhost','root','Delphi00');
    mysql_select_db('test');
    $query = "SELECT stock_price FROM stockprices "
           . "WHERE stock_symbol = '$symbol'";
    $result = mysql_query($query);

    $row = mysql_fetch_assoc($result);
    return $row['stock_price'];
}

require('lib/nusoap.php');

$server = new soap_server();

$server->configureWSDL('stockserver', 'urn:stockquote');

$server->register("getStockQuote",
                array('symbol' => 'xsd:string'),
                array('return' => 'xsd:decimal'),
                'urn:stockquote',
                'urn:stockquote#getStockQuote');

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                      ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
The client side is:

Code: Select all

<?php
require_once('lib/nusoap.php');
$c = new soapclient('http://localhost/webservices/stockserver.php');
$stockprice = $c->call('getStockQuote', array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>
I've read that SOAP has some problems with some PHP versions I'm not sure if that is my problem. I am using XAMPP version 1.7.3 and it has PHP version 5.3.1, I tested it on another server that has IIS with PHP version 5.2.3 and it seems to work!

Any ideas besides downgrading my XAMPP/PHP version?

Thanks!

Re: Problem running basic Web Service on XAMPP

Posted: Tue Jun 29, 2010 7:22 pm
by Jade
Have you tried looking at the php.ini on your IIS machine and comparing that to your php.ini on the other? My guess is that it's a problem there... it's probably just turned off.

Re: Problem running basic Web Service on XAMPP

Posted: Tue Jun 29, 2010 11:47 pm
by emmbec
I haven't I'll check that out tomorrow. By the way, I made another test on an older XAMPP installation using PHP5 SOAP services and I have the same problem, is not just the nusoap library the one that has problems in a XAMPP installation. I tried uploading it to a Godaddy hosting that I have and it worked fine! Weird...

Re: Problem running basic Web Service on XAMPP

Posted: Wed Jun 30, 2010 7:22 am
by Jade
Looks like the PHP5 soap extension isn't enabled by default: http://www.bluehostforum.com/archive/in ... -4115.html