使用php从web服务构建中获取空响应
我想用php和zend框架创建一个web服务。 服务器端代码如下所示:使用php从web服务构建中获取空响应,php,web-services,zend-framework,soap,Php,Web Services,Zend Framework,Soap,我想用php和zend框架创建一个web服务。 服务器端代码如下所示: $server = new Zend_Soap_Server(null, array('uri' => $WSDL_URI)); csiService.php: <?php require_once 'Zend/Loader.php'; require_once 'CSI.php'; $WSDL_URI="http://csi.chemicalseeker.com/csiService.php?WSDL"; i
$server = new Zend_Soap_Server(null, array('uri' => $WSDL_URI));
csiService.php:
<?php
require_once 'Zend/Loader.php';
require_once 'CSI.php';
$WSDL_URI="http://csi.chemicalseeker.com/csiService.php?WSDL";
if(isset($_GET["WSDL"]))
{
Zend_Loader::loadClass('Zend_Soap_AutoDiscover');
Zend_Loader::loadClass('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$autodiscover->setBindingStyle(array('style' => 'document'));
$autodiscover->setOperationBodyStyle(array('use' => 'literal'));
$autodiscover->setClass('CSI');
$autodiscover->handle();
}
else
{
Zend_Loader::loadClass('Zend_Soap_Server');
$server = new Zend_Soap_Server($WSDL_URI);
$server->setClass('CSI');
$server->handle();
}
?>
我可以通过“$client->getFunctions()”和“$client->getTypes()”获取函数列表和类型列表,这意味着“CSI”类已成功连接到web服务。但结果无法正确返回
我还尝试了其他方法来调用web服务。我使用Flash Builder调用helloWorld()函数,服务器响应如下:
$server = new Zend_Soap_Server(null, array('uri' => $WSDL_URI));
正如我们所看到的,预期结果“Hello”也没有包含在SOAP信封中。
我的代码中是否遗漏了一些重要的内容或犯了一些错误?如果你有线索,请帮帮我。谢谢大家! 在进行测试时查看php错误日志 您还可以启用错误报告
E\u STRICT
或E\u NOTICE
以获取更多信息性错误提示:
您可以使用它进行更多的可扩展测试:我也在努力解决这个问题,但我通过切换到非WSDL模式解决了上面的问题 无论我尝试了什么,当尝试从我自己的自动发现生成的WSDL加载WSDL时,我总是收到与您相同的空响应。(感觉可能有一些递归问题,但我现在看不出有什么问题) 无论如何,切换到非WSDL模式给了我正确的响应 尝试按如下方式创建服务器:
很抱歉,这个答案太幸运了。Soap服务器似乎无法处理函数的返回。
<?php
require_once 'Zend/Loader.php';
require_once 'CSI.php';
Zend_Loader::loadClass('Zend_Soap_Client');
$WSDL_URI="http://csi.chemicalseeker.com/csiService.php?WSDL";
$client = new Zend_Soap_Client($WSDL_URI);
echo('<pre>');
var_dump($client->helloWorld());
echo('</pre>');
?>
object(stdClass)#3 (0) {
}
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://csi.chemicalseeker.com/csiService.php">
<SOAP-ENV:Body>
<ns1:helloWorldResponse/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
$server = new Zend_Soap_Server(null, array('uri' => $WSDL_URI));