<slide title="Anatomy of a PHP Client">

<example type="php" title="Include the SOAP Client" fontsize='1.4em'>
<![CDATA[<?php require_once('SOAP/Client.php'); ?>
]]>
</example>
<example type="php" title="Create the SOAP Client" fontsize='1.4em'>
<![CDATA[<?php
$endpoint = 'http://api.google.com/search/beta2';
$client =& new SOAP_Client($endpoint);
?>
]]>
</example>
<example type="php" title="Prepare the Data" fontsize='1.4em'>
<![CDATA[<?php
$key = 'xxxx';
$query = 'Caraveo';
$start = 0;
$maxResults = 4;
$filter = false;
$restrict = '';
$safeSearch = false;
$lr = '';
$ie = '';
$oe = '';
?>
]]>
</example>
<example type="php" title="Make the SOAP Call" fontsize='1.4em'>
<![CDATA[<?php
$response = $client->call('doGoogleSearch',
                          $params = array('key'=>$key,
                                'q'=>$query,
                                'start'=>$start,
                                'maxResults'=>$maxResults,
                                'filter'=>$filter,
                                'restrict'=>$restrict,
                                'safeSearch'=>$safeSearch,
                                'lr'=>$lr,
                                'ie'=>$ie,
                                'oe'=>$oe),
                          array('namespace'=>'urn:GoogleSearch'));
?>
]]>
</example>
<example type="php" title="Do something with the results" fontsize='1.4em'>
<![CDATA[<?php
foreach($response->resultElements as $result) {
    echo '<a href="'.$result->URL.'">';
    echo $result->title."</a><br><br>\n";
    echo $result->snippet."<br><br><br>\n";
}
?>
]]>
</example>
<list><bullet>Benefits</bullet></list>
<list marginleft="2em">
    <bullet>No WSDL Overhead</bullet>
    <bullet>No worry about creating SOAP_Values, we do it for you</bullet>
</list>
<list><bullet>Pitfalls</bullet></list>
<list marginleft="2em">
    <bullet>PHP data types do not convert correctly to SOAP often</bullet>
    <bullet>Must still know how to read WSDL</bullet>
    <bullet>Low Interoperability (except with dynamic languages)</bullet>
</list>
</slide>
