简体   繁体   English

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

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

I have a wsdl file with location, i want to send the request value through soap, i am trying the below scenario. 我有一个带位置的wsdl文件,我想通过soap发送请求值,我正在尝试以下情况。 But its not calling the wsdl function. 但是它没有调用wsdl函数。 Kindly help me how to send soap request parameter. 请帮助我如何发送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>

Below code i am using in php to call wsdl using soap function 下面的代码我在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>";

I am not getting any response from wsdl when i call the above soap function. 当我调用上述soap函数时,我没有从wsdl得到任何响应。 Kindly help me how to send parameters from php to soap. 请帮助我如何将参数从php发送到soap。

Not sure if you already have an answer to this. 不知道您是否已经对此有了答案。 But previously I used the nusoap toolkit to achieve this. 但是以前我使用nusoap工具包来实现这一目标。

  1. download the package and place the files in your project folder 下载软件包并将文件放在项目文件夹中
  2. include the library in your code 将库包含在您的代码中

    require_once('lib/nusoap.php'); require_once('lib / nusoap.php');

  3. write your code 写你的代码

Looking at your xml this could do the trick 查看您的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