【问题标题】:SOAP Request Over PHPPHP 上的 SOAP 请求
【发布时间】:2019-04-10 06:52:46
【问题描述】:

我尝试为 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' =&gt; '123456789' 没有传递给 wsdl,我得到了缺少的参数响应。我还使用 SOAP UI 进行了测试,它可以正常工作。对我的 php 代码有任何建议。

谢谢

【问题讨论】:

  • 您的代码行似乎加倍并且顺序错误。首先删除双打,然后按正确的顺序排列。
  • 您好@KIKOSoftware,感谢您的回复,能否请您提供更多详细信息?
  • 您只需要 1 个SoapClient,而不需要 2 个。第一个 $soapclient-&gt;wsGetSubscriberProfileByID() 似乎没有使用,并且有一个未定义的参数。这些都是代码中非常明显的缺陷。如果您没有看到这些,那么创建 SOAP 请求对您来说可能是一个太大的挑战。
  • 嗨@KIKOSoftware,我已经尝试只使用一个SoapClient $client,然后在这里询问并被称为$client-&gt;wsGetSubscriberProfileByID() 我在没有双soapclient 的代码中编辑了有问题的代码
  • 嗯,看起来更好。此 SOAP 请求是否有任何文档?显然你缺少一个参数,文档可以告诉你它们应该是什么。

标签: php soap wsdl soap-client


【解决方案1】:

终于在这段代码中工作了:

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();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多