服务器配置

扩展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. 游戏server设计的一些感悟

    Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csdn.net/chen19870707 Date:September 30 ...

  2. 现在企业流行的java框架技术

    我将简短分析被用于支持这些框架的企业开发环境或工具箱,例如Borland JBuilder,Eclipse以及BEA Workbench.请记住,市场上有许多有关这些开发框架的图书;然而,在任何一篇文 ...

  3. Oracle - 创建表视图等 - DDL

    解锁scott: sqlplus / as sysdba; alter user scott account unlock; alter user scott identified by tiger; ...

  4. ubuntu切换中英文通用方法,ubuntu中文语言

    1:点击桌面右上角的齿轮,选择“system settings”进入系统设置界面

  5. 什么是PMU(PMIC)【转】

    本文转载自:http://blog.csdn.net/zhenwenxian/article/details/7614537 什么是PMU(PMIC) PMU(power management uni ...

  6. MARGIN-BEFORE MARGIN-AFTER MARGIN-START MARGIN-END

    总的来说:这是CSS3.0的对于文章段P容器的定义方法语句!display:block这个样式,只定义了P容器为一个块;后面四句是CSS3中的样式定义方法:-webkit-margin-before: ...

  7. lucene DocValues——本质是为通过docID查找某field的值 看图

    Why DocValues? The standard way that Solr builds the index is with an inverted index. This style bui ...

  8. Ubuntu Bochs boot.asm 测试

    /********************************************************************* * Ubuntu Bochs boot.asm 测试 * ...

  9. 并不对劲的[USACO07NOV,洛谷p2886]Cow Relays

    题意就是给一张无向有边权的图.起点.终点,求起点到终点经过n条边的最短路.n<=10^6,点的编号<=10^3,边数<=10^2. 这个边数让人不由自主地想到了floyd,然后发现f ...

  10. BZOJ_3172_[Tjoi2013]单词_后缀自动机

    BZOJ_3172_[Tjoi2013]单词_后缀自动机 Description 某人读论文,一篇论文是由许多单词组成.但他发现一个单词会在论文中出现很多次,现在想知道每个单词分别在论文中出现多少次. ...