protected function action_soap($cache_name, $headers = false, $content = false) { if (!$content) { $content = file_get_contents("php://input"); } if (!$content || !($req_doc = new DOMDocument("1.0", "UTF-8")) || !$req_doc->loadXML($content) || !($xpath = new DOMXPath($req_doc)) || !$xpath->registerNamespace('soap', 'http://www.w3.org/2003/05/soap-envelope') || !$xpath->registerNamespace('wsa', 'http://www.w3.org/2005/08/addressing') || !$xpath->registerNamespace('csd', 'urn:ihe:iti:csd:2013') || !($results = $xpath->query('/soap:Envelope/soap:Body/csd:getModificationsRequest/csd:lastModified')) instanceof DOMNodeList || !($results->length == 1) || !($item = $results->item(0)) instanceof DOMElement || !($mod_time = $item->textContent) || !($results = $xpath->query('/soap:Envelope/soap:Header/wsa:MessageID')) instanceof DOMNodeList || !($results->length == 1) || !($item = $results->item(0)) instanceof DOMElement || !($msg_id = $item->textContent)) { I2CE::raiseError("Invalid request"); //NEED TO ADD IN ERROR HANDLING ACCORDING TO SPEC return false; } try { $csd_cache = new iHRIS_CSDCache($cache_name); } catch (Exception $e) { return false; } if (!is_array($headers)) { $headers = array('Content-Type: text/xml'); } foreach ($headers as $header) { header($header); } $pre = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:csd="urn:ihe:iti:csd:2013"> <soap:Header> <wsa:Action soap:mustUnderstand="1" >urn:ihe:iti:csd:2013:GetDirectoryModificationsResponse</wsa:Action> <wsa:MessageID>urn:uuid:' . iHRIS_UUID_Map::generateUUID() . '</wsa:MessageID> <wsa:To soap:mustUnderstand="1"> http://www.w3.org/2005/08/addressing/anonymous</wsa:To> <wsa:RelatesTo>' . $msg_id . '</wsa:RelatesTo> </soap:Header> <soap:Body> <csd:getModificationsResponse xmlns:csd="urn:ihe:iti:csd:2013"> '; $post = '</csd:getModificationsResponse> </soap:Body> </soap:Envelope>'; $csd_cache->streamCache(false, $mod_time, array(), $pre, $post); exit(0); }