ZendService\StrikeIron: Advanced Uses

This section describes the more advanced uses of ZendService\StrikeIron\StrikeIron.

Using Services by WSDL

Some StrikeIron services may have a PHP wrapper class available, such as those described in Bundled Services. However, StrikeIron offers hundreds of services and many of these may be usable even without creating a special wrapper class.

To try a StrikeIron service that does not have a wrapper class available, give the wsdl option to getService() instead of the class option:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$strikeIron = new ZendService\StrikeIron\StrikeIron(array('username' => 'your-username',
                                                'password' => 'your-password'));

// Get a generic client to the Reverse Phone Lookup service
$phone = $strikeIron->getService(
    array('wsdl' => 'http://ws.strikeiron.com/ReversePhoneLookup?WSDL')
);

$result = $phone->lookup(array('Number' => '(408) 253-8800'));
echo $result->listingName;

// Zend Technologies USA Inc

Using StrikeIron services from the WSDL will require at least some understanding of the WSDL files. StrikeIron has many resources on its site to help with this. Also, Jan Schneider from the Horde project has written a small PHP routine that will format a WSDL file into more readable HTML.

Please note that only the services described in the Bundled Services section are officially supported.

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 ZendService\StrikeIron\Base) contains a getSoapClient() method to return the underlying instance of SOAPClient used to communicate with StrikeIron.

PHPSOAPClient has a trace option that causes it to remember the XML exchanged during the last transaction. ZendService\StrikeIron\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():

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$strikeIron =
    new ZendService\StrikeIron\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();

Table Of Contents

Previous topic

ZendService\StrikeIron: Bundled Services

Next topic

ZendService\Technorati

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to ZendService\StrikeIron: Advanced Uses on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.