Uncaught SoapFault exception: [Client] looks like we got no XML document
| From: | Noe Rocha | Date: | Mon, 06 Nov 2006 17:06:27 +0000 |
| Subject: | Uncaught SoapFault exception: [Client] looks like we got no XML document | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-2384@lists.php.net to get a copy of this message | ||
Hi all.
I was trying to do a simple example and got the above error, even if the
Response looks good for me.
Here is what i have done:
types.php:
<?php
class Book
{
/** @var string Name */
public $b_title;
/** @var string Author */
public $b_author;
/** @var string isdn */
public $b_isdn;
function __construct($t, $a, $i)
{
$this->b_title = $t;
$this->b_author = $a;
$this->b_isdn = $i;
}
}
class ArrayOfBook
{
/** @var Book[] Result set */
public $Book;
function __construct($b)
{
$this->Book = $b;
}
function getBook()
{
return $this->Book;
}
}
?>
services.php
<?php
include "types.php";
class Services
{
/**
* Return list of Persons
*
* @return Book[] Result set
*/
function getBooks()
{
$books[] = new Book("B1", "Author1", "ISDN1");
$books[] = new Book("B2", "Author2", "ISDN2");
$books[] = new Book("B3", "Author3", "ISDN3");
return $books;
}
}
?>
endpoint.php:
<?php
include "services.php";
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("ServiceBooks.wsdl", array('actor' =>
'urn:ServiceBooks'));
$server->setClass("Services", "getBooks");
$server->handle();
exit;
?>
client.php:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
class MySoapClient extends SoapClient {
public function __doRequest($request, $location, $action, $version)
{
$dom = DOMDocument::loadXML($request);
$dom->formatOutput = true;
echo $dom->saveXML(); // if not using cli: echo <pre> and
htmlentities()
$result = parent::__doRequest($request, $location, $action,
$version);
echo '<pre>result: ', htmlspecialchars($result),
"<pre/>\n";
// no cli -> <pre>, htmlentities
//echo '<pre>result: ', $result, "\n"; // no cli ->
<pre>,
htmlentities
return $result;
}
}
$client = new MySoapClient("ServiceBooks.wsdl", array('trace' => 1));
$client->getBooks();
echo "Request :<br>", htmlspecialchars($client->__getLastRequest()),
"<br>";
echo "Response :<br>", htmlspecialchars($client->__getLastResponse()),
"<br>";
//$result = $client->getBooks();
//echo "<pre>";
//echo htmlentities($result);
//echo "</pre>";
?>
WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="ServiceBooks" targetNamespace="urn:ServiceBooks"
xmlns:tns="urn:ServiceBooks" xmlns:impl="urn:ServiceBooks"
xmlns:xsd1="urn:ServiceBooks" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types xmlns="http://schemas.xmlsoap.org/wsdl/">
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:ServiceBooks">
<!--<complexType name="ArrayOfBook">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
wsdl:arrayType="tns:Book[]"/>
</restriction>
</complexContent>
</complexType>-->
<complexType name="ArrayOfBook">
<sequence>
<element name="Book" type="tns:Book" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="Book">
<sequence>
<element name="b_title" type="xsd:string"/>
<element name="b_author" type="xsd:string"/>
<element name="b_isdn" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</types>
<portType name="ServiceBooksPortType">
<operation name="getBooks">
<input message="tns:GetBooksRequest"/>
<output message="tns:GetBooksResponse"/>
</operation>
</portType>
<binding name="ServiceBooksBinding" type="tns:ServiceBooksPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getBooks">
<soap:operation
soapAction="urn:ServiceBooks#ServiceBooksServer#getBooks"/>
<input>
<soap:body use="encoded" namespace="urn:ServiceBooks"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body parts="return" use="encoded"
namespace="urn:ServiceBooks"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<message name="GetBooksRequest"/>
<message name="GetBooksResponse">
<part name="return" type="tns:ArrayOfBook"/>
</message>
<service name="ServiceBooksService">
<port name="ServiceBooksPort" binding="tns:ServiceBooksBinding">
<soap:address location="http://localhost/interacesso/endpoint2.php"/>
</port>
</service>
</definitions>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:ServiceBooks"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:getBooksResponse>
<return xsi:type="ns1:ArrayOfBook">
<Book xsi:type="ns1:Book">
<b_title xsi:type="xsd:string">B1</b_title>
<b_author xsi:type="xsd:string">Author1</b_author>
<b_isdn xsi:type="xsd:string">ISDN1</b_isdn>
</Book>
<Book xsi:type="ns1:Book">
<b_title xsi:type="xsd:string">B2</b_title>
<b_author xsi:type="xsd:string">Author2</b_author>
<b_isdn xsi:type="xsd:string">ISDN2</b_isdn>
</Book>
<Book xsi:type="ns1:Book">
<b_title xsi:type="xsd:string">B3</b_title>
<b_author xsi:type="xsd:string">Author3</b_author>
<b_isdn xsi:type="xsd:string">ISDN3</b_isdn>
</Book>
</return>
</ns1:getBooksResponse>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
Can someone help me what i'm missing here?
I'll post a rar with the files too.
http://www.nabble.com/file/3991/example.rar
example.rar
Thanks.
--
View this message in context: http://www.nabble.com/Uncaught-SoapFault-exception%3A--Client--looks-like-we-got-no-XML-document-tf2583660.html#a7202680
Sent from the Php - Soap mailing list archive at Nabble.com.