foinf Posted June 13, 2014 Report Share Posted June 13, 2014 The pbx_soap() function call shown below is taking way too long to respond. Here's the body of the soap_call has as suggested by the abstract code body given here : https://wiki.snomone.com/index.php?title=Access_to_the_Database#Abstract_Code_to_access_the_pbxnsip_database function pbx_soap($req) { $start = microtime(true); global $dbadr, $dbport, $dbdebug; $dbhandle = fsockopen($dbadr, $dbport, $errno, $errstr); if (!$dbhandle) { echo "error hash"; if($dbdebug) echo "$errstr ($errno)<br>\n"; return; } $request = "POST /soap.xml HTTP/1.1\r\n"; $request .= "Content-Type: text/xml\r\n"; $request .= "Content-Length: " . strlen($req) . "\r\n"; $request .= "Connection: close\r\n\r\n"; $request .= $req; //echo $request; //exit; fputs($dbhandle, $request); $data = ""; $count=0; while(!feof($dbhandle)) { $count++; $data.=fread($dbhandle, 128); } fclose($dbhandle); $pos = strpos($data,"\r\n\r\n"); if($pos != false) { $body = substr($data, $pos); return $body; } } // pbx_soap Every call takes about 6 seconds (As determined by using microtimers.) Also, the following statistics show how much time is being spent on the pbx_soap calls GREATLY slowing down the web apps. Quote Link to comment Share on other sites More sharing options...
Vodia PBX Posted June 14, 2014 Report Share Posted June 14, 2014 That code comes from ancient times. Today you can have PHP do the HTTP client stuff with built-in functions that are much faster, for example http_get. Quote Link to comment Share on other sites More sharing options...
foinf Posted June 16, 2014 Author Report Share Posted June 16, 2014 Hello, thanks for your response. Could you provide a sample code or example or at least a few lines of code which Illustrate how to use the modern technique instead of using SOAP? The documentation (which i have quoted as a link in the OP) only illustrated the call using soap. Quote Link to comment Share on other sites More sharing options...
Vodia PBX Posted June 16, 2014 Report Share Posted June 16, 2014 Well, for POST you cannot use http_get (sorry). But if you take a look e.g. at http://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php you see some sample code on how to POST something with an attachment. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.