Home > php教程 > php手册 > PHP调用wsdl文件类型的接口代码分享,

PHP调用wsdl文件类型的接口代码分享,

WBOY
Release: 2016-06-13 09:20:49
Original
1065 people have browsed it

PHP调用wsdl文件类型的接口代码分享,

复制代码 代码如下:


// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
    public function index(){
        //#分销商订单提交、修改、取消、查询接口
         $wsdl1='http://127.0.0.1:8080/ejfxs/services/order?wsdl';
         //#分销商可销售产品接口地址
        $wsdl='http://127.0.0.1:8080/ejfxs/services/availableProducts?wsdl';
        //实例化对象
        $client=new SoapClient($wsdl);
        //接口参数。
        $param1=array('password'=>'123456','dis_code'=>'fxBZZHLYW','checkcode'=>'FXFAXM5U1Y');
        //接口方法。
        $ret1 = $client->getAvailableProducts($param1);
        //将XML数据转换成数组
        $array=(array)$ret1;
        //转换成simplexml_load_string对象
        $v=simplexml_load_string($array['return']);
        //数组定义
        $Varr=$v->ybproducts->fzhproducts->product;
        //获取到具体的值
        for ($i=0; $i             echo $Varr[$i]->prod_id;
            echo $Varr[$i]->product_name;
            echo $Varr[$i]->prod_code;
            echo $Varr[$i]->prod_category;
            echo $Varr[$i]->supply_id;
            echo $Varr[$i]->price;
            echo $Varr[$i]->parprice;
            echo $Varr[$i]->total_ticket_num;
            echo $Varr[$i]->inventory;
            echo $Varr[$i]->product_name;
            echo $Varr[$i]->product_name;
            echo '
';
        }
        //获取接口所有方法及参数
        // print_r($client->__getfunctions());
        // print_r($client->__getTypes());
    }
}
?>


=================================================================

大概就是这个样子!上面注释得比较清楚。不懂的留言。或者建议改进的。留言。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template