dourang20110122 2013-09-03 21:08
浏览 51
已采纳

如何获取soapclient函数的响应

foreach ($record_sets as $row) {
    $params->Loginname = "a";
    $params->Password = "xxxxxxx";
    $params->studentresult = "<a1><marks>95</marks><grade>A</grade></a1>"; 
    $params->rollid = $row[0];

    $response = $client->Marksofstudent($params);
    $result = $response->Marksresult->SqlXml->any;

    var_dump($result);    

    /* NEED TO ALERT THE MESSAGE IF SOAP CLIENT FUNCTION RETURNS THE SUCCESS */
} 

When i run this code, it uploads my data. When i var_dump the value it returns string(800) "". When i right click and check the view source , the below xml comes as per success and failure.

It returns the xml like <ROOT ........."><t1><t2 rollid="76" marks="282"/></t1><Transfer><row TransferedrollID="5"/></Transfer></ROOT> when success.

How could i alert to client if its uploads is successfull.

If its error, it returns the xml like '<ROOT ........."><t1><t2 rollid="76" eror="invalid roll number"/></ProcessLog></ROOT>'

I just want to prompt the alert if its the xml is uploaded successfully as the xml comes as explained above and prompt error alert when the xml returned is as second one.

  • 写回答

1条回答 默认 最新

  • douyan1972 2013-09-03 21:12
    关注

    One way to do it is:

    if (strpos($result, 'eror') === false) echo 'Success!';
    

    Another way:

    $xml = new SimpleXMLElement($result);
    if (isset($xml->t1->t2->Transfer->row)) {
      echo 'Success!';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计