Reputation: 33
I am trying to call a publicly available web service from a PHP web page.
The web service is: http://www.webservicex.net/uszip.asmx?WSDL
<html>
<body>
<?php
$zip = $_REQUEST['zip'];
echo 'zip is'.$zip;
?>
<form action="wszip.php" method="post">
<table cellspacing="10" bgcolor="CadetBlue">
<tr>
<td><B>Enter Zip Code : </B><input type="text" name="zip" /></td>
<td></td>
<td><input type="Submit" value="Find It!"/></td>
</tr>
</table>
<BR><BR><BR><BR>
</form>
<?php
if($zip != "")
{
$wsdl = "http://www.webservicex.net/uszip.asmx?WSDL";
$client = new soapclient($wsdl, true);
$response = $client->GetInfoByZIP($zip);
}
?>
</body>
</html>
Upvotes: 0
Views: 13441
Reputation: 50298
You're feeding the ZIP code in incorrectly, and your constructor syntax is also incorrect. Use this syntax instead:
$wsdl = "http://www.webservicex.net/uszip.asmx?WSDL";
$client = new soapclient($wsdl);
$response = $client->GetInfoByZIP(array('USZip' => $zip));
I just tested it, and it works fine. The documentation is here.
Upvotes: 7