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就 ...
随机推荐
- Unity5.1 新的网络引擎UNET(八) UNET 系统概括
孙广东 2015.7.12 Server and Host 在Unity 的 网络系统,游戏有 一个server和多个client. 当没有专用的server时,client之中的一个扮演s ...
- vector draw 试用期结束的 激活方法
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\DBEA4D42-0745-428e-B17A-A5B6CA3AB34B] 把这个注冊表给删 了
- 2 AngularJS 1 概念浓缩
Angular Web APP 结构图: module --> 模块 :相当于一个容器,Angular里的所有东西都得放在模块里,才能够被引用和加载. directive --&g ...
- Java经常使用日期操作具体解释
Date类型大多数时间分量计算方法已经被Calendar代替 Date经常用法setTime getTime() new Date();默认获取当前的时间 SimpleDateFormat用来格式化和 ...
- 嵌入式开发之命令行---linux下的find文件查找命令与grep文件内容查找命令
在使用linux时,经常需要进行文件查找.其中查找的命令主要有find和grep.两个命令是有区的. 区别:(1)find命令是根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为空,访 ...
- 关于 iOS 的 StoryBoard,接受的那一刻才发现她的美 - 当然美的事物都须要业心照料
关于 iOS 的 StoryBoard,接受的那一刻才发现她的美 - 当然美的事物都须要业心照料 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循&quo ...
- Arch Linux 下Android 源代码的下载以及编译
之前把公司的开发环境由Ubuntu Kylin 换成了Arch Linux.而Arch 下由于种种问题公司的代码一直编只是去.搞定了之后也一直忘了写下来,希望能给相同在Arch 下做Android 开 ...
- Unity即将到来的2D工具
孙广东 2015.7.5 看了一下对功能介绍的视频,确实功能强大. 可是须要FQ在youtube上观看,所以就下载下来了.能够浏览一下: http://www.iqiyi.com/playlist2 ...
- Linux服务基础命令
---恢复内容开始--- 1简介: Linux的网络功能相当强悍,一时之间我们无法了解所有的文阿罗命令,在配置服务器基础环境时,先了解下网络参数设定命令. ifconfig 查询,设置网卡和i ...
- 不同节点 IP 时间同步 分布式时间同步系统的参考时间获取技术分析
linux linux下时间同步的两种方法分享_LINUX_操作系统_脚本之家 http://www.jb51.net/LINUXjishu/73979.html 分布式时间同步系统的参考时间获取技术 ...