1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.service.strikeiron.advanced-uses">
4 <title>Zend_Service_StrikeIron: Advanced Uses</title>
7 This section describes the more advanced uses of
8 <classname>Zend_Service_StrikeIron</classname>.
11 <sect2 id="zend.service.strikeiron.advanced-uses.services-by-wsdl">
12 <title>Using Services by WSDL</title>
15 Some StrikeIron services may have a <acronym>PHP</acronym> wrapper class available,
16 such as those described in
17 <link linkend="zend.service.strikeiron.bundled-services">Bundled Services</link>.
18 However, StrikeIron offers hundreds of services and many of these
19 may be usable even without creating a special wrapper class.
23 To try a StrikeIron service that does not have a wrapper class available,
24 give the <code>wsdl</code> option to <methodname>getService()</methodname>
25 instead of the <code>class</code> option:
28 <programlisting language="php"><![CDATA[
29 $strikeIron = new Zend_Service_StrikeIron(array('username' => 'your-username',
30 'password' => 'your-password'));
32 // Get a generic client to the Reverse Phone Lookup service
33 $phone = $strikeIron->getService(
34 array('wsdl' => 'http://ws.strikeiron.com/ReversePhoneLookup?WSDL')
37 $result = $phone->lookup(array('Number' => '(408) 253-8800'));
38 echo $result->listingName;
40 // Zend Technologies USA Inc
44 Using StrikeIron services from the WSDL will require at least some understanding
45 of the WSDL files. StrikeIron has many resources on its site to help with this. Also,
46 <ulink url="http://janschneider.de">Jan Schneider</ulink> from the <ulink
47 url="http://horde.org">Horde project</ulink> has written a <ulink
48 url="http://janschneider.de/news/25/268">small <acronym>PHP</acronym>
49 routine</ulink> that will format a WSDL file into more readable
50 <acronym>HTML</acronym>.
54 Please note that only the services described in the <link
55 linkend="zend.service.strikeiron.bundled-services">Bundled Services</link>
56 section are officially supported.
60 <sect2 id="zend.service.strikeiron.viewing-soap-transactions">
61 <title>Viewing SOAP Transactions</title>
64 All communication with StrikeIron is done using the <acronym>SOAP</acronym> extension.
65 It is sometimes useful to view the <acronym>XML</acronym> exchanged with StrikeIron for
70 Every StrikeIron client (subclass of
71 <classname>Zend_Service_StrikeIron_Base</classname>) contains a
72 <methodname>getSoapClient()</methodname> method to return the underlying instance of
73 <code>SOAPClient</code> used to communicate with StrikeIron.
77 <acronym>PHP</acronym>' <ulink
78 url="http://www.php.net/manual/en/function.soap-soapclient-construct.php">SOAPClient</ulink>
79 has a <code>trace</code> option that causes it to remember the <acronym>XML</acronym>
80 exchanged during the last transaction. <classname>Zend_Service_StrikeIron</classname>
81 does not enable the <code>trace</code> option by default but this can easily by changed
82 by specifying the options that will be passed to the <code>SOAPClient</code>
87 To view a SOAP transaction, call the <methodname>getSoapClient()</methodname> method
88 to get the <code>SOAPClient</code> instance and then call the appropriate methods like
90 url="http://www.php.net/manual/en/function.soap-soapclient-getlastrequest.php"><methodname>__getLastRequest()</methodname></ulink>
92 url="http://www.php.net/manual/en/function.soap-soapclient-getlastresponse.php"><methodname>__getLastRequest()</methodname></ulink>:
95 <programlisting language="php"><![CDATA[
97 new Zend_Service_StrikeIron(array('username' => 'your-username',
98 'password' => 'your-password',
99 'options' => array('trace' => true)));
101 // Get a client for the Sales & Use Tax Basic service
102 $taxBasic = $strikeIron->getService(array('class' => 'SalesUseTaxBasic'));
104 // Perform a method call
105 $taxBasic->getTaxRateCanada(array('province' => 'ontario'));
107 // Get SOAPClient instance and view XML
108 $soapClient = $taxBasic->getSoapClient();
109 echo $soapClient->__getLastRequest();
110 echo $soapClient->__getLastResponse();