I am new to Zend_Soap_Client
. I have the following code as an example, and I try to understand what is behind it. Do I understand correctly that it connects to remote server and reads specified data? Finally, as far as I understand, it is supposed to save these data in test.txt
.
I tried to run this code (I have the necessary certificate). The problem is that no data is saved to test.txt
. So, could someone please explain me this technology or give me a link to a good tutorial on similar topic? In particular, I'm very interested in how to save necessary data to local XML file or array.
P.S. I apologize if I used some incorrect definitions, because as I mentioned at the beginning I'm new to Zend_Soap_Client
and the related technology.
$wsdl = 'tttest.wsdl';
$options = array(
'local_cert' => 'certificate.pem',
'soap_version' => SOAP_1_1
);
$client = new Zend_Soap_Client($wsdl, $options);
$p = array(
'endUserId' => 'demo',
'sendTime' => array('value' => date("Y-m-d H:i:s")),
'eaupId' => array('chainDate' => array('value' => $chaindate), 'sequenceNumber' => 1)
);
$webServices = $client->retrieveEAUPCDRs($p);
$line = $client->getLastResponse();
$line = substr($line, 110);
$line = substr($line, 0, -22);
$xml = simplexml_load_string($line);
$result = $xml->xpath('//@ns3:title | //ns2:beginPosition | //ns2:endPosition | //ns4:upperLimit | //ns4:lowerLimit | //ns8:conditionalRouteType');
$filename = 'test.txt';
if ($fh = fopen($filename, "r")) {
while (!feof($fh)) {
$line = fgets($fh);
if (strlen($line) != 0) {
$chars = explode(";", $line, 5);
$np[$chars[0]] = "$chars[3],$chars[2]";
}
}
fclose($fh);
};
This code does NOT do what you think it is doing.
The first two-thirds (up to and including the call to xpath()
) do connect to a server and grab some information, which is ultimately placed in the $result
variable. However, the last 11 lines do not utilize any of the data from the previous code ($line
is being re-used in the last bit).
Furthermore, fopen()
is being called with the "r" option, which means read-only.
I would recommend spending some time on http://php.net researching the various PHP functions and language constructs that are being used in this code and then visiting the Zend Framework Manual for additional info on Zend_Soap_Client
: http://framework.zend.com/manual/1.12/en/manual.html