function addContactToGroup($firstName, $lastName, $email, $groupName) { $request = createRequest('addContactToGroup', array('f' => $firstName, 'l' => $lastName, 'e' => $email, 'g' => $groupName)); return execute($request, 'encodeResult'); }
} $startcoordinate = str_replace(",", " ", $startcoordinate); $endcoordinate = str_replace(",", " ", $endcoordinate); if (strlen($viaPoints_xml) > 0) { $points = explode(" ", $viaPoints_xml); $viaPoints_xml = ""; for ($i = 0; $i < count($points); $i++) { $p = explode(",", $points[$i]); $viaPoints_xml = $viaPoints_xml . "<xls:ViaPoint><xls:Position><gml:Point><gml:pos>" . $p[0] . " " . $p[1] . "</gml:pos></gml:Point></xls:Position></xls:ViaPoint>"; } } else { $viaPoints_xml = ""; } /////////////////////////////////////////////////// //*** Sende Request an Web Service *** $request = createRequest($startcoordinate, $endcoordinate, $viaPoints_xml, $language, $distanceunit, $routepref, $routeprofile, $avoidAreas, $avoidFeatures, $instructions); //Server $http_response = post('openls.geog.uni-heidelberg.de', '/osm/routing', $request, 20, 80); /////////////////////////////////////////////////// //*** Request auswerten *** //Header entfernen $sExplodeParam = '<?xml'; if (strchr($http_response, $sExplodeParam)) { $aResponse = explode($sExplodeParam, $http_response); //Response XML $doc = new DOMDocument(); $doc->loadXML($sExplodeParam . $aResponse[1]); header('Content-Type: text/xml'); echo $sExplodeParam . $aResponse[1]; } } else {
$client = createClient($wsdl, $debug); $client->setLocation($service_url); $header = login($client, $username, $password, $debug); // Iterate through the data. $successCount = 0; $errorCount = 0; $resultArray = array(); $payloadChunks = array_chunk($payload, $logIndex); $chunkCount = 0; $recordCount = 0; foreach ($payloadChunks as $chunk) { $chunkCount++; # Create the XML for the operation/object. $xml = ZuoraAPIHelper::printXMLWithNS($operation, $object, $fieldList, $chunk, $debug, 0, $defaultApiNamespace, $defaultObjectNamespace, false); if ($showRequest) { $soapRequest = createRequest($header->data["session"], $xml); fwrite($lf, "Request:\n"); fwrite($lf, xml_pretty_printer($soapRequest, true) . "\n"); continue; } $result = ZuoraAPIHelper::bulkOperation($client, $header, $operation, $xml, count($chunk), $debug, TRUE, $objectCount); $successCount += $result["successCount"]; $errorCount += $result["errorCount"]; $resultArray[] = $result; $recordCount += count($chunk); // Print a Summary of results fwrite($lf, "Chunk " . $chunkCount . ", " . $recordCount . " records processed: successfully " . $operation . "d " . $result["successCount"] . " out of " . count($chunk) . " ZObjects. Number of errors: " . $result["errorCount"] . ". Total errors: " . $errorCount . "/" . $recordCount . ".\n"); if ($result["errorCount"] > 0) { fwrite($lf, "The following ZObjects failed:\n"); $errorList = $result["errorList"]; for ($i = 0; $i < count($errorList); $i++) {
* <p><b>Institution:</b> University of Heidelberg, Department of Geography</p> * @author Pascal Neis, Enrico Steiger , openrouteservice@geog.uni-heidelberg.de * @version 1.0 2015-02-01 */ include 'CreateAASRequest.php'; include 'ConnectToWebService.php'; /////////////////////////////////////////////////// //*** Request erstellen POST *** if (isset($_GET["position"]) && isset($_GET["minutes"]) && isset($_GET["method"]) && isset($_GET["interval"]) && isset($_GET["routepreference"])) { $position = $_GET["position"]; $minutes = $_GET["minutes"]; $method = $_GET["method"]; $interval = $_GET["interval"]; $routepreference = $_GET["routepreference"]; $position = str_replace(",", " ", $position); $request = createRequest($position, $minutes, $method, $intervall, $routepreferences); /////////////////////////////////////////////////// //*** Sende Request an Web Service *** //Server $http_response = post('openls.geog.uni-heidelberg.de', '/osm/analysis', $request, 20, 80); /////////////////////////////////////////////////// //*** Request auswerten *** //Header entfernen $sExplodeParam = '<?xml'; if (strchr($http_response, $sExplodeParam)) { $aResponse = explode($sExplodeParam, $http_response); //Response XML $doc = new DOMDocument(); $doc->loadXML($sExplodeParam . $aResponse[1]); header('Content-Type: text/xml'); echo $sExplodeParam . $aResponse[1];
function insertRecord($db, $modelName, $record, $roles) { global $config; $request = createRequest($modelName); $request["records"][] = array("values" => array()); if (!checkRequest($db, $request, $record, "insert", $roles)) { return; } fillRequestWithRecords($request, $record); $insertedIDs = insertRows($db, $request, $roles); //insertRowsDynamoDB($request, $roles, $insertedIDs); $insertID = $insertedIDs[0]; if ($modelName == "school") { $querySchoolUser = "******"; $stmt = $db->prepare($querySchoolUser); $stmt->execute(array("insertID" => $insertID, "userID" => $record["userID"])); } if ($modelName === "user" && $config->email->bSendMailForReal) { sendValidationEmails($record); } echo json_encode(array("success" => true, "recordID" => $insertID)); }
public static function bulkOperation($client, $header, $method, $payload, $itemCount, $debug, $htmlOutput = FALSE, $zObjectCap = -1) { global $maxZObjectCount; global $defaultApiNamespaceURL; $result = array("errorList" => array(), "batchList" => array(), "successCount" => 0, "errorCount" => 0); // Only create/update calls are supported. if ($method != "create" && $method != "update" && $method != "delete") { return $result; } $nodeName = "zObjects"; if ($method == "delete") { $nodeName = "ids"; } // Allow control over how many objects are submitted in one call. if ($zObjectCap < 0) { $zObjectCap = $maxZObjectCount; } $soapRequest = createRequest($header->data["session"], $payload); $xml_obj = new SimpleXMLElement($soapRequest); $xml_obj->registerXPathNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); $xml_obj->registerXPathNamespace("ns1", $defaultApiNamespaceURL); $type = $xml_obj->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "/ns1:type"); // Iterate through the list of items, $zObjectCap at a time for ($counter = 0; $counter < $itemCount; $counter += $zObjectCap) { // Identify upper bound for this batch. $lowerBound = $counter + 1; $upperBound = $counter + $zObjectCap; if ($upperBound > $itemCount) { $upperBound = $itemCount; } // Create request for this batch of records. $batchNodes = $xml_obj->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "/ns1:" . $nodeName . "[position()>=" . $lowerBound . " and position()<" . ($upperBound + 1) . "]"); $batchPayload = "\n<ns1:" . $method . ">\n"; if ($method == "delete") { $batchPayload = $batchPayload . " " . $type[0]->asXML() . "\n"; } for ($i = 0; $i < count($batchNodes); $i++) { $batchPayload = $batchPayload . " " . $batchNodes[$i]->asXML() . "\n"; } $batchPayload = $batchPayload . "</ns1:" . $method . ">\n"; print "Batch " . ceil($upperBound / $zObjectCap) . ": submitting ZObjects " . $lowerBound . "-" . $upperBound . " (" . count($batchNodes) . ")..."; $soapRequest = createRequest($header->data["session"], $batchPayload); // Execute the API call. $timeBefore = microtime(true); $batchResponse = ZuoraAPIHelper::callAPIWithClient($client, $header, $soapRequest, $debug); $timeAfter = microtime(true); print " " . ($timeAfter - $timeBefore) . " secs - Done."; if ($htmlOutput) { print "<br/>"; } print "\n"; // Parse through the response. $xml_obj2 = new SimpleXMLElement($batchResponse); $xml_obj2->registerXPathNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); $xml_obj2->registerXPathNamespace("ns1", $defaultApiNamespaceURL); $soapFaultNode = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault"); $resultNodes = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result/ns1:Success | //SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result/ns1:success"); $successCount = 0; $errorCount = 0; if (count($soapFaultNode) > 0) { $errorCount = count($batchNodes); for ($i = 0; $i < count($batchNodes); $i++) { $faultCode = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/faultstring"); $faultMessage = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/detail/Exception"); array_push($result["errorList"], array("index" => $lowerBound + $i, "code" => (string) $faultCode[0], "message" => (string) $faultMessage[0])); } array_push($result["batchList"], array("start" => $lowerBound, "end" => $upperBound, "size" => count($batchNodes), "successCount" => $successCount, "errorCount" => $errorCount)); } else { for ($i = 0; $i < count($resultNodes); $i++) { $resultNode = $resultNodes[$i]; if (strcasecmp($resultNode, "false") == 0) { $errorCodeNodes = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result[position()=" . ($i + 1) . "]/ns1:errors/ns1:Code | //SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result[position()=" . ($i + 1) . "]/ns1:Errors/ns1:Code"); $errorMsgNodes = $xml_obj2->xpath("//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result[position()=" . ($i + 1) . "]/ns1:errors/ns1:Message | //SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:" . $method . "Response/ns1:result[position()=" . ($i + 1) . "]/ns1:Errors/ns1:Message"); $errorCount++; array_push($result["errorList"], array("index" => $lowerBound + $i, "code" => (string) $errorCodeNodes[0], "message" => (string) $errorMsgNodes[0])); } else { $successCount++; } } array_push($result["batchList"], array("start" => $lowerBound, "end" => $upperBound, "size" => count($resultNodes), "successCount" => $successCount, "errorCount" => $errorCount)); } $result["successCount"] += $successCount; $result["errorCount"] += $errorCount; } return $result; }