I'm trying to call a webservice that I've created, but the server is returning the following error:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.savepoints.com.br/server.php?WSDL' : Premature end of data in tag html line 2 in /home/storage/a/39/1c/site1365816459/public_html/cliente.php:5 Stack trace: #0 /home/storage/a/39/1c/site1365816459/public_html/cliente.php(5): SoapClient->SoapClient('http://www.save...') #1 {main} thrown in /home/storage/a/39/1c/site1365816459/public_html/cliente.php on line 5
Here I show my two scripts:
server.php (it's the WSDL server)
<?php
require('classes/nusoap/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);
?>
cliente.php
<?php
require('classes/nusoap/nusoap.php');
$c = new SoapClient('http://www.savepoints.com.br/server.php?WSDL');
$stockprice = $c->call('getStockQuote',array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is ".$stockprice.".";
?>
With server NuSOAP
and client PHP-SOAP
.
Use:
$c = new SoapClient('http://www.savepoints.com.br/server.php?wsdl');
Instead of:
$c = new SoapClient('http://www.savepoints.com.br/server.php?WSDL');
I do not know why, but it works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With