简体   繁体   中英

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. But its not calling the wsdl function. Kindly help me how to send soap request parameter.

<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

 $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. Kindly help me how to send parameters from php to soap.

Not sure if you already have an answer to this. But previously I used the nusoap toolkit to achieve this.

  1. download the package and place the files in your project folder
  2. include the library in your code

    require_once('lib/nusoap.php');

  3. write your code

Looking at your xml this could do the trick

$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);

}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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