user2624315
user2624315

Reputation: 327

How to get the response of the soapclient function

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.

Upvotes: 0

Views: 153

Answers (1)

Alex
Alex

Reputation: 1593

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!';
}

Upvotes: 2

Related Questions