服务器配置

扩展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的更多相关文章

  1. THINKPHP3.2 中使用 soap 连接webservice 解决方案

    今天使用THINKPHP3.2 框架中开发时使用soap连接webservice 一些浅见现在分享一下, 1.首先我们要在php.ini 中开启一下 php_openssl.dll php_soap. ...

  2. 【接口开发】浅谈 SOAP Webserver 与 Restful Webserver 区别

    接口,强大,简单,交互,跨越平台 下面简单阐述这两大接口思想 一 REST: REST是一种架构风格,其核心是面向资源,REST专门针对网络应用设计和开发方式,以降低开发的复杂性,提高系统的可伸缩性. ...

  3. salesforce 零基础学习(五十五)java通过SOAP方式定时访问某个文件然后插入到sObject中

    项目源码:https://github.com/zhangyueqidlmu/SOAP-Access-SFDC.git 项目背景:salesforce端相关数据需要其他系统提供,其他系统可以提供相关数 ...

  4. infopath发布的提示“无法解析SOAP消息”(The SOAP message cannot be parsed)问题解决方案

    最近发现一个列表数据过大,每次发布infopath表单提示如下错误: 后来发现一个infopath表单通过list.asmx and Formsservice.asmx来进行发布的. This err ...

  5. Rest webservice 和SOAP webservice

    SOAP: 简单对象访问协议(Simple Object Access Protocol,SOAP)是一种基于 XML 的协议,可以和现存的许多因特网协议和格式结合使用,包括超文本传输协议(HTTP) ...

  6. thinkphp3.2.3中U()方法和redirect()方法区别

    今天博主看3.1的教程,学着3.2,就遇到了这个坑,怎么就是不跳转呢,很纳闷!! 在thinkphp3.1 中 U()方法是可以执行跳转的(看视频教程里面是可以的,博主没有测试过). 但是在think ...

  7. thinkphp3.2.3版本文件目录及作用

    下载thinkphp3.2.3版本,解压缩后将文件夹名字改为thinkphp,然后放在www目录下,里面的文件夹和文件的名字和作用如下:(前面有Tab健的表示下一级,thinkphp是根目录) //t ...

  8. webservice客户端添加soap Header信息

    根据wsdl文件的header信息,在客户端中添加相应的header 1.wsdl信息如图 <soapenv:Envelope xmlns:soapenv="http://schema ...

  9. 推荐一篇 关于REST 和 SOAP区别的文章

    写的很出色! https://www.ibm.com/developerworks/cn/webservices/0907_rest_soap/ 我的感觉就是REST针对的是资源,通过api的URL就 ...

随机推荐

  1. 使用vscode 编译 sass

    由于我在工作中用的编辑器是 vscode ,所以记录一下vscode 编译sass 的配置 vs code 编译saass 1.在扩展里搜索“easy sass”,直接进行安装即可 2.安装后默认已经 ...

  2. soapUI系列之—-06 testrunner实现自动化测试

    TestRunner为soapUI自带------testrunner.bat/testrunner.sh 实现步骤: 1. 使用soapUI,针对接口文件创建测试用例. 2. 将测试用例保存至本地, ...

  3. 深度学习笔记之关于基本思想、浅层学习、Neural Network和训练过程(三)

    不多说,直接上干货! 五.Deep Learning的基本思想 假设我们有一个系统S,它有n层(S1,…Sn),它的输入是I,输出是O,形象地表示为: I =>S1=>S2=>….. ...

  4. Android之弹出多级菜单

    使用布局文件创建菜单:(多级菜单) 在res下创建目录menu(假设已经有啦就不用再创建了) 在该menu目录下创建XML文件这里我把文件名称命名为menu 在创建的menu.XML文件里 写入: & ...

  5. 【iOS系列】-单例模式的实现

    1:重写allocWithZone方法 allocWithZone方法是对象分配内存空间时, alloc方法最终会调用这个方法 + (id)allocWithZone:(struct _NSZone ...

  6. JS Debug

    任何一个编程者都少不了要去调试代码,不管你是高手还是菜鸟,调试程序都是一项必不可少的工作.一般来说调试程序是在编写代码之后或测试期修改Bug 时进行的,往往在调试代码期间更加能够体现出编程者的水平高低 ...

  7. gearcache在qemu-kvm虚拟化平台下的实现

    需要用到的数据结构: 链表,基树. gearcache在qemu-kvm虚拟化平台下的实现主要有以下的步骤: 1.打开镜像文件的时候,为gearcache中的基数池(page_node_pool)和读 ...

  8. request的Content-Type小结

    一.Content-Type定义 Content-Type MediaType,即是Internet Media Type,互联网媒体类型:也叫做MIME类型,在Http协议消息头中,使用Conten ...

  9. 黑客常用WinAPI函数整理

    之前的博客写了很多关于Windows编程的内容,在Windows环境下的黑客必须熟练掌握底层API编程.为了使读者对黑客常用的Windows API有个更全面的了解以及方便日后使用API方法的查询,特 ...

  10. 洛谷 P1311 选择客栈 —— 水题

    题目:https://www.luogu.org/problemnew/show/P1311 看每个位置能否成为咖啡店,然后作为客栈和前面配对即可. 代码如下: #include<iostrea ...