<?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 PHP 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 <code>wsdl</code> option to <code>getService()</code>
        instead of the <code>class</code> option:

        <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>

      <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 PHP routine</ulink> that
        will format a WSDL file into more readable HTML.
      </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 SOAP extension. It
        is sometimes useful to view the XML exchanged with StrikeIron for debug
        purposes.
      </para>

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

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

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

        <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>
      </para>

    </sect2>
</sect1>
