• curl:get,post 以及SoapClien访问webservice数据


    
    

    一。curl get模式

    public function close_order()
    {

    $url="http://192.168.2.50:7777/U8API.asmx?op=InsertSo=".$ordersn;
        $getinfo = $this->httpGet($url);
    return $getinfo;
    }
        public function httpGet($url) {
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_TIMEOUT, 500);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_URL, $url);
            $res = curl_exec($curl);
            curl_close($curl);
            return $res;
        }

    二。curl post模式

    public function insert_order()
    {
    $data['cSOCode']='20171105455555';//订单号
    $data['dDate']='2017-11-01'; //下单日期
    $data['cCusCode']='';//客户编码
    $data['Details']=array(
    array('cInvCode'=>'B03602','iQuantity'=>12,'iTaxUnitPrice'=>7000)
    );
    $string=json_encode($data);
    $getinfo = $this->httpPost($string);
    return $getinfo;
    }
        public function httpPost($data) {
            $postUrl = 'http://192.168.2.50:7777/U8API.asmx/InsertSo';
            $postData = array(
                'strJson'=>$data
            );
            $postData = http_build_query($postData);
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $postUrl);
            curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
            curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
            $r = curl_exec($curl);
            curl_close($curl);
            return $r;
        }

    三。SoapClient模式

    public function insert_order()
    {
    $data['cSOCode']='20171105455555';//订单号
    $data['dDate']='2017-11-01'; //下单日期
    $data['cCusCode']='';//客户编码
    $data['Details']=array(
    array('cInvCode'=>'B03602','iQuantity'=>12,'iTaxUnitPrice'=>7000)
    );
    $string=json_encode($data);
    $getinfo = $this->closeOrderToErp($string);
    return $getinfo;
    }
        public function closeOrderToErp($data)
        {
    
            $client = new SoapClient("http://erpapi.chengmei.com:7777/U8API.asmx?wsdl");
            $client->soap_defencoding = "utf-8";
            $client->decode_utf8 = false;
            $client->xml_encoding = "utf-8";
            $result = $client->__Call('UpdateSo', array(
                array(
                    'cCode' => $data
                )
            ));
            $list = (array)$result;
            return json_decode($list['UpdateSoResult'], true);
        }
     
  • 相关阅读:
    游标
    mobaxterm安装与使用(root_35/37/36/121)
    美团笔试--修改矩阵
    美团笔试1--螺旋矩阵
    assert函数
    2019年头条笔试--围坐分糖果
    邻值查找——stl函数lower_bound和upper_bound的使用
    动态规划练习1--腾讯暑期实习正式批
    Windows 7下硬盘安装CentOS6.4的解决方法
    Sublime Text 3 的一些基本使用方法和配置
  • 原文地址:https://www.cnblogs.com/houdj/p/7771926.html
Copyright © 2020-2023  润新知