如何使用 zend soap 生成 wsdl
我正在尝试使用 Zend 框架中的自动发现类生成 wsdl 文件。生成的定义似乎不可用,后续功能也不起作用。
下面是我正在使用的代码...
<?php
/**
* Returns Hello World as a string.
*
* @return string
*/
function hello( )
{
return "Hello World";
}
if( isset( $_GET['wsdl'] ) )
{
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->addFunction( 'hello' );
$autodiscover->handle();
}
else if( isset( $_GET['client'] ) )
{
$client = new Zend_Soap_Client( "http://localhost/service.php" );
echo $client->hello();
}
else
{
$server = new Zend_Soap_Server( "http://localhost/service.php?wsdl" );
$server->addFunction( 'hello' );
$server->handle();
}
?>
这一切都会默默地失败,调用 http://localhost/service .php?wsdl 只是默默地消亡并且不生成任何 WSDL 定义。有人可以告诉我我做错了什么吗:)
非常感谢
I'm trying to generate a wsdl file using the autodiscover class from the Zend framework. The resulting definition doesn't seem to become available and subsequent functionality doesn't work.
Below is the code that I'm using...
<?php
/**
* Returns Hello World as a string.
*
* @return string
*/
function hello( )
{
return "Hello World";
}
if( isset( $_GET['wsdl'] ) )
{
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->addFunction( 'hello' );
$autodiscover->handle();
}
else if( isset( $_GET['client'] ) )
{
$client = new Zend_Soap_Client( "http://localhost/service.php" );
echo $client->hello();
}
else
{
$server = new Zend_Soap_Server( "http://localhost/service.php?wsdl" );
$server->addFunction( 'hello' );
$server->handle();
}
?>
This all weems to fail silently, calling http://localhost/service.php?wsdl just dies silently and generates no WSDL definition. Could someone please give me an idea of what I'm doing wrong :)
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我尝试了您发布的代码,但我添加了:
require('Zend/Soap/AutoDiscover.php');
。它起作用了。I tried the code you posted, except that I added:
require('Zend/Soap/AutoDiscover.php');
. It worked.尝试将 docblocking 添加到 hello 函数。 WSDL 生成器依赖它来生成正确的 WSDL 文件。 http://framework.zend.com/manual/en/zend.soap .autodiscovery.html 请参阅该链接中的重要注释。
Try adding docblocking to the hello function. the WSDL generator relies on it to generate proper WSDL file. http://framework.zend.com/manual/en/zend.soap.autodiscovery.html See the important notes in that link.
是的,您缺少 require('Zend/Soap/AutoDiscover.php');就这样。
Yep, you are missing require('Zend/Soap/AutoDiscover.php'); that's all.