/** * Generate an Update Request * * @ignore */ public static function generateUpdateRequest(Entity $entity) { /* Generate the UpdateRequest message */ $updateRequestDOM = new DOMDocument(); $updateNode = $updateRequestDOM->appendChild($updateRequestDOM->createElementNS('http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Update')); $updateNode->appendChild($updateRequestDOM->importNode($entity->getEntityDOM(), true)); /* Return the DOMNode */ return $updateNode; }
/** * Parse the results of a RetrieveRequest into a useable PHP object * * @param Client $client * @param String $entityLogicalName * @param String $soapResponse * * @ignore */ private function parseRetrieveResponse(Client $client, $entityLogicalName, $soapResponse) { /* Load the XML into a DOMDocument */ $soapResponseDOM = new DOMDocument(); $soapResponseDOM->loadXML($soapResponse); /* Find the RetrieveResponse */ $retrieveResponseNode = null; foreach ($soapResponseDOM->getElementsByTagName('RetrieveResponse') as $node) { $retrieveResponseNode = $node; break; } unset($node); if ($retrieveResponseNode == null) { throw new Exception('Could not find RetrieveResponse node in XML provided'); } /* Find the RetrieveResult node */ $retrieveResultNode = null; foreach ($retrieveResponseNode->getElementsByTagName('RetrieveResult') as $node) { $retrieveResultNode = $node; break; } unset($node); if ($retrieveResultNode == null) { throw new Exception('Could not find RetrieveResult node in XML provided'); } /* Generate a new Entity from the DOMNode */ $entity = Entity::FromDom($client, $entityLogicalName, $retrieveResultNode); return $entity; }