• PHP操作Webservice


    Function:

    //server:
    <?php
    $soap = new SoapServer(null,array('uri'=>"http://192.168.1.110/"));    //This uri is your SERVER ip.
    $soap->addFunction('minus_func');                                                 //Register the function
    $soap->addFunction(SOAP_FUNCTIONS_ALL);
    $soap->handle();
    
    function minus_func($par){
        return "Hello,".$par;
    }
    ?>
    
    //client:
    <?php
    try {
        $client = new SoapClient(null,
            array('location' =>"http://192.168.1.110/server.php",'uri' => "http://192.168.1.110/"));
        echo $client->minus_func('fangbaiyi');
    
    } catch (SoapFault $fault){
        echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
    }
    ?>

    Class:

    //server:
    <?php
        //$classExample=array();
        $soap=new SoapServer(null,array('uri'=>"http://192.168.1.110"));
        $soap->setClass('chClass');
        $soap->handle();
        
        class chClass
        {
            public $mes="Hello World!";
            function getName()
            {
                return $this->mes;
            }
        }
    ?>
    
    //client:
    <?php
    try{
        $client=new SoapClient(null,array('location'=>"http://192.168.1.110/server1.php",'uri'=>"http://192.168.1.110"));
        echo $client->getName();
    }catch(SoapFault $fault)
    {
        echo $fault;
    }
    ?>
  • 相关阅读:
    imac 截图

    [Python] 安装及环境配置
    冒泡算法
    [转载]分页+双向排序(jquery + ashx)
    【转载】jQuery最佳实践
    【转载】星级评分jQuery插件
    ie浏览器模式判断语句
    jQuery面向对象定制业务框架开发
    【转载】jQuery设计思想
  • 原文地址:https://www.cnblogs.com/zhaobijin/p/5813366.html
Copyright © 2020-2023  润新知