dongquechan4414 2012-01-18 20:21
浏览 97
已采纳

PHP SoapClient异常,我做错了什么?

I´ve recently started looking a web service calls using PHP. I can´t get the following rather simple snippet to work, instead the web service returns an exception.

<?php
$client = new SoapClient("http://www.webservicex.net/geoipservice.asmx?wsdl");
print($client->__soapCall("GetGeoIP", array('IP' => '83.251.30.62')));
?>

I´ve also tried the simpler $client->GetGeoIP('83.251.30.62'); but they both yield the same result.

Is there something wrong with my code? Exception below:

Fatal error: Uncaught SoapFault exception: [soap:Server] 
System.Web.Services.Protocols.SoapException: Server was unable to process request. --->     System.ArgumentNullException: Value cannot be null. 
Parameter name: input at System.Text.RegularExpressions.Regex.IsMatch(String input) at 
WebserviceX.Service.Adapter.IPAdapter.CheckIP(String IP) at 
WebserviceX.Service.GeoIPService.GetGeoIP(String IPAddress) --- End of inner exception 
stack trace --- in C:\Program Files (x86)\Apache Software 
Foundation\Apache2.2\htdocs\isolda\test.php:16 Stack trace: #0 C:\Program Files 
(x86)\Apache Software Foundation\Apache2.2\htdocs\isolda\test.php(16): SoapClient-
>__soapCall('GetGeoIP', Array) #1 {main} thrown in C:\Program Files (x86)\Apache 
Software Foundation\Apache2.2\htdocs\isolda\test.php on line 16
  • 写回答

1条回答 默认 最新

  • dstm2014 2012-01-18 21:11
    关注

    You should write "IPAddress" instead of 'IP' (Inside the array) and it will work.

    $client = new SoapClient("http://www.webservicex.net/geoipservice.asmx?wsdl"); 
    
    $result = $client->GetGeoIP(array("IPAddress" => "83.251.30.62")); //change was made here
    
    echo $result->GetGeoIPResult->CountryName;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 为什么我按照电路图做出的仿真和实物都不能使用
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web