PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Viewing SOAP Transactions

All communication with StrikeIron is done using the SOAP extension. It is sometimes useful to view the XML exchanged with StrikeIron for debug purposes.

Every StrikeIron client (subclass of Zend_Service_StrikeIron_Base) contains a getSoapClient() method to return the underlying instance of SOAPClient used to communicate with StrikeIron.

PHP' SOAPClient has a trace option that causes it to remember the XML exchanged during the last transaction. Zend_Service_StrikeIron does not enable the trace option by default but this can easily by changed by specifying the options that will be passed to the SOAPClient constructor.

To view a SOAP transaction, call the getSoapClient() method to get the SOAPClient instance and then call the appropriate methods like __getLastRequest() and __getLastRequest():

<?php
$strikeIron 
=
    new 
Zend_Service_StrikeIron(array('username' => 'your-username',
                                      
'password' => 'your-password',
                                      
'options'  => array('trace' => true)));

// Get a client for the Sales & Use Tax Basic service
$taxBasic $strikeIron->getService(array('class' => 'SalesUseTaxBasic'));

// Perform a method call
$taxBasic->getTaxRateCanada(array('province' => 'ontario'));

// Get SOAPClient instance and view XML
$soapClient $taxBasic->getSoapClient();
echo 
$soapClient->__getLastRequest();
echo 
$soapClient->__getLastResponse();

Zend Framework