Hi,
The invalid XML error is normal when you call the server through your browser.
Maybe you should generate a soap request to your server with a soap debugging tool like SoapUI. That program can read your WSDL and prepare a request, you just have to fill in optional request data.
From: Thaorius [mailto:thaorius@thaorius.com]
Sent: maandag 10 november 2008 15:55
To: fw-webservices@lists.zend.com
Subject: [fw-webservices] SOAP Service: Uncaught SoapFault exception: [Client] looks like we got no XML document
Hi, I've just signed up for the list due to an ugly error with Zend_Soap. I'm getting:
Uncaught SoapFault exception: [Client] looks like we got no XML document
I've read this error occurred when there are random characters before the <xml... on the output; this is not the case. Although there is a 0A(line feed) character at the end of the output.
Here is the involved controller, take a look:
[application/modules/api/controllers/RealmController.php]
<?php
class Api_RealmController extends Zend_Controller_Action
{
public function init()
{
// Disable layout
$this->_helper->layout()->disableLayout();
// Disable ViewRenderer plugin
$this->_helper->viewRenderer->setNoRender();
$this->getResponse()->clearBody();
}
public function serveAction()
{
// Instantiate SOAP server
$server = new Zend_Soap_Server('http://rhea.thaorius.net/nation/public/api/realm/wsdl');
// Set class
$server->setClass('Test_Soap');
// Handle SOAP request
$server->handle();
}
public function wsdlAction()
{
// Instantiate auto discover
$autodiscover = new Zend_Soap_AutoDiscover();
// Set class
$autodiscover->setClass('Test_Soap');
// Handle WSDL request
$autodiscover->handle()
}
}
class Test_Soap
{
/**
* This method takes 1 parameter and does shit with it.
*
* @param string $input
* @return integer
*/
public function testfunc($input)
{
return 12;
}
}
On the index,php, bootstrap.php and a plugin that is loaded on the bootloader, I use Zend's coding guidelines and have no line feed before any <?php tag and I don't use the ?> tag.
Now, if I query the WSDL directly, firefox will render it properly, like XML it is. Same with the serve action, but I'll get the following output:
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>0</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Also, I thought the 'Invalid XML' problem was due to direct calling and, there for, the lack of a SOAP request; so I wrote and small test client, which throws the error I'm getting, code:
<?php
$client = new SoapClient('http://rhea.thaorius.net/nation/public/api/realm/wsdl');
var_dump($client->testfunc("lalalala"));
Any ideas? I'm kinda desperate.
Thanks for your time
--
Thaorius
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.0/1778 - Release Date: 10/11/2008 7:53
没有评论:
发表评论