2013-04-30 131 views
0

我使用php SOAPClient从外部服务器调用数据,并使用soapUI测试并验证了该服务。我的请求似乎正常工作,直到它遇到第四个参数,这是一个字符串(前三个是数字)。我的代码,并要求低于:soapclient请求不完整

$wdsl = "http://ofmpub.epa.gov/WATERSWebServices/SpatialServices?WSDL"; 
$client = new SoapClient($wdsl, array(
           "trace"=>1, 
           "exceptions"=>0)); 
$lat = 46.852783; 
$long = -114.004517; 
$radius = 1; 
$program = '303D'; 

$values = $client->getEntitiesByLatLong($lat,$long,$radius,$program); 

产生的请求:

<?xml version="1.0" encoding="utf-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ofmpub.epa.gov/WATERSWebServices/SpatialServices.wsdl"> 
    <SOAP-ENV:Body> 
    <ns1:getEntitiesByLatLong> 
     <latitude>46.852783</latitude> 
     <longitude>-114.004517</longitude> 
     <searchRadiusMiles>1</searchRadiusMiles> 
     <programsList /> 
    </ns1:getEntitiesByLatLong> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

相信该服务在这里期待一个字符串。有什么我做了错误的代码?

+0

通过文档回过头来看,它看起来像它期待字符串数组,所以我已将$ program更改为:array('303D');.标签显示为完整: 303D,但没有响应。 – user2305316 2013-04-30 00:58:48

回答

0

如果我没有记错,您需要将一个数组或对象传递给soap客户端方法调用。 即

$data = array('latitude' => 46.852783, 'longitude' => -114.004517, ...); 
$values = $client->getEntitiesByLatLong($data); 

从来自物体的阵列或属性的密钥&值相应地映射到XML节点。

对SOAP客户端对象,你可以请求XML &实际上看到什么是网络线路上的传输(使用getLastRequest())php soap client