3 * $Id: wsdlclient12.php,v 1.4 2007/11/06 14:50:07 snichol Exp $
8 * Payload: document/literal
10 * Authentication: none
12 require_once('../lib/nusoap.php');
13 require_once('../lib/class.wsdlcache.php');
14 $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
15 $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
16 $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
17 $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
19 $method = isset($_GET['method']) ? $_GET['method'] : 'ItemSearch';
21 $SubscriptionId = 'Your AWS subscription id';
23 $wsdlurl = 'http://webservices.amazon.com/AWSECommerceService/US/AWSECommerceService.wsdl';
24 $cache = new wsdlcache('.', 120);
25 $wsdl = $cache->get($wsdlurl);
27 $wsdl = new wsdl($wsdlurl,
28 $proxyhost, $proxyport, $proxyusername, $proxypassword);
31 $wsdl->debug_str = '';
32 $wsdl->debug('Retrieved from cache');
34 $client = new nusoap_client($wsdl, true,
35 $proxyhost, $proxyport, $proxyusername, $proxypassword);
36 $err = $client->getError();
38 echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
41 $client->soap_defencoding = 'UTF-8';
43 function GetCartCreateParams() {
44 global $SubscriptionId;
46 // create items to be added to the cart
48 $item[0] = array( "ASIN" => "0596004206",
51 $item[1] = array( "ASIN" => "0596003277",
55 // pack it to <Item> array
56 $items = array("Item" => $item);
57 // Construct request parameters
58 $request = array("Items" => $items, "ResponseGroup" => "CartSimilarities");
60 // Construct all parameters
61 $cartCreate = array( "SubscriptionId" => $SubscriptionId,
68 function GetItemLookupParams() {
69 global $SubscriptionId;
71 $itemLookupRequest[] = array(
72 'ItemId' => 'B0002IQML6',
75 'ResponseGroup' => 'Large'
78 $itemLookupRequest[] = array(
79 'ItemId' => '0486411214',
82 'ResponseGroup' => 'Small'
86 'SubscriptionId' => $SubscriptionId,
87 // 'AssociateTag' => '',
88 'Request' => $itemLookupRequest,
94 function GetItemSearchParams() {
95 global $SubscriptionId;
97 $itemSearchRequest = array(
100 // 'ResponseGroup' => array('Request', 'Small'),
101 'SearchIndex' => 'Books',
102 'Sort' => 'salesrank'
106 'SubscriptionId' => $SubscriptionId,
107 // 'AssociateTag' => '',
109 // 'XMLEscaping' => '',
110 // 'Shared' => $itemSearchRequest,
111 'Request' => array($itemSearchRequest)
117 function GetItemSearchParams2() {
118 global $SubscriptionId;
121 "Keywords" => "postal stamps",
122 "SearchIndex" => "Books"
126 'SubscriptionId' => $SubscriptionId,
127 'Request' => $request
133 function GetListLookupParams() {
134 global $SubscriptionId;
136 $listLookupRequest[] = array(
137 'ListId' => '1L0ZL7Y9FL4U0',
138 'ListType' => 'WishList',
140 'ResponseGroup' => 'ListFull',
141 'Sort' => 'LastUpdated'
144 $listLookupRequest[] = array(
145 'ListId' => '1L0ZL7Y9FL4U0',
146 'ListType' => 'WishList',
148 'ResponseGroup' => 'ListFull',
149 'Sort' => 'LastUpdated'
152 // two lookup maximum
153 $listLookupRequest[] = array(
154 'ListId' => '1L0ZL7Y9FL4U0',
155 'ListType' => 'WishList',
157 'ResponseGroup' => 'ListFull',
158 'Sort' => 'LastUpdated'
162 'SubscriptionId' => $SubscriptionId,
163 // 'AssociateTag' => '',
164 'Request' => $listLookupRequest,
170 function GetListSearchParams() {
171 global $SubscriptionId;
173 $listSearchRequest[] = array(
174 'FirstName' => 'Scott',
175 'LastName' => 'Nichol',
176 'ListType' => 'WishList'
180 'SubscriptionId' => $SubscriptionId,
181 // 'AssociateTag' => '',
182 'Request' => $listSearchRequest,
188 if ($method == 'ItemLookup') {
189 $result = $client->call('ItemLookup', array('body' => GetItemLookupParams()));
190 } elseif ($method == 'ItemSearch') {
191 $result = $client->call('ItemSearch', array('body' => GetItemSearchParams()));
192 } elseif ($method == 'ItemSearch2') {
193 $result = $client->call('ItemSearch', array('body' => GetItemSearchParams2()));
194 } elseif ($method == 'ListLookup') {
195 $result = $client->call('ListLookup', array('body' => GetListLookupParams()));
196 } elseif ($method == 'ListSearch') {
197 $result = $client->call('ListSearch', array('body' => GetListSearchParams()));
198 } elseif ($method == 'CartCreate') {
199 $result = $client->call('CartCreate', array('body' => GetCartCreateParams()));
201 echo "Unsupported method $method";
205 if ($client->fault) {
206 echo '<h2>Fault</h2><pre>';
211 $err = $client->getError();
214 echo '<h2>Error</h2><pre>' . $err . '</pre>';
216 // Display the result
217 echo '<h2>Result</h2><pre>';
222 echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
223 echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
224 echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';