SOAP请求PHP

问题描述 投票:0回答:1

我尝试创建SOAP wsdl的请求,请求的请求和响应是:

SOAP请求:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sub="http://subscriberprovisioning.ws.nvsmx.domain.com/">
<soap:Header/><soap:Body>
<sub:wsGetSubscriberProfileByID><subscriberID>123456789</subscriberID><alternateID></alternateID><parameter1></parameter1><parameter2></parameter2>
</sub:wsGetSubscriberProfileByID></soap:Body></soap:Envelope>

响应

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:wsGetSubscriberProfileByIDResponse xmlns:ns2="http://subscriberprovisioning.ws.nvsmx.domain.com/">
<return><responseCode>200</responseCode><responseMessage>SUCCESS</responseMessage><subscriberProfile>
<entry><key>SUBSCRIBER_IDENTITY</key><value>123456789</value></entry>
</subscriberProfile></return></ns2:wsGetSubscriberProfileByIDResponse></soap:Body></soap:Envelope>

我使用php来创建代码看起来像这样的请求:

request.php

<?php

$client = new SoapClient("http://ipnumber:1988/services/Subscriber?wsdl"); 





$param = array('subscriberId' => '123456789');
$response = $client->wsGetSubscriberProfileByID    ($param);

var_dump($response);

在上面的代码中,'subscriberId' => '123456789'没有传递给wsdl,我得到了缺少的参数响应。我也使用SOAP UI测试,它工作。我的PHP代码的任何建议。

谢谢

php soap wsdl soap-client
1个回答
0
投票

最后它在这段代码中工作:

try{
$soapclient = new SoapClient('http://ipnumber:1988//services/Subscriber?wsdl');
$param=array('subscriberID'=>'123456789');
$response =$soapclient->wsGetSubscriberProfileByID($param);
var_dump($response);
echo '<br><br><br>';
$array = json_decode(json_encode($response), true);
print_r($array);
 echo '<br><br><br>';
      echo '<br><br><br>';
    foreach($array as $item) {
        echo '<pre>'; var_dump($item);
    }  
}catch(Exception $e){
    echo $e->getMessage();
}
© www.soinside.com 2019 - 2024. All rights reserved.