WSDL Introduction
Web service description language (WSDL).
When programmers sit in front of the computer and want to use Web services, their tools (such as Visual Studio) cannot provide them with any help because these tools do not understand Web services at all.
The solution is:
Provide a formal description document in a machine-readable way. Web service description language (WSDL)
is such an XML-based language used to describe Web services and their functions, Parameters and return values. Because it is based on XML, WSDL is both machine-readable and human-readable.
This will be a great benefit. Some of the latest development tools can not only generate WSDL documents based on your Web service, but also import WSDL documents to generate code that calls the corresponding Web service.
This article mainly shares with you an interface code for PHP to call wsdl file type. It is very simple and practical. Friends who have related needs can use it directly.
The code is as follows:
<?php // 本类由系统自动生成,仅供测试用途 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 < 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/>'; } //获取接口所有方法及参数 // print_r($client->getfunctions()); // print_r($client->getTypes()); } } ?>
The above is the detailed content of PHP interface code example for calling wsdl file type. For more information, please follow other related articles on the PHP Chinese website!