The feature that'll blow your mind and your developer!

  04 décembre 2013       Cet article a 0 commentaire       De Mikaël DELSOL

We are pretty excited by the new feature we are now providing. We think this feature will be one of the most useful. Indeed, the first one was the package generation (yeah, it's the oldest). The second one was the Soap client web interface that allows you to call any SOAP Web service without having to write even one line of code.

Here is the new feature: execute a request from the web interface and get auto-generated files that contain the XML request, the XML response, the whole required PHP code to make the request and finally the PHP response usable code. All these files are generated dynamically. They stand for the request you just executed and the response you've got. They are downloadable one by one.

First case: the simpliest one

We have a SOAP Web service that allows to login and get an unique identifier corresponding to the opened session.

After calling the operation using the web interface, here is the result:

Simple case links execute and download - WSDL to php

As you can see, the icon Download a file - WSDL to php is displayed for each part that can be downloaded. Each file contains the content of the part the icon is attached to.

The XML request file then contains what you see:

<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapi.ovh.com/manager"> <SOAP-ENV:Body> <ns1:login> <ns1:nic>*******</ns1:nic> <ns1:password>*******</ns1:password> <ns1:language>fr</ns1:language> <ns1:multisession>true</ns1:multisession> </ns1:login> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

The PHP request file contains all the code you need to execute the exact same request you just sent using the web interface:

<?php /** * This file has been auto-generated at 2013-12-05 00:10:24 from https://www.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1932. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/OvhAutoload.php'; /** * This array contains the required parameters to initialize the class that makes the SOAP call. */ $wsdl = array(); $wsdl[OvhServiceLogin::WSDL_URL] = 'http://www.ovh.com/soapi/soapi-dlw-1.61.wsdl'; /** * Instanciates the object that will make the call. */ $caller = new OvhServiceLogin($wsdl); /** * This array contains the parameters as defined by the call you made. */ $parameters = array ( 0 => OvhStructLogin::__set_state(array( 'nic' => '*******', 'password' => '*******', 'language' => 'fr', 'multisession' => '1', 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), ); /** * Makes the call and get the result as the $result variable. */ $result = call_user_func_array(array($caller,'login'),$parameters); /** * Here are some methods that you can call to get things about the request and the response. */ $xmlRequestString = $caller->getLastRequest(); $xmlRequestDOMDocument = $caller->getLastRequest(true); $xmlResponseString = $caller->getLastResponse(); $xmlResponseDOMDocument = $caller->getLastResponse(true); /** * Handles the result depending on its value. */ if($result) { // request has been executed successfully, handle $result } else { // request has been executed unsuccessfully, handle (SoapFault) $soapFault $soapFault = $caller->getLastErrorForMethod($caller->__toString() . '::login'); } ?>

The XML response file contains:

<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:typens="http://soapi.ovh.com/manager" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Body> <loginResponse xmlns="http://soapi.ovh.com/manager"> <return xsi:type="xsd:string">*******-ovh-8fa17a163a*******f6dba94</return> </loginResponse> </soap:Body> </soap:Envelope>

The PHP response file contains the PHP code that sets a variable with the response:

<?php /** * This file has been auto-generated at 2013-12-05 00:11:54 from https://wwww.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1932. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/OvhAutoload.php'; $response = OvhStructLoginResponse::__set_state(array( 'return' => '*******-ovh-8fa17a163a*******f6dba94', 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )); ?>

As it is said, you first have to download the package at the URL indicated in the comment. The PHP files are usable as they are and can be modified at your own risks ;).

Second case: a more complex request with HTTP headers

Let's call the eBay Shopping SOAP Web service. To do so, you have to set HTTP headers to be recognized correctly by the system. We have already explained how to do it using the web interface in order to get the eBay category info. As for the previous case, the icon Download a file - WSDL to php is available for each part of the requests and responses. What we want to show you is the generated PHP request and response files.

The PHP request file contains all you need to correctly set the HTTP headers as required:

<?php /** * This file has been auto-generated at 2013-12-05 00:29:00 from https://www.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1933. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/EbayShoppingAutoload.php'; /** * This array contains the required parameters to initialize the class that makes the SOAP call. */ $wsdl = array(); $wsdl[EbayShoppingServiceGet::WSDL_URL] = 'http://developer.ebay.com/webservices/latest/ShoppingService.wsdl'; /** * Instanciates the object that will make the call. */ $caller = new EbayShoppingServiceGet($wsdl); /** * Sets required HTTP Headers. */ $caller->setHttpHeader('X-EBAY-API-APP-ID','******-****-****-****-************'); $caller->setHttpHeader('X-EBAY-API-CALL-NAME','getCategoryInfo'); $caller->setHttpHeader('X-EBAY-API-VERSION','825'); /** * This array contains the parameters as defined by the call you made. */ $parameters = array ( 0 => EbayShoppingStructGetCategoryInfoRequestType::__set_state(array( 'CategoryID' => '1', 'IncludeSelector' => 'ChildCategories', 'MessageID' => 'MY_MESSAGE_ID', 'any' => '', 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), ); /** * Makes the call and get the result as the $result variable. */ $result = call_user_func_array(array($caller,'GetCategoryInfo'),$parameters); /** * Here are some methods that you can call to get things about the request and the response. */ $xmlRequestString = $caller->getLastRequest(); $xmlRequestDOMDocument = $caller->getLastRequest(true); $xmlResponseString = $caller->getLastResponse(); $xmlResponseDOMDocument = $caller->getLastResponse(true); /** * Handles the result depending on its value. */ if($result) { // request has been executed successfully, handle $result } else { // request has been executed unsuccessfully, handle (SoapFault) $soapFault $soapFault = $caller->getLastErrorForMethod($caller->__toString() . '::GetCategoryInfo'); } ?>

The PHP response file contains all the data that can be used in you code as the $response variable:

<?php /** * This file has been auto-generated at 2013-12-05 00:31:31 from https://www.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1933. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/EbayShoppingAutoload.php'; $response = EbayShoppingStructGetCategoryInfoResponseType::__set_state(array( 'CategoryArray' => EbayShoppingStructCategoryArrayType::__set_state(array( 'Category' => array ( 0 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1', 'CategoryLevel' => 1, 'CategoryName' => 'Collectibles', 'CategoryParentID' => '-1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles', 'CategoryIDPath' => '1', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 1 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '34', 'CategoryLevel' => 2, 'CategoryName' => 'Advertising', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Advertising', 'CategoryIDPath' => '1:34', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 2 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1335', 'CategoryLevel' => 2, 'CategoryName' => 'Animals', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Animals', 'CategoryIDPath' => '1:1335', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 3 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13658', 'CategoryLevel' => 2, 'CategoryName' => 'Animation Art & Characters', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Animation Art & Characters', 'CategoryIDPath' => '1:13658', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 4 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '66502', 'CategoryLevel' => 2, 'CategoryName' => 'Arcade, Jukeboxes & Pinball', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Arcade, Jukeboxes & Pinball', 'CategoryIDPath' => '1:66502', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 5 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '14429', 'CategoryLevel' => 2, 'CategoryName' => 'Autographs', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Autographs', 'CategoryIDPath' => '1:14429', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 6 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '66503', 'CategoryLevel' => 2, 'CategoryName' => 'Banks, Registers & Vending', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Banks, Registers & Vending', 'CategoryIDPath' => '1:66503', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 7 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '3265', 'CategoryLevel' => 2, 'CategoryName' => 'Barware', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Barware', 'CategoryIDPath' => '1:3265', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 8 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '156277', 'CategoryLevel' => 2, 'CategoryName' => 'Beads', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Beads', 'CategoryIDPath' => '1:156277', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 9 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '29797', 'CategoryLevel' => 2, 'CategoryName' => 'Bottles & Insulators', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Bottles & Insulators', 'CategoryIDPath' => '1:29797', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 10 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '562', 'CategoryLevel' => 2, 'CategoryName' => 'Breweriana, Beer', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Breweriana, Beer', 'CategoryIDPath' => '1:562', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 11 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '898', 'CategoryLevel' => 2, 'CategoryName' => 'Casino', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Casino', 'CategoryIDPath' => '1:898', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 12 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '397', 'CategoryLevel' => 2, 'CategoryName' => 'Clocks', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Clocks', 'CategoryIDPath' => '1:397', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 13 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '63', 'CategoryLevel' => 2, 'CategoryName' => 'Comics', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Comics', 'CategoryIDPath' => '1:63', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 14 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '3913', 'CategoryLevel' => 2, 'CategoryName' => 'Cultures & Ethnicities', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Cultures & Ethnicities', 'CategoryIDPath' => '1:3913', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 15 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13777', 'CategoryLevel' => 2, 'CategoryName' => 'Decorative Collectibles', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Decorative Collectibles', 'CategoryIDPath' => '1:13777', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 16 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '137', 'CategoryLevel' => 2, 'CategoryName' => 'Disneyana', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Disneyana', 'CategoryIDPath' => '1:137', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 17 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '10860', 'CategoryLevel' => 2, 'CategoryName' => 'Fantasy, Mythical & Magic', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Fantasy, Mythical & Magic', 'CategoryIDPath' => '1:10860', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 18 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13877', 'CategoryLevel' => 2, 'CategoryName' => 'Historical Memorabilia', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Historical Memorabilia', 'CategoryIDPath' => '1:13877', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 19 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '907', 'CategoryLevel' => 2, 'CategoryName' => 'Holiday & Seasonal', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Holiday & Seasonal', 'CategoryIDPath' => '1:907', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 20 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13905', 'CategoryLevel' => 2, 'CategoryName' => 'Kitchen & Home', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Kitchen & Home', 'CategoryIDPath' => '1:13905', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 21 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1401', 'CategoryLevel' => 2, 'CategoryName' => 'Knives, Swords & Blades', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Knives, Swords & Blades', 'CategoryIDPath' => '1:1401', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 22 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1404', 'CategoryLevel' => 2, 'CategoryName' => 'Lamps, Lighting', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Lamps, Lighting', 'CategoryIDPath' => '1:1404', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 23 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '940', 'CategoryLevel' => 2, 'CategoryName' => 'Linens & Textiles (1930-Now)', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Linens & Textiles (1930-Now)', 'CategoryIDPath' => '1:940', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 24 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1430', 'CategoryLevel' => 2, 'CategoryName' => 'Metalware', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Metalware', 'CategoryIDPath' => '1:1430', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 25 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13956', 'CategoryLevel' => 2, 'CategoryName' => 'Militaria', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Militaria', 'CategoryIDPath' => '1:13956', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 26 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '124', 'CategoryLevel' => 2, 'CategoryName' => 'Paper', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Paper', 'CategoryIDPath' => '1:124', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 27 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '966', 'CategoryLevel' => 2, 'CategoryName' => 'Pens & Writing Instruments', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Pens & Writing Instruments', 'CategoryIDPath' => '1:966', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 28 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '14005', 'CategoryLevel' => 2, 'CategoryName' => 'Pez, Keychains, Promo Glasses', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Pez, Keychains, Promo Glasses', 'CategoryIDPath' => '1:14005', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 29 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '14277', 'CategoryLevel' => 2, 'CategoryName' => 'Photographic Images', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Photographic Images', 'CategoryIDPath' => '1:14277', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 30 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '39507', 'CategoryLevel' => 2, 'CategoryName' => 'Pinbacks, Bobbles, Lunchboxes', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Pinbacks, Bobbles, Lunchboxes', 'CategoryIDPath' => '1:39507', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 31 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '914', 'CategoryLevel' => 2, 'CategoryName' => 'Postcards', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Postcards', 'CategoryIDPath' => '1:914', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 32 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '29832', 'CategoryLevel' => 2, 'CategoryName' => 'Radio, Phonograph, TV, Phone', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Radio, Phonograph, TV, Phone', 'CategoryIDPath' => '1:29832', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 33 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '1446', 'CategoryLevel' => 2, 'CategoryName' => 'Religion & Spirituality', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Religion & Spirituality', 'CategoryIDPath' => '1:1446', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 34 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '3213', 'CategoryLevel' => 2, 'CategoryName' => 'Rocks, Fossils & Minerals', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Rocks, Fossils & Minerals', 'CategoryIDPath' => '1:3213', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 35 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '152', 'CategoryLevel' => 2, 'CategoryName' => 'Science Fiction & Horror', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Science Fiction & Horror', 'CategoryIDPath' => '1:152', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 36 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '412', 'CategoryLevel' => 2, 'CategoryName' => 'Science & Medicine (1930-Now)', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Science & Medicine (1930-Now)', 'CategoryIDPath' => '1:412', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 37 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '113', 'CategoryLevel' => 2, 'CategoryName' => 'Sewing (1930-Now)', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Sewing (1930-Now)', 'CategoryIDPath' => '1:113', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 38 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '165800', 'CategoryLevel' => 2, 'CategoryName' => 'Souvenirs & Travel Memorabilia', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Souvenirs & Travel Memorabilia', 'CategoryIDPath' => '1:165800', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 39 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '593', 'CategoryLevel' => 2, 'CategoryName' => 'Tobacciana', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Tobacciana', 'CategoryIDPath' => '1:593', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 40 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '13849', 'CategoryLevel' => 2, 'CategoryName' => 'Tools, Hardware & Locks', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Tools, Hardware & Locks', 'CategoryIDPath' => '1:13849', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 41 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '868', 'CategoryLevel' => 2, 'CategoryName' => 'Trading Cards', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Trading Cards', 'CategoryIDPath' => '1:868', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 42 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '417', 'CategoryLevel' => 2, 'CategoryName' => 'Transportation', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Transportation', 'CategoryIDPath' => '1:417', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 43 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '597', 'CategoryLevel' => 2, 'CategoryName' => 'Vanity, Perfume & Shaving', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Vanity, Perfume & Shaving', 'CategoryIDPath' => '1:597', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 44 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '69851', 'CategoryLevel' => 2, 'CategoryName' => 'Vintage, Retro, Mid-Century', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Vintage, Retro, Mid-Century', 'CategoryIDPath' => '1:69851', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 45 => EbayShoppingStructCategoryType::__set_state(array( 'CategoryID' => '45058', 'CategoryLevel' => 2, 'CategoryName' => 'Wholesale Lots', 'CategoryParentID' => '1', 'CategoryParentName' => NULL, 'ItemCount' => NULL, 'CategoryNamePath' => 'Collectibles:Wholesale Lots', 'CategoryIDPath' => '1:45058', 'LeafCategory' => false, 'any' => NULL, 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), ), 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 'CategoryCount' => 46, 'UpdateTime' => '2013-09-10T02:20:24.000Z', 'CategoryVersion' => '106', 'Timestamp' => '2013-12-04T23:28:40.738Z', 'Ack' => 'Success', 'Errors' => NULL, 'Build' => 'E849_CORE_APILW_16526616_R1', 'Version' => '849', 'CorrelationID' => 'MY_MESSAGE_ID', 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )); ?>

Final case: location, SOAP Headers and more complex request

For this sample we call the PayPal SOAP API that allows to get our account balance. To learn how to do it using the web interface, please read first the post about getting your PayPal account balance. This call is more complex than the two previous ones because you have to set the Web service location, one SOAP Header and a request parameter with deeper values. But as nothing is impossible, here is the PHP file for the request that sets all what we just need:

<?php /** * This file has been auto-generated at 2013-12-05 00:36:52 from https://www.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1812. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/PayPalAutoload.php'; /** * This array contains the required parameters to initialize the class that makes the SOAP call. */ $wsdl = array(); $wsdl[PayPalServiceGet::WSDL_URL] = 'https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl'; /** * Instanciates the object that will make the call. */ $caller = new PayPalServiceGet($wsdl); /** * Sets the location. */ $caller->setLocation('https://api-3t.paypal.com/2.0/'); /** * Sets required SOAP Headers. */ $soapHeader0 = PayPalStructCustomSecurityHeaderType::__set_state(array( 'eBayAuthToken' => '', 'HardExpirationWarning' => '', 'Credentials' => PayPalStructUserIdPasswordType::__set_state(array( 'AppId' => '', 'DevId' => '', 'AuthCert' => '', 'Username' => '**************************', 'Password' => '****************', 'Signature' => '********************************************************', 'Subject' => '', 'AuthToken' => '', 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )); $caller->setSoapHeaderRequesterCredentials($soapHeader0,'urn:ebay:api:PayPalAPI',false,NULL); /** * This array contains the parameters as defined by the call you made. */ $parameters = array ( 0 => PayPalStructGetBalanceReq::__set_state(array( 'GetBalanceRequest' => PayPalStructGetBalanceRequestType::__set_state(array( 'ReturnAllCurrencies' => '1', 'DetailLevel' => 'ReturnAll', 'ErrorLanguage' => 'en', 'Version' => '98.0', 'any' => '', 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 'result' => NULL, 'lastError' => array ( ), 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), ); /** * Makes the call and get the result as the $result variable. */ $result = call_user_func_array(array($caller,'GetBalance'),$parameters); /** * Here are some methods that you can call to get things about the request and the response. */ $xmlRequestString = $caller->getLastRequest(); $xmlRequestDOMDocument = $caller->getLastRequest(true); $xmlResponseString = $caller->getLastResponse(); $xmlResponseDOMDocument = $caller->getLastResponse(true); /** * Handles the result depending on its value. */ if($result) { // request has been executed successfully, handle $result } else { // request has been executed unsuccessfully, handle (SoapFault) $soapFault $soapFault = $caller->getLastErrorForMethod($caller->__toString() . '::GetBalance'); } ?>

And the content of the PHP file for the response looks like that:

<?php /** * This file has been auto-generated at 2013-12-05 00:37:00 from https://www.wsdltophp.com. * @author Mikaël DELSOL <contact@wsdltophp.fr> * Be aware that we decline any error that could be contained by this file as it is auto-generated. * You should not modify it if you wish to make the exact same call that has been made using the interface. */ /** * Loads the file that autoloads the package classes. * This autoloader is contained by the zip archive that you can download at https://www.wsdltophp.com/mdwsdltophp/user/packagecontent/download/1812. * After downloading the zip archive, you should uncompress it in the root folder that contains this file. */ require_once __DIR__ . '/PayPalAutoload.php'; $response = PayPalStructGetBalanceResponseType::__set_state(array( 'Balance' => PayPalStructBasicAmountType::__set_state(array( 'currencyID' => 'EUR', '_' => '46100000.14', 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), 'BalanceTimeStamp' => '2013-12-04T23:36:29Z', 'BalanceHoldings' => array ( 0 => PayPalStructBasicAmountType::__set_state(array( 'currencyID' => 'EUR', '_' => '46100000.14', 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )), ), 'Timestamp' => '2013-12-04T23:36:29Z', 'Ack' => 'Success', 'CorrelationID' => '******0723***', 'Errors' => NULL, 'Version' => '98.0', 'Build' => '8620107', 'result' => NULL, 'lastError' => NULL, 'internArrayToIterate' => NULL, 'internArrayToIterateIsArray' => NULL, 'internArrayToIterateOffset' => NULL, )); ?>

Conclusion

Do you need more example to understand that from now you can call any SOAP Web service without having to code anything?

If you use the web interface then call the SOAP Web service, you'll be able to get the PHP code to execute the request you just made.

Isn't it great?!

Create an account now to use this feature!