zend framework 提供的webservices

xjwchy 2012-01-10 09:53:18
谁有这样的完整的例子。用到Zend_Soap_Server 等zend framework提供的soap扩展的。
想学一下,哪位大侠给提供一些资料,例子的更好啊。最好是那种能运行的简单小例子,谢谢啦
...全文
153 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xjwchy 2012-01-30
  • 打赏
  • 举报
回复
谢谢各位
xjwchy 2012-01-11
  • 打赏
  • 举报
回复
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Bad Request in E:\server_new\weborb\services\etim\ZF\soap\MyClient.php:8 Stack trace: #0 [internal function]: SoapClient->__call('Add', Array) #1 E:\server_new\weborb\services\etim\ZF\soap\MyClient.php(8): SoapClient->Add(1, 2) #2 {main} thrown in E:\server_new\weborb\services\etim\ZF\soap\MyClient.php on line 8

这是全部的错误信息
请高手帮忙啊
xjwchy 2012-01-11
  • 打赏
  • 举报
回复
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Bad Request in
引起这个问题是什么原因呢?

客户端
<?php
try{
$soap = new SoapClient(null,array(
"location" => "http://localhost:8666/weborb/services/etim/ZF/soap/MyServer.php",
"uri" => "abcd", //资源描述符服务器和客户端必须对应
));

echo $soap->Add(1,2);
}catch(Exction $e){
echo print_r($e->getMessage().'---',true);
}
?>

服务端
<?php
class service
{
public function HelloWorld()
{
return "Hello";
}
public function Add($a,$b)
{
return $a+$b;
}
}
file_put_contents("c:/log.txt",$HTTP_RAW_POST_DATA);
$server=new SoapServer(null,array('uri' => "abcd"));
$server->setClass("service");
$server->handle($HTTP_RAW_POST_DATA);
?>
ihelloworld 2012-01-10
  • 打赏
  • 举报
回复
application/controllers/WebServiceController.php

<?php
class WebServiceController extends Zend_Controller_Action {
public function init() {
$this->_helper->viewRenderer->setNoRender();
}

public function indexAction() {
if (isset($_GET['wsdl'])) {
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('Service_Helloworld');
$autodiscover->handle();
} else {
$soap = new Zend_Soap_Server("http://zf-demo.localhost/WebService/index/?wsdl");
$soap->setClass('Service_Helloworld');
$soap->handle();
}
}

public function testAction() {
$params = array(
'name' => 'tom'
);

$client = new SoapClient("http://zf-demo.localhost/WebService/index/?wsdl", array('trace' => 1));
echo $client->__soapCall('sayHello', $params);
}

}


application/services/Helloworld.php

<?php
class Service_Helloworld {
/**
* say hello
* @param string $name
* @return string
*/
public function sayHello($name) {
return 'hello ' . $name;
}
}



请将http://zf-demo.localhost改为你自己的域名
LAMP_WAMP 2012-01-10
  • 打赏
  • 举报
回复
zend framework 英文版的用不习惯,不知道有没有汉化的,在此之前,我一直用的是EclipsePHP Studio ,还可以!!
ihelloworld 2012-01-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xjwchy 的回复:]

高手们 还有吗?
[/Quote]
1楼的不行吗?符合你要求啊,简单的小例子.
xjwchy 2012-01-10
  • 打赏
  • 举报
回复
高手们 还有吗?

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧