繁体   English   中英

如何在php中使用soap将参数发送到wsdl文件

[英]How to send parameters to wsdl file using soap in php

我有一个带位置的wsdl文件,我想通过soap发送请求值,我正在尝试以下情况。 但是它没有调用wsdl函数。 请帮助我如何发送soap请求参数。

<xs:complexType name="wsNotification">
 <xs:sequence>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="notificationList" nillable="true" type="tns:notificationsParam"/>
 </xs:sequence>
</xs:complexType>
<xs:complexType name="notificationsParam">
 <xs:sequence>
  <xs:element minOccurs="0" name="email" type="xs:string"/>
  <xs:element minOccurs="0" name="phone" type="xs:string"/>
 </xs:sequence>
</xs:complexType>

下面的代码我在PHP中使用soap函数调用wsdl

 $client = new SoapClient("http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl", 
                                array('email'       => "test@gmail.com",
                                       'phone'       => "97122555")
                         );
 echo "Response:\n" . $client->__getLastResponse() . "<br>";

当我调用上述soap函数时,我没有从wsdl得到任何响应。 请帮助我如何将参数从php发送到soap。

不知道您是否已经对此有了答案。 但是以前我使用nusoap工具包来实现这一目标。

  1. 下载软件包并将文件放在项目文件夹中
  2. 将库包含在您的代码中

    require_once('lib / nusoap.php');

  3. 写你的代码

查看您的xml可以解决问题

$client=new nusoap_client('http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl', 'wsdl');

$login=array('email'=>'test@gmail.com', 'phone'=>'97122555');
$response= $client->call('notificationsParam', array('parameters' => $login));

if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($response);
echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
    echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {

print_r($response);

}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM