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

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());
    }
}
?>


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

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

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)