Commit | Line | Data |
---|---|---|
696f20d5 MS |
1 | <?php |
2 | /* | |
3 | * $Id: wsdlclient15.php,v 1.1 2008/02/12 00:13:50 snichol Exp $ | |
4 | * | |
5 | * UTF-8 client sample that sends and receives data with characters UTF-8 encoded. | |
6 | * | |
7 | * Service: WSDL | |
8 | * Payload: document/literal | |
9 | * Transport: http | |
10 | * Authentication: none | |
11 | */ | |
12 | require_once('../lib/nusoap.php'); | |
13 | $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : ''; | |
14 | $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : ''; | |
15 | $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : ''; | |
16 | $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : ''; | |
17 | $useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0'; | |
18 | $client = new nusoap_client('http://www.scottnichol.com/samples/helloutf8.php?wsdl', 'wsdl', | |
19 | $proxyhost, $proxyport, $proxyusername, $proxypassword); | |
20 | $err = $client->getError(); | |
21 | if ($err) { | |
22 | echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; | |
23 | echo '<h2>Debug</h2>'; | |
24 | echo '<pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; | |
25 | exit(); | |
26 | } | |
27 | $client->setUseCurl($useCURL); | |
28 | $client->soap_defencoding = 'UTF-8'; | |
29 | $client->decode_utf8 = false; | |
30 | $utf8string = array('stuff' => "\xc2\xa9\xc2\xae\xc2\xbc\xc2\xbd\xc2\xbe"); | |
31 | $result = $client->call('echoback', $utf8string); | |
32 | if ($client->fault) { | |
33 | echo '<h2>Fault</h2><pre>'; | |
34 | print_r($result); | |
35 | echo '</pre>'; | |
36 | } else { | |
37 | $err = $client->getError(); | |
38 | if ($err) { | |
39 | echo '<h2>Error</h2><pre>' . $err . '</pre>'; | |
40 | } else { | |
41 | echo '<h2>Result</h2><pre>'; | |
42 | // Decode the result: it so happens we sent Latin-1 characters | |
43 | if (isset($result['return'])) { | |
44 | $result1 = utf8_decode($result['return']); | |
45 | } elseif (!is_array($result)) { | |
46 | $result1 = utf8_decode($result); | |
47 | } else { | |
48 | $result1 = $result; | |
49 | } | |
50 | print_r($result1); | |
51 | echo '</pre>'; | |
52 | } | |
53 | } | |
54 | echo '<h2>Request</h2>'; | |
55 | echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; | |
56 | echo '<h2>Response</h2>'; | |
57 | echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; | |
58 | echo '<h2>Debug</h2>'; | |
59 | echo '<pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; | |
60 | ?> |