zend framework 提供的webservices

xjwchy 2012-01-10 09:53:18
谁有这样的完整的例子。用到Zend_Soap_Server 等zend framework提供的soap扩展的。
想学一下,哪位大侠给提供一些资料,例子的更好啊。最好是那种能运行的简单小例子,谢谢啦
...全文
157 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
  • 打赏
  • 举报
回复
高手们 还有吗?
Book Description Overview Create powerful web applications by leveraging the power of this Model-View-Controller-based framework Learn by doing; create a social network from design to deployment Written in a framework and the API-centric approach to simplify the process of learning In Detail Zend Framework 2 has a flexible architecture that lets us build modern web applications and web services easily. It also provides an easy-to-use, high quality component library that is designed to be used the way you want. It’s easy to get started and produce a powerful and professional looking website with Zend Framework 2 Application Development. Exploring real life applications, we will explore the Zend Framework 2 components, as well as throwing some light on best practices and design concerns faced when building complex MVC applications. Zend Framework 2 Application Development is a hands-on guide to building your application. We will explore the components of this new version of the framework and discover how to use each component, the options available, and how to get the most from each component. Whilst learning everything you need to know, we’ll even create our own social network. We will also learn to engineer an application using an API-centric approach, broadly used today to build applications that work seamlessly on desktops, mobiles and tablets. We will learn how to filter and validate data, interact with databases to retrieve and store data, handle and manipulate file uploads, interact with other websites, deal with spam, and also protect your APIs using OAuth authentication whilst allowing people from all over the world to interact with your application. Zend Framework 2 Application Development is your guide to everything you need to know to build applications of any size for big and small companies alike, whilst using the right components for the job. What you will learn from this book Get to grips with the features of Zend Framework 2’s MVC architecture Filter and validate data no matter what the content is Handle and manage file uploads Gather content from other websites Fight spam with services such as Akismet Pull content from RSS feeds Quickly build forms such as login, register, and so on. Protect your API layer by using authentication protocols such as OAuth Manage database operations Build web services using the latest controller types Approach Every concept is put into practice with clear, step-by-step instructions and a hands-on approach. Forget about hundreds of pages full of theory; learn everything by example with Zend Framework 2 Application Development. Who this book is written for Written for PHP developers who want to get started with Zend Framework 2. Whether you are learning Zend framework from scratch or looking to sharpen up your skills from previous versions, Zend Framework 2 Application Development will help you to harness the power of Zend to produce better and more powerful applications. Basic knowledge of object-oriented design will be helpful. Table of Contents Chapter 1: Let’s Build a Social Network Chapter 2: Setting Up the Environment Chapter 3: Scratching the Surface of Zend Framework 2 Chapter 4: The First Request/Response – Building the User Wall Chapter 5: Handling Text Content – Posting Text Chapter 6: Working with Images – Publishing Pictures Chapter 7: Dealing with URLs – Posting Links Chapter 8: Dealing with Spam – Akismet to the Rescue Chapter 9: Let’s Read Feeds – A News Reader Chapter 10: Sign Up Chapter 11: Log in Chapter 12: Sending E-mails Chapter 13: OAuth 2.0 Protocol Securing our API Book Details Title: Zend Framework 2 Application Development Author: Christopher Valles Length: 298 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2013-10-25 ISBN-10: 1782162100 ISBN-13: 9781782162100

4,250

社区成员

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

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