PHP calls the interface code of the wsdl file type

Source: Internet
Author: User
Tags array definition
This article shares with you a PHP interface code for calling the wsdl file type. It is very simple and practical. You can use it directly if you have any requirements.

This article shares with you a PHP interface code for calling the wsdl file type. It is very simple and practical. You can use it directly if you have any requirements.

The Code is as follows:


<? Php
// This class is automatically generated by the system for testing purposes only
Class IndexAction extends Action {
Public function index (){
// # API for submitting, modifying, canceling, and querying distributor orders
$ Wsdl1 = 'HTTP: // 127.0.0.1: 8080/ejfxs/services/order? Wsdl ';
// # Contact address of the reseller's salable product
$ Wsdl = 'HTTP: // 127.0.0.1: 8080/ejfxs/services/availableProducts? Wsdl ';
// Instantiate the object
$ Client = new SoapClient ($ wsdl );
// Interface parameters.
$ Param1 = array ('Password' => '000000', 'dis _ Code' => 'fxbzzhlyw', 'checkcode' => 'fxfaxm5u1y ');
// Interface method.
$ Ret1 = $ client-> getAvailableProducts ($ param1 );
// Convert XML data into an array
$ Array = (array) $ ret1;
// Convert to simplexml_load_string object
$ V = simplexml_load_string ($ array ['Return ']);
// Array Definition
$ Varr = $ v-> ybproducts-> fzhproducts-> product;
// Obtain the 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'
';
}
// Obtain all methods and parameters of the interface
// Print_r ($ client->__ getfunctions ());
// Print_r ($ client->__ getTypes ());
}
}
?>


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

This is probably the case! The above annotations are clear. Leave a message if you do not understand it. Or we recommend that you improve it. Leave a message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.