Commit | Line | Data |
---|---|---|
696f20d5 MS |
1 | <?php |
2 | /* | |
3 | * $Id: wsdlclient14.php,v 1.2 2007/11/06 14:50:08 snichol Exp $ | |
4 | * | |
5 | * WSDL client sample. | |
6 | * | |
7 | * Service: WSDL | |
8 | * Payload: rpc/encoded | |
9 | * Transport: http | |
10 | * Authentication: none | |
11 | */ | |
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'] : ''; | |
18 | $useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0'; | |
19 | ||
20 | //echo 'You must set your own Via Michelin login and password in the source code to run this client!'; exit(); | |
21 | $login = 'WSDEMO_01145'; | |
22 | $password = 'DckHXMMHj'; | |
23 | ||
24 | $wsdlurl = 'http://www.viamichelin.com/ws/services/Geocoding?wsdl'; | |
25 | $cache = new wsdlcache('.', 120); | |
26 | $wsdl = $cache->get($wsdlurl); | |
27 | if (is_null($wsdl)) { | |
28 | $wsdl = new wsdl($wsdlurl, | |
29 | $proxyhost, $proxyport, $proxyusername, $proxypassword, | |
30 | 0, 30, null, $useCURL); | |
31 | $err = $wsdl->getError(); | |
32 | if ($err) { | |
33 | echo '<h2>WSDL Constructor error</h2><pre>' . $err . '</pre>'; | |
34 | echo '<h2>Debug</h2><pre>' . htmlspecialchars($wsdl->getDebug(), ENT_QUOTES) . '</pre>'; | |
35 | exit(); | |
36 | } | |
37 | $cache->put($wsdl); | |
38 | } else { | |
39 | $wsdl->debug_str = ''; | |
40 | $wsdl->debug('Retrieved from cache'); | |
41 | } | |
42 | $client = new nusoap_client($wsdl, 'wsdl', | |
43 | $proxyhost, $proxyport, $proxyusername, $proxypassword); | |
44 | $err = $client->getError(); | |
45 | if ($err) { | |
46 | echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; | |
47 | echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; | |
48 | exit(); | |
49 | } | |
50 | ||
51 | $inputAddresses[] = array( | |
52 | 'address' => '45 Liberty Blvd.', | |
53 | 'cityName' => 'Malvern', | |
54 | 'countryCode' => 'USA', | |
55 | 'postalCode' => '19355', | |
56 | 'stateName' => 'PA' | |
57 | ); | |
58 | $geocodingrequest = array('addressesList' => $inputAddresses); | |
59 | $params = array('request' => $geocodingrequest, 'check' => "$login|$password"); | |
60 | $result = $client->call('getLocationsList', $params); | |
61 | ||
62 | // Check for a fault | |
63 | if ($client->fault) { | |
64 | echo '<h2>Fault (Expect - AUTHENTIFICATION)</h2><pre>'; | |
65 | print_r($result); | |
66 | echo '</pre>'; | |
67 | } else { | |
68 | // Check for errors | |
69 | $err = $client->getError(); | |
70 | if ($err) { | |
71 | // Display the error | |
72 | echo '<h2>Error</h2><pre>' . $err . '</pre>'; | |
73 | } else { | |
74 | // Display the result | |
75 | echo '<h2>Result</h2><pre>'; | |
76 | print_r($result); | |
77 | echo '</pre>'; | |
78 | } | |
79 | } | |
80 | echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; | |
81 | echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; | |
82 | echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; | |
83 | ?> |