我试图从PHP网页上调用公开的Web服务.
Web服务是: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>
Run Code Online (Sandbox Code Playgroud)
您输入的邮政编码不正确,您的构造函数语法也不正确.请改用此语法:
$wsdl = "http://www.webservicex.net/uszip.asmx?WSDL";
$client = new soapclient($wsdl);
$response = $client->GetInfoByZIP(array('USZip' => $zip));
Run Code Online (Sandbox Code Playgroud)
我刚试过它,它工作正常.文档在这里.
| 归档时间: |
|
| 查看次数: |
9175 次 |
| 最近记录: |