PHP Classes

File: sample-tpl.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of MikaŽl DELSOL  >  WSDL To PHP  >  sample-tpl.php  >  Download  
File: sample-tpl.php
Role: Example script
Content type: text/plain
Description: Class source
Class: WSDL To PHP
Generate classes to send SOAP requests from a WSDL
Author: By
Last change: [UPDATE] minor PHP doc block updates
[UPDATE] PSR-2 standards for generator files and generated files
[UPDATE] enhancement and compliance

In order to let the PHP native SoapClient class handle correctly the
object to send based on the request created with the generated classes,
we no longer define the array to send. Indeed, it's better to let the
SoapClient convert the object passed to the generate method mathcing the
operation to call instead of defining an array based on the object. It
actually creates conflicts or defines values that should be sent.
By this update, the option sendArrayAsParameter should be not useful
By this update we lose the faculty to define a specific behaviour on the
values sent because we previously called the getter associated to the
value to send. In this case, the generate method PHP doc block has been

Update of the sample file to be more explicit on the optional parameter
when instantiating a Service class.

Finally, the sample case for PayPal in samples-generator.php has been
updated to give a functional example based on this update.
[UPDATE] enhancements and refactoring


Simplification of the instantiation of Service objects in the
generated sample file by removing the SoapClient options parameter. By
default, the cache_wsdl is disabled, the wsdl_url is set with the WSDL
url used to generate the package and trace is set with true. The
VALUE_WSDL_URL constant has been added to the generated WsdlClass
defined with the WSDL url used to generate the package.

Remove trailing ?> in generator files/classes.

Add WsdlToPhpGenerator::getWsdl($_index) method to get any WSDL at any

Enhance generated sample file with explanation about the optional
parameter allowing to override the SoapClient Options. Remove the $wsdl
parareter previously used to instantiate each Service object.

Avoid Struct object to reset SoapClient when it is instantiated when
calling the parent constructor.
[UPDATE] updates initiated by the pull request
Date: 1 year ago
Size: 1,176 bytes


Class file image Download
 * Test with PackageName for WSDL_PATH
 * @package PackageName
 * Load autoload
require_once dirname(__FILE__) . '/PackageNameAutoload.php';
 * Wsdl instanciation infos. By default, nothing has to be set.
 * If you wish to override the SoapClient's options, please refer to the sample below.
 * This is an associative array as:
 * - the key must be a PackageNameWsdlClass constant beginning with WSDL_
 * - the value must be the corresponding key value
 * Each option matches the {@link} options
 * Here is below an example of how you can set the array:
 * $wsdl = array();
 * $wsdl[PackageNameWsdlClass::WSDL_URL] = WSDL_PATH;
 * $wsdl[PackageNameWsdlClass::WSDL_CACHE_WSDL] = WSDL_CACHE_NONE;
 * $wsdl[PackageNameWsdlClass::WSDL_TRACE] = true;
 * $wsdl[PackageNameWsdlClass::WSDL_LOGIN] = 'myLogin';
 * $wsdl[PackageNameWsdlClass::WSDL_PASSWD] = '**********';
 * etc....
 * Then instantiate the Service class as:
 * - $wsdlObject = new PackageNameWsdlClass($wsdl);
 * Examples