`
endual
  • 浏览: 3511270 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

PHP5 soap web services

    博客分类:
  • html
阅读更多


一.开发环境:
  1 WAMPserver PHP5.3 + apache + mysql的集成环境
  2.Eclipse + PHP插件
  3。python2.5和PHP5语言版本
二:开发代码
  1.python 做一个服务端,发布为python web services.
 
代码如下:
import soaplib
import soaplib.core
from soaplib.core.service import rpc, DefinitionBase,soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array


class HelloWorldService(DefinitionBase):
    @soap(String,_returns=String)
    def say_hello(self,name):
        results = "hello,"+name;
        return results


if __name__=='__main__':
    try:
        from wsgiref.simple_server import make_server
        soap_application = soaplib.core.Application([HelloWorldService], 'tns')
        wsgi_application = wsgi.Application(soap_application)
        server = make_server('10.21.237.120', 8010, wsgi_application)
        print "8010........."
        server.serve_forever()
    except ImportError:
        print "Error: example server code requires Python >= 2.5"

WSDL地址:http://10.21.237.120:8010/server?wsdl

2.PHP5作为php 客户端调用python web services
代码如下:

<?php

header("content-type:text/html;charset=utf-8");

try {
    //$client = new SoapClient("HelloService.wsdl",array('encoding'=>'UTF-8'));
  $client = new SoapClient("http://10.21.237.120:8010/server?wsdl",array('encoding'=>'utf-8'));
//   var_dump($client->__getFunctions());
//   print("<br/>");
//   var_dump($client->__getTypes());
//   print("<br/>");  

  $parm1 = "KING";
          $param = array('name' => $parm1);
          $arr = $client->say_hello($param);
//   print_r($arr); 
  $ar = get_object_vars($arr);
  print("<br/>");
//   print_r($ar);
  print("<br/>");
  echo $ar["say_helloResult"];

} catch (SOAPFault $e) {

    print $e;
}
?>

三:soap环境的搭建

    这个比较烦恼的事情,WAMP集成了PHP5自带了soap扩展,所谓的扩展就是有soap 的功能!!
   python 端用的是soaplib,官方文档有点错误的,我的代码是根据官方代码修改了下!!
四:遇到问题怎么办
   你可以邮件给我或者QQ1019990976,技术分享,广交天下好朋友。
   我已经录制了视频。

分享到:
评论

相关推荐

    PHP SOAP实现Web Services 完整实例WSDL服务端+客户端

    PHP实现的Web Services 完整实例,WSDL交互。 PHP.INI,请开启php_soap。 服务端:直接解压到网站根目录下,访问地址:http://localhost/hbj/wsdl.php?wsdl 客户端:http://localhost/hbj/Client.php ,显示hello ...

    基于php的webservices的研究与应用.pdf

    web services 是 基 于XML、SOAP、WSDL、UDDI等 标 准 协 议 之 上 的 实 现 异 构 系 统 互 访 的 一 种 通 用 解 决 方 案。本 文 正 是 基 于 此 探 讨 了web services的 体 系 架 构 和 通 信 协 议 栈。最 后 ...

    PHP.Web.Services.APIs.for.the.Modern.Web.2nd.Edition

    PHP is ideally suited for both consuming and creating web services. You’ll learn how to use this language with JSON, XML, and other web service technologies. The second edition has been updated to ...

    php实现webservices接口

    php通过WSDL的方式实现webservices接口,需要在php.ini设置always_populate_raw_post_data=-1

    PHP Oracle Web Development: Data Processing, Security, Caching, XML, Web Services, and Ajax

    implement SOAP web services; build Ajax-driven PHP/Oracle solutions. Building and deploying PHP applications on Oracle Database combines the power and robustness of Oracle with the easy, rapid ...

    php-soap 扩展源文件

    PHP的SOAP扩展可以用来提供和使用Web services。换句话说,PHP开发者可以利用这个PHP扩展来写他们自己的Web services,也可以写一些客户端来使用给定的Web services。

    《PHP Web Services (English)》是一本关于使用 PHP 构建 Web 服务的书籍 在这本书中,你可以学习

    SOAP 服务: 讨论如何使用 PHP 创建和部署基于 SOAP 协议的 Web 服务,并介绍 SOAP 的工作原理和基本概念。 安全和身份验证: 探讨如何确保 Web 服务的安全性,包括身份验证、授权、加密等方面的技术和实践。 性能...

    用PHP编写增强的SOAP-Webservices

    有关如何使用自动WSDL生成功能编写增强PHP-SOAP-webservices的教程

    nusoap php webservices 类

    $client = new soapclient("http://www.flash-db.com/services/ws/companyInfo.wsdl","wsdl"); // The following is a mechanism for capturing the stock symbol we want // to lookup. You can change this ...

    soap-server:SOAP 1.1和1.2服务器的纯PHP实现

    goetas-webservices / soap-server PHP实现SOAP 1.1和1.2服务器规范。 优点: 纯PHP,不依赖ext-soap 可扩展(JMS事件侦听器支持) PSR-7 HTTP消息传递 PSR-15 HTTP服务器处理程序 无需在生产中解析WSDL / XSD ...

    amadeus-ws-client:PHP Amadeus SOAP Web服务客户端库

    amadeus-ws-client:Amadeus GDS SOAP Web服务接口PHP客户端 该客户端库提供对Amadeus GDS SOAP Web服务接口的访问。 要使用此客户端,您必须首先通过所选的Amadeus销售渠道获得对Web Service界面的个人访问权限。...

    PHP 中应用 SOAP例子

    里面是在PHP中怎么样用SOAP来做的WEB SERVICES 例子应用,很适用的。

    SOAP 1.1和1.2客户端规范PHP实现-PHP开发

    goetas-webservices / soap-client SOAP 1.1和1.2客户端规范PHP实现。 优点:纯PHP,不依赖于ext-soap可扩展(JMS事件侦听器支持)PSR-7 HTTP消息传递goetas-webservices / soap-client PHP实现SOAP 1.1和1.2客户端...

    全球最大的中文 Web 技术教程

    HTML HTML5 XHTML CSS CSS3 TCP/IP 浏览器脚本 JavaScript ...jQuery jQuery Mobile ...PHP ...Web Services Web Services WSDL SOAP RSS RDF .NET ASP.NET Web Pages Razor MVC Web Forms

    PHP Web 2.0 Mashup Projects.pdf

    Using PHP 5's SoapClient extension, we then interact with SOAP servers to grab data. We then finally create our mashup, which gathers web search results sourced from Microsoft Live and Yahoo! For ...

    最全面的 PHP webservice 接口,服务器端,客户端接口

    WebService是一种跨编程语言和跨操作系统平台的远程调用技术。仅仅有通过Web Service,client和server才可以自由的用HTTP进行通信...XML、SOAP和WSDL是Web Service平台的三大技术: WebService採用HTTP协议数据传输。

    www.w3school.com.cn

    HTML/CSS(HTML/XHTML/HTML 5/CSS/CSS3/TCP/IP)、 ...Web Services(Web Services/WSDL/SOAP/RSS/RDF)、 Web Building(网站构建/万维网联盟/浏览器信息/网站品质/语义网/职业规划/网站主机/网络媒体)

    w3cschool菜鸟教程离线版chm手册 2016

    w3cschool菜鸟教程离线版目录: ...学习 HTML5 学习 CSS 学习 CSS3 学习 Bootstrap ASP.NET 学习 ASP.NET 学习 C# 学习 Web Pages ...学习 Web Forms ...学习 Web Services 学习 WSDL 学习 SOAP 学习 RSS 学习 RDF

    w3school web编程教程

    Web Services 浏览器脚本 JavaScript HTML DOM DHTML VBScript AJAX E4X WMLScript 服务器脚本 SQL ASP ADO PHP .NET(dotnet) .NET Microsoft .NET ASP .NET Mobile 多媒体 Media SMIL SVG 建站...

    w3school.com.cn整站下载 领先的 Web 技术教程 离线学习

    Web Services 浏览器脚本 JavaScript HTML DOM jQuery AJAX JSON DHTML VBScript E4X WMLScript 服务器脚本 SQL ASP ADO PHP .NET(dotnet) .NET Microsoft .NET ASP .NET Mobile 多媒体 Media SMIL SVG

Global site tag (gtag.js) - Google Analytics