Pass server side variable back to datatable page

Pass server side variable back to datatable page

lincolncbennettlincolncbennett Posts: 25Questions: 11Answers: 1

Hi, I am using postEdit event on serverside url to send a SOAP request to a web service which returns a response.

Response:

$return = simplexml_load_string($response_xml);

After the editor has submitted the data I am wanting to open an alert on the editor page with the response ($return) inside.

I am just wondering what the best way is to do this?

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    You could do it in postSubmit, but I'd actually suggest using the browser's "Network" inspector instead. The instructions at this tech note show how you get see the return from the server (even if that specific error message might not apply to you).

    Allan

  • lincolncbennettlincolncbennett Posts: 25Questions: 11Answers: 1

    Hi Allan, thanks for your reply.
    My problem is that I am trying to return the Soap request from the Server side page either to the Network inspector or an alert on the editor page just for testing purposes. Just to clarify I am using 2 pages, an editor page and server side page. My process is as follows;

    I open editor and complete fields, then submit editor. On server side page I am using postEdit event to submit Soap request to a web service using the data passed in editor. the web service is then returning the soap response ie. success or error message with extensive detail. I am just wanting to see the response from the web service either in alert or in the Network inspector.

    Here is my postEdit code. I am saving a couple of the response elements to a database already but I am just after a way to view entire $response = curl_exec($ch) from the editor page so I can fix any validation errors with the request.

     ->on('postEdit', function ($editor, $id, $values, $row){ 
    
      
     error_reporting(E_ERROR | E_PARSE);
          
         
          $soapURL = 'https://lifelinkPreProd.bdm.nsw.gov.au/lifelink/b2b/statusQuery.wsdl';
          $soapUser = 'email';
          $soapPassword = 'passcode';
    
    
     $xml_post_string = '...the soap string with data values from editor';
    
     $headers = array(
                        "Content-type: text/xml;charset=\"utf-8\"",
                        "Accept: text/xml",
                        "Cache-Control: no-cache",
                        "Pragma: no-cache",
                        "SOAPAction: ".$soapURL,
                        "Content-length: ".strlen($xml_post_string),
                    );
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_URL, $soapURL);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); 
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); 
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
       $response = curl_exec($ch);
        //curl_close($ch);
       $response_xml = str_replace("<SOAP-ENV:Body>","", $response);
       $response_xml = str_replace("</SOAP-ENV:Body>","", $response_xml);
       $return = simplexml_load_string($response_xml);
       $value = (string) $return->lodgeWithCertificateResponseType->Notification->Id;
       $status = (string) $return->lodgeWithCertificateResponseType->Notification->Status;
    
    
    $servername = "localhost";
    $username = "root";
    $password = "root";
    $dbname = "company";
    
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    
    $sql = "UPDATE importtest SET NotificationID='$value', Status='$status' WHERE GalleryID='{$values['importtest']['GalleryID']}'";
    
    if ($conn->query($sql) === TRUE) {
        $conn->close();
    } else {
        echo "Error updating record: " . $conn->error;
    }
    
    $conn->close();
    
       
         })
    
  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    I'm afraid I don't quite understand - the "Network Inspector" in your browser should show the response from the server.

    Could you give me a link to your page so I can take a look please?

    Thanks,
    Allan

This discussion has been closed.