SoFunction
Updated on 2025-02-28

PHP calls wsdl file type interface code sharing


<?php
// This class is automatically generated by the system and is for testing purposes only
class IndexAction extends Action {
    public function index(){
//#Distribution order submission, modification, cancellation, query interface
         $wsdl1='http://127.0.0.1:8080/ejfxs/services/order?wsdl';
//#Distribution product interface address
        $wsdl='http://127.0.0.1:8080/ejfxs/services/availableProducts?wsdl';
//Instantiate the object
        $client=new SoapClient($wsdl);
//Interface parameters.
        $param1=array('password'=>'123456','dis_code'=>'fxBZZHLYW','checkcode'=>'FXFAXM5U1Y');
//Interface method.
        $ret1 = $client->getAvailableProducts($param1);
//Convert XML data to array
        $array=(array)$ret1;
//Convert to simplexml_load_string object
        $v=simplexml_load_string($array['return']);
//Array definition
        $Varr=$v->ybproducts->fzhproducts->product;
//Get specific value
        for ($i=0; $i < count($Varr); $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 '<br/>';
        }
//Get all methods and parameters of the interface
        // print_r($client->__getfunctions());
        // print_r($client->__getTypes());
    }
}
?>