PHP Web Service:Uncaught SoapFault exception

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jimath
Forum Newbie
Posts: 7
Joined: Fri Sep 23, 2005 3:56 am

PHP Web Service:Uncaught SoapFault exception

Post by jimath »

hi everyone!

When i run web services applications i take always this message:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\Program Files\Apache Group\Apache2\htdocs\WebServices\SOAP_EXTENSION\StockQuote\client3.php:3 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 C:\Program Files\Apache Group\Apache2\htdocs\WebServices\SOAP_EXTENSION\StockQuote\client3.php(3): SoapClient->getQuote('ibm') #2 {main} thrown in C:\Program Files\Apache Group\Apache2\htdocs\WebServices\SOAP_EXTENSION\StockQuote\client3.php on line 3

Does anyone know anything about the problem?
i have soap extension enabled, and have tried in PHP 5.0.5, 5.1.4.
Thanks



That's the code if helps:

SERVER

Code: Select all

 
<?php
 
 
$quotes = array(
  "ibm" => 98.42
); 
 
function getQuote($symbol) {
  global $quotes;
  return $quotes[$symbol];
}
 
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("stockquote.wsdl");
$server->addFunction("getQuote");
$server->handle();
?> 
 
CLIENT

Code: Select all

 
<?php
  $client = new SoapClient("stockquote.wsdl");
  print($client->getQuote("ibm"));
?> 
 
WSDL FILE

Code: Select all

 
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='StockQuote'
  targetNamespace='http://example.org/StockQuote'
  xmlns:tns=' http://example.org/StockQuote '
  xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
  xmlns:xsd='http://www.w3.org/2001/XMLSchema'
  xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
  xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
  xmlns='http://schemas.xmlsoap.org/wsdl/'>
 
<message name='getQuoteRequest'>
  <part name='symbol' type='xsd:string'/>
</message>
<message name='getQuoteResponse'>
  <part name='Result' type='xsd:float'/>
</message>
 
<portType name='StockQuotePortType'>
  <operation name='getQuote'>
    <input message='tns:getQuoteRequest'/>
    <output message='tns:getQuoteResponse'/>
  </operation>
</portType>
 
<binding name='StockQuoteBinding' type='tns:StockQuotePortType'>
  <soap:binding style='rpc'
    transport='http://schemas.xmlsoap.org/soap/http'/>
  <operation name='getQuote'>
    <soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/>
    <input>
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
    </input>
    <output>
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
    </output>
  </operation>
</binding>
 
<service name='StockQuoteService'>
  <port name='StockQuotePort' binding='StockQuoteBinding'>
    <soap:address location='http://localhost/WebServices/SOAP_EXTENSION/StockQuote/Server1.php'/>
  </port>
</service>
</definitions>
 
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: PHP Web Service:Uncaught SoapFault exception

Post by Darhazer »

Client:

Code: Select all

<?php
  $client = new SoapClient("stockquote.wsdl", array('location' => '<URL-OF-SERVER>'));
  print($client->getQuote("ibm"));
?>
Works for me ;)
jimath
Forum Newbie
Posts: 7
Joined: Fri Sep 23, 2005 3:56 am

Re: PHP Web Service:Uncaught SoapFault exception

Post by jimath »

Unfortunately it doesn't work for me.
The same message appeared.
Any idea?

On the other hand the following is working for me:

Client

Code: Select all

 
<?php
    $ZIP = $_GET['zipcode'];
  $client = new SoapClient("TemperatureService.wsdl");
  $return = $client->getTemp($ZIP);
  echo("Temperature is: " . $return);
?>
 
Server

Code: Select all

 
<?php 
 
function getTemp($zip) { 
  $temp = rand(40,80);
  return $temp; 
} 
 
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
$server = new SoapServer("TemperatureService.wsdl"); 
$server->addFunction("getTemp"); 
$server->handle(); 
?>
 
WSDL

Code: Select all

 
<?xml version ='1.0' encoding ='UTF-8' ?> 
<definitions name='Temperature' 
  targetNamespace='http://example.org/temperature' 
  xmlns:tns=' http://example.org/temperature ' 
  xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' 
  xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
  xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' 
  xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' 
  xmlns='http://schemas.xmlsoap.org/wsdl/'> 
 
<message name='getTempRequest'> 
  <part name='symbol' type='xsd:string'/> 
</message> 
<message name='getTempResponse'> 
  <part name='Result' type='xsd:float'/> 
</message> 
 
<portType name='TempPortType'> 
  <operation name='getTemp'> 
    <input message='tns:getTempRequest'/> 
    <output message='tns:getTempResponse'/> 
  </operation> 
</portType> 
 
<binding name='TempBinding' type='tns:TempPortType'> 
  <soap:binding style='rpc' 
    transport='http://schemas.xmlsoap.org/soap/http'/> 
  <operation name='getTemp'> 
    <soap:operation soapAction='urn:localhost-temperature#getTemp'/> 
    <input> 
      <soap:body use='encoded' namespace='urn:localhost-temperature' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </input> 
    <output> 
      <soap:body use='encoded' namespace='urn:localhost-temperature' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </output> 
  </operation> 
</binding> 
 
<service name='TemperatureService'> 
  <port name='TempPort' binding='TempBinding'> 
    <soap:address location='http://localhost/WebServices/SOAP_EXTENSION/Temperature/Server.php'/> 
  </port> 
</service>
</definitions>
 
 

I wonder if the problem is the array..
Thanks anyway!
Post Reply