string parameter into array, so that we can use it for calling webmethod. For a client we create object “soapclient” (argument is URL to the server)
at line 14. With created client we can call our webmetod “getWeather” and we pass the parameter (form data in array).
created a simple SOAP client, with just a few line of code.
SOAP Client Using WSDL
web service. So basically the programmer only needs to know webmethods name and required parameters, and all this can be retrieved from WSDL. We can
save WSDL file localy and use it. So let??????s make a SOAP client using WSDL (look at server code to see how we generated WSDL).
<?php
/**************************************************************
* Description:
* Creates a simple SOAP Client using WSDL (client_wsdl.php).
**************************************************************/
// use form data
if ((string)$_GET['action'] == 'get_data') {
// includes nusoap classes
require('inc/nusoap.php');
// set parameters and create client
$l_oClient = new soapclient(
'http://somewhere.org/soap/weather.wsdl', 'wsdl');
$l_oProxy = $l_oClient->getProxy();
// call a webmethod (getWeather)
$l_stResult = $l_oProxy->getWeather((string)$_POST['city']);
// check for errors
if (!$l_oClient->getError()) {
// print results
print '<h1>>Current data for: ' . (string)$_POST['city']
. ':</h1><ul><li>DEGREES: ' . $l_stResult['degrees']
. '°C</li><li>FORECAST: ' . $l_stResult['forecast']
. '</li></ul>';
}
// print error description
else {
echo '<h1>Napaka: ' . $l_oClient->getError() . '</h1>';
}
}
// output search fclientorm
print '
<form name="input" action="'.$_SERVER['PHP_SELF'].'?action=get_data" method="POST">
Your city: <input type="text" name="city">
<input type="submit" value="Search">
</form>
';
?>