PHP SoapClient-异常,我做错了什么?
我最近开始寻找使用 PHP 的 Web 服务调用。 我无法让以下相当简单的代码片段工作,而是 Web 服务返回异常。
<?php
$client = new SoapClient("http://www.webservicex.net/geoipservice.asmx?wsdl");
print($client->__soapCall("GetGeoIP", array('IP' => '83.251.30.62')));
?>
我还尝试了更简单的 $client->GetGeoIP('83.251.30.62');
但它们都产生相同的结果。
我的代码有问题吗? 异常如下:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该编写
"IPAddress"
而不是'IP'
(在数组内),它将起作用。You should write
"IPAddress"
instead of'IP'
(Inside the array) and it will work.