thinkphp3.2 + soap
服务器配置
扩展libxml2下载地址:http://xmlsoft.org/downloads.html
在windows下的php.ini文件里
找到这一行代码(如没有则自行添加)
extension=php_soap.dll
SOAP在php.ini中还有自己的配置部分,如下所示
[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400
这段配置控制了SOAP扩展的WSDL缓存特性。默认情况下,WSDL描述文件在24小时(86400sec)内都在缓存设置的目录下。
另外还需要修改一下代码段,将always_populate_raw_post_data设置为On,并去掉分号,表示允许去的没经格式化的POST数据。
; Always populate the $HTTP_RAW_POST_DATA variable.
always_populate_raw_post_data = On
然后找到如下代码,设置为0
soap.wsdl_cache_enabled=0
这样,在代码调试时,避免遇到一些莫名其妙的错误,完成web服务开发之后,要记得改为1,即打开WSDL缓存,使代码运行得更快。
为了证明你成功配置好SOAP,请使用phpinfo()函数确认下:

无WSDL
/* 官网用户注册 判断是否已存在 */
public function isUsername($username){
$User = new UserApi();
$result = $User->checkUsername($username);
if($result >=0){
$data['status'] = true;
}else{
$data['status'] = false;
}
return json_encode($data);
exit;
}
服务器端:
public function passportServer(){
try{
$server = new \SoapServer(null,array("uri"=>"http://www.6ycom.com/soap/","location"=>"http://http://www.6ycom.com/soap/passportServer"));
//$server -> addFunction(array('a', 'b'));
$server->setClass(get_class($this));
$server -> handle();
}catch(SoapFault $e){
echo $e->getMessage();
}
}
客户端:
public function passportClient(){
$client = new \SoapClient(null,array("uri"=>"http://www.6ycom.com/soap/","location"=>"http://http://www.6ycom.com/soap/passportServer","trace" => 1));
$param = ['tongtong'];
echo $result=$client->__soapCall('isUsername',$param);
}
WSDL形式:
调用生成wsdl类:SoapDiscovery.class.php
服务器端:
<?php
class MyClass {
public function isExistUser($param) {
$count = M('ucenter_member')->where($map)->count();
return $count.$param;
}
}
require_once 'SoapDiscovery.class.php';
try {
$disco = new SoapDiscovery('MyClass','MyClass');
header("Content-type: text/html; charset=utf-8");
$disco->getWSDL();
$server = new SOAPServer('MyClass.wsdl', array('soap_version' => SOAP_1_2));
$server->setClass('MyClass');
$server->handle();
}
catch (SOAPFault $f) {
print $f->faultstring;
}
客服端:
<?php
//$client = new SoapClient(null, array('location' => "http://localhost/server.php",'uri' => "http://localhost/server.php"));
$client = new SoapClient("http://localhost:8082/Webservice/server.php?wsdl");
$param = ['33666fsdfdrewre666663'];
echo $return = $client->__soapCall("isExistUser",$param);
thinkphp3.2 + soap的更多相关文章
- THINKPHP3.2 中使用 soap 连接webservice 解决方案
今天使用THINKPHP3.2 框架中开发时使用soap连接webservice 一些浅见现在分享一下, 1.首先我们要在php.ini 中开启一下 php_openssl.dll php_soap. ...
- 【接口开发】浅谈 SOAP Webserver 与 Restful Webserver 区别
接口,强大,简单,交互,跨越平台 下面简单阐述这两大接口思想 一 REST: REST是一种架构风格,其核心是面向资源,REST专门针对网络应用设计和开发方式,以降低开发的复杂性,提高系统的可伸缩性. ...
- salesforce 零基础学习(五十五)java通过SOAP方式定时访问某个文件然后插入到sObject中
项目源码:https://github.com/zhangyueqidlmu/SOAP-Access-SFDC.git 项目背景:salesforce端相关数据需要其他系统提供,其他系统可以提供相关数 ...
- infopath发布的提示“无法解析SOAP消息”(The SOAP message cannot be parsed)问题解决方案
最近发现一个列表数据过大,每次发布infopath表单提示如下错误: 后来发现一个infopath表单通过list.asmx and Formsservice.asmx来进行发布的. This err ...
- Rest webservice 和SOAP webservice
SOAP: 简单对象访问协议(Simple Object Access Protocol,SOAP)是一种基于 XML 的协议,可以和现存的许多因特网协议和格式结合使用,包括超文本传输协议(HTTP) ...
- thinkphp3.2.3中U()方法和redirect()方法区别
今天博主看3.1的教程,学着3.2,就遇到了这个坑,怎么就是不跳转呢,很纳闷!! 在thinkphp3.1 中 U()方法是可以执行跳转的(看视频教程里面是可以的,博主没有测试过). 但是在think ...
- thinkphp3.2.3版本文件目录及作用
下载thinkphp3.2.3版本,解压缩后将文件夹名字改为thinkphp,然后放在www目录下,里面的文件夹和文件的名字和作用如下:(前面有Tab健的表示下一级,thinkphp是根目录) //t ...
- webservice客户端添加soap Header信息
根据wsdl文件的header信息,在客户端中添加相应的header 1.wsdl信息如图 <soapenv:Envelope xmlns:soapenv="http://schema ...
- 推荐一篇 关于REST 和 SOAP区别的文章
写的很出色! https://www.ibm.com/developerworks/cn/webservices/0907_rest_soap/ 我的感觉就是REST针对的是资源,通过api的URL就 ...
随机推荐
- 常用近百个js代码汇总
//檢查空串 function isEmpty(str){ )) return (true); else return(false); } //檢查是否未數字 function isDigit(the ...
- vue 配置跨域访问
主要在config->index.js中配置 proxyTable: { ‘/gameapi’: { changeOrigin: true, // target: ‘http://rap.id. ...
- ARGB,RGB颜色值表示
转载请注明出处:http://blog.csdn.net/wei_chong_chong/article/details/50831493 今天自己定义一个控件.设置背景颜色时犯难了 如今就来总结一下 ...
- asp.net mvc 中使用单例
有这样一个service,需要运行的asp.net站点上,但要保证这个实例是唯一的.单例用来启用聊天机器人,保证唯一,以免启动多个,造成客户端发送消息的时候,会造成每个机器人都发送消息,app收到多条 ...
- ASP.NET MVC 提供与访问 Web Api
ASP.NET MVC 提供与访问 Web Api 一.提供一个 Web Api 新建一个项目,类型就选 "Web Api".我用的是MVC5,结果生成的项目一大堆东西,还编译不过 ...
- java8--IO工具类(java疯狂讲义3复习笔记)
Paths类 public static void pathTest(){ Path path = Paths.get("~"); System.out.println(path) ...
- caution
做好需求更改的准备,提高代码的扩展性和可维护性:预留出修改bug和需求的时间:对需求理解透彻再开始写代码:代码不要写死,防止需求变动.
- sqlyog快捷键
Ctrl+M 创建一个新的连接Ctrl+N 使用当前设置新建连接Ctrl+F4 断开当前连接 对象浏览器F5 刷新对象浏览器(默认)Ctrl+B 设置焦点于对象浏览器 SQL 窗口 ...
- YTU 2954: A改错题--是虫还是草
2954: A改错题--是虫还是草 时间限制: 1 Sec 内存限制: 128 MB 提交: 83 解决: 55 题目描述 冬虫夏草为虫体与菌座相连而成,冬天是虫子,夏天却是草.根据类生物(bio ...
- 从free到page cache
Free 我们经常用free查看服务器的内存使用情况,而free中的输出却有些让人困惑,如下: 图1-1 先看看各个数字的意义以及如何计算得到: free命令输出的第二行(Mem):这行分别显示了 ...