I have been arguing with my computer all day. It just doesn't want to do as it's told!
essentially I have been able to build an xml file in the format that I want using simplexml and stick it in a soap header, send it to a server in a post array and get a response. This is a huge victory for me
Code: Select all
$xmlToSend = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SOAP-ENV:Body>' . "\n" .
substr($xml2->asXML(),22) . //XML body
'</SOAP-ENV:Body>' . "\n" .
'</SOAP-ENV:Envelope>';I'm then using CURL to bring the xml response into a variable:
Code: Select all
$ch = curl_init(SOURCE_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlToSend);
$xmlReceived = curl_exec($ch);
curl_close($ch);Code: Select all
$QResponse = new SimpleXMLElement($xmlReceived);
echo "<pre>Premium Returned:" . (string) $QResponse->GrossPremium . "\n";I tried using PHP SOAP earlier but the WS im trying to connect to doesn't like the way the xml is formatted by the soapClient object.
Thanks for reading,
Ben