Issues (209)

samples/wsdlclient15.php (4 issues)

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);
0 ignored issues
show
It seems like $useCURL can also be of type string; however, parameter $use of Nusoap_client::setUseCURL() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
$client->setUseCurl(/** @scrutinizer ignore-type */ $useCURL);
Loading history...
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)) {
0 ignored issues
show
The condition is_array($result) is always false.
Loading history...
46
			$result1 = utf8_decode($result);
0 ignored issues
show
$result of type false is incompatible with the type string expected by parameter $data of utf8_decode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
			$result1 = utf8_decode(/** @scrutinizer ignore-type */ $result);
Loading history...
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
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
61