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

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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的
  • ¥15 硬件IIC从模式的数据发送,中断数据的接收,不能用HAL库(按照时序图)
  • ¥20 QAxWidget上显示一个word文档后,如何直接在该QAxWidget上修改和保存word文档
  • ¥15 Simulink仿真报错,请问如何解决
  • ¥20 宝塔面板无法添加Node项目,一直处于正在添加脚本页面