dongyuxiao6295 2013-03-06 13:46
浏览 115

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

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:
" . $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.

  • 写回答

1条回答 默认 最新

  • dongzai3917 2015-11-19 22:03
    关注

    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);
    
    }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度