### Run unit tests locally Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Commands to navigate to the source directory, install dependencies, and execute the test suite. ```bash $ cd /path/to/src/WsdlToPhp/PackageBase/ $ composer install $ composer test ``` -------------------------------- ### Create Docker container Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Command to build and start the Docker container from the project root directory. ```bash $ docker-compose up -d --build ``` -------------------------------- ### Retrieve items from ArrayType Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Examples of retrieving the first, last, or a specific item from an ArrayType collection. ```php $items->first(); ``` ```php $items->last(); ``` ```php $items->item($index); ``` -------------------------------- ### Redefining SoapHeaders Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Example of using the setSoapHeader method within a generated ServiceType class. ```php // A sample of its usage in the generated ServiceType class public function setSoapHeaderCSPCHD(\Api\StructType\ApiCSPCHD $cSPCHD, $nameSpace = 'http://tempuri.org', $mustUnderstand = false, $actor = null) { return $this->setSoapHeader($nameSpace, 'CSPCHD', $cSPCHD, $mustUnderstand, $actor); } ``` -------------------------------- ### Run commands inside Docker container Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Commands to install dependencies and execute tests within the 'package_base' container using PHP 7.4. ```bash # install deps in container (using update ensure it does use the composer.lock file if there is any) $ docker exec -it package_base php-7.4 /usr/bin/composer update # run tests in container $ docker exec -it package_base php-7.4 -dmemory_limit=-1 vendor/bin/phpunit ``` -------------------------------- ### Define a ServiceType class extending AbstractSoapClientBase Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Example of a generated ServiceType class that uses AbstractSoapClientBase to wrap SOAP calls and handle errors. ```php namespace Api\ServiceType; use \WsdlToPhp\PackageBase\AbstractSoapClientBase; class ApiUpdate extends AbstractSoapClientBase { public function UpdateBulkOrder(\Api\StructType\ApiUpdateBulkOrder $parameters) { try { $this->setResult($this->getSoapClient()->UpdateBulkOrder($parameters)); return $this->getResult(); } catch (\SoapFault $soapFault) { $this->saveLastError(__METHOD__, $soapFault); return false; } } } ``` -------------------------------- ### Initialize and reset the SoapClient instance Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Demonstrates how to initialize the service with WSDL options and how to reset the underlying SoapClient instance. ```php use \WsdlToPhp\PackageBase\AbstractSoapClientBase; $options = [ AbstractSoapClientBase::WSDL_URL => '__WSDL_URL__', AbstractSoapClientBase::WSDL_CLASSMAP => \Api\ApiClassMap::classMap(), ]; // sets the first instance of SoapClient within AbstractSoapClientBase $update = new \Api\ServiceType\ApiUpdate($options); // resets the SoapClient instance $update = new \Api\ServiceType\ApiUpdate($options, true); ``` -------------------------------- ### Instantiate StructType using __set_state Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Demonstrates how to use the __set_state method to hydrate a StructType object with an associative array of properties. ```php $item = \Api\StructType\Item::__set_state([ 'id' => 1, 'name' => 'Entity #1', 'label' => 'Entity #1', '_href' => 'http://www.entity.com', ]); // $item is now an \Api\StructType\Item object ``` -------------------------------- ### Instantiate ArrayType with nested items Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Shows how to initialize an ArrayType class using __set_state with a collection of StructType objects. ```php $items = \Api\ArrayType\Items::__set_state([ 'items' => [ \Api\StructType\Item::__set_state([ 'id' => 1, 'name' => 'Entity #1', 'label' => 'Entity #1', '_href' => 'http://www.entity-1.com', ]), \Api\StructType\Item::__set_state([ 'id' => 2, 'name' => 'Entity #2', 'label' => 'Entity #2', '_href' => 'http://www.entity-2.com', ]), \Api\StructType\Item::__set_state([ 'id' => 3, 'name' => 'Entity #3', 'label' => 'Entity #3', '_href' => 'http://www.entity-3.com', ]), ], ]); // 'items' is the unique property of the object // Its name is returned by the getAttributeName method // defined in the generated \Api\ArrayType\Items class ``` -------------------------------- ### Legacy property access in 3.0 Source: https://github.com/wsdltophp/packagebase/blob/develop/UPGRADE-4.0.md Demonstrates the deprecated _set and _get methods used in version 3.0. ```php /** @var WsdlToPhp\PackageBase\AbstractStructBase|WsdlToPhp\PackageBase\AbstractStructArrayBase $o */ $o = new Struct(); $o->_set('name', 'the name'); $theName = $o->_get('name'); ``` -------------------------------- ### Updated property access in 4.0 Source: https://github.com/wsdltophp/packagebase/blob/develop/UPGRADE-4.0.md Demonstrates the new setPropertyValue and getPropertyValue methods replacing the legacy internal methods. ```php /** @var WsdlToPhp\PackageBase\AbstractStructBase|WsdlToPhp\PackageBase\AbstractStructArrayBase $o */ $o = new Struct(); $o->setPropertyValue('name', 'the name'); $theName = $o->getPropertyValue('name'); ``` -------------------------------- ### Accessing SoapClient in version 1.0 Source: https://github.com/wsdltophp/packagebase/blob/develop/UPGRADE-2.0.md Uses the static method self::getSoapClient() to access the SoapClient instance. ```php class MyService extends AbstractSoapClientBase { public function CreateQueue(\Api\StructType\ApiCreateQueue $body) { try { $this->setResult(self::getSoapClient()->CreateQueue($body)); return $this->getResult(); } catch (\SoapFault $soapFault) { $this->saveLastError(__METHOD__, $soapFault); return false; } } } ``` -------------------------------- ### Iterate through ArrayType items Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Demonstrates iterating over an ArrayType object using a foreach loop. ```php foreach ($items as $item) { // $items->current() and $item is an \Api\StructType\Item object // $items->key() is the current index } ``` -------------------------------- ### Accessing SoapClient in version 2.0 Source: https://github.com/wsdltophp/packagebase/blob/develop/UPGRADE-2.0.md Uses the instance method $this->getSoapClient() to access the SoapClient instance. ```php class MyService extends AbstractSoapClientBase { public function CreateQueue(\Api\StructType\ApiCreateQueue $body) { try { $this->setResult($this->getSoapClient()->CreateQueue($body)); return $this->getResult(); } catch (\SoapFault $soapFault) { $this->saveLastError(__METHOD__, $soapFault); return false; } } } ``` -------------------------------- ### Accessing results, request/response data, and errors Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Shows how to retrieve the result of a SOAP call or access debugging information like XML requests, headers, and errors when a call fails. ```php $result = $update->UpdateBulkOrder(new \Api\StructType\ApiUpdateBulkOrder()) if ($result !== false) { echo "\nThis is the result as an object:" . print_r($update->getResult(), true); // Actually $result is the same data than $update->getResult() } else { echo "\nThis is the XML request:" . $update->getLastRequest(false); echo "\nThese are the request's headers:" . $update->getLastRequestHeaders(false); echo "\nThis is the XML response:" . $update->getLastResponse(false); echo "\nThese are the response's headers:" . $update->getLastResponseHeaders(false); echo "\nThese are the last errors:" . print_r($update->getLastError(), true); echo "\nThis is the current error:" . print_r($update->getLastErrorForMethod('\Api\ServiceType\ApiUpdate::UpdateBulkOrder'), true); } ``` -------------------------------- ### Add item to ArrayType Source: https://github.com/wsdltophp/packagebase/blob/develop/README.md Shows how to append a new StructType object to an existing ArrayType collection. ```php $items->add(\Api\StructType\Item::__set_state([ 'id' => 4, 'name' => 'Entity #4', 'label' => 'Entity #4', '_href' => 'http://www.entity-4.com', ])); ``` -------------------------------- ### Rename getFormatedXml to getFormattedXml Source: https://github.com/wsdltophp/packagebase/blob/develop/UPGRADE-3.0.md Update method calls to use the corrected spelling of getFormattedXml. ```php WsdlToPhp\PackageBase\Utils::getFormatedXml($xmlString); WsdlToPhp\PackageBase\AbstractSoapClientBase::getFormatedXml($xmlString); ``` ```php WsdlToPhp\PackageBase\Utils::getFormattedXml($xmlString); WsdlToPhp\PackageBase\AbstractSoapClientBase::getFormattedXml($xmlString); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.