<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.service.strikeiron.advanced-uses">
    <title>Zend_Service_StrikeIron: Advanced Uses</title>

    <para>
        This section describes the more advanced uses of
        <classname>Zend_Service_StrikeIron</classname>.
    </para>

    <sect2 id="zend.service.strikeiron.advanced-uses.services-by-wsdl">
        <title>Using Services by WSDL</title>

        <para>
            Some StrikeIron services may have a <acronym>PHP</acronym> wrapper class available,
            such as those described in
            <link linkend="zend.service.strikeiron.bundled-services">Bundled Services</link>.
            However, StrikeIron offers hundreds of services and many of these
            may be usable even without creating a special wrapper class.
        </para>

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

        <programlisting language="php"><![CDATA[
$strikeIron = new Zend_Service_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
]]></programlisting>

        <para>
            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,
            <ulink url="http://janschneider.de">Jan Schneider</ulink> from the <ulink
                url="http://horde.org">Horde project</ulink> has written a <ulink
                url="http://janschneider.de/news/25/268">small <acronym>PHP</acronym>
                routine</ulink> that will format a WSDL file into more readable
            <acronym>HTML</acronym>.
        </para>

        <para>
            Please note that only the services described in the <link
                linkend="zend.service.strikeiron.bundled-services">Bundled Services</link>
            section are officially supported.
        </para>
    </sect2>

    <sect2 id="zend.service.strikeiron.viewing-soap-transactions">
        <title>Viewing SOAP Transactions</title>

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

        <para>
            Every StrikeIron client (subclass of
            <classname>Zend_Service_StrikeIron_Base</classname>) contains a
            <methodname>getSoapClient()</methodname> method to return the underlying instance of
            <classname>SOAPClient</classname> used to communicate with StrikeIron.
        </para>

        <para>
            <acronym>PHP</acronym>' <ulink
                url="http://www.php.net/manual/en/function.soap-soapclient-construct.php">SOAPClient</ulink>
            has a <property>trace</property> option that causes it to remember the
            <acronym>XML</acronym> exchanged during the last transaction.
            <classname>Zend_Service_StrikeIron</classname> does not enable the
            <property>trace</property> option by default but this can easily by changed
            by specifying the options that will be passed to the <classname>SOAPClient</classname>
            constructor.
        </para>

        <para>
            To view a SOAP transaction, call the <methodname>getSoapClient()</methodname> method
            to get the <classname>SOAPClient</classname> instance and then call the appropriate
            methods like <ulink
                url="http://www.php.net/manual/en/function.soap-soapclient-getlastrequest.php"><methodname>__getLastRequest()</methodname></ulink>
            and <ulink
                url="http://www.php.net/manual/en/function.soap-soapclient-getlastresponse.php"><methodname>__getLastRequest()</methodname></ulink>:
        </para>

        <programlisting language="php"><![CDATA[
$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();
]]></programlisting>
    </sect2>
</sect1>
