# Process the data. # Make the API call. $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");
public static function printTemplateWithNS($wsdl, $call, $object, $debug, $offset, $apiNamespace, $objectNamespace) { /* // Handle "delete". if ($call == "delete") { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":delete>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":type>" . $object . "</" . $apiNamespace . ":type>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":ids></" . $apiNamespace . ":ids>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":delete>\n"; return $payload; } // Handle "create"/"update"/"query". $fieldNames = ZuoraAPIHelper::getFieldList($wsdl, $object); if ($call == "query") { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":query>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":queryString>select "; $payload .= "Id"; } else { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":" . $call . ">\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":zObjects xsi:type=\"" . $objectNamespace . ":" . $object . "\">\n"; if ($call == "update") { // Assume zObject base. $payload .= str_repeat(" ", $offset) . " <" . $objectNamespace . ":" . "Id" . "></" . $objectNamespace . ":" . "Id" . ">\n"; } } for ($i = 0; $i < count($fieldNames); $i++) { if ($call == "query") { $payload .= "," . $fieldNames[$i]; } else { $payload .= str_repeat(" ", $offset) . " <" . $objectNamespace . ":" . $fieldNames[$i] . "></" . $objectNamespace . ":" . $fieldNames[$i] . ">\n"; } } if ($call == "query") { $payload .= " from " . $object . "</" . $apiNamespace . ":queryString>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":query>\n"; } else { $payload .= str_repeat(" ", $offset) . " </" . $apiNamespace . ":zObjects>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":" . $call . ">\n"; } return $payload; / /*/ $fieldNames = ZuoraAPIHelper::getFieldList($wsdl, $object); return ZuoraAPIHelper::printXMLWithNS($call, $object, $fieldNames, array(), $debug, $offset, $apiNamespace, $objectNamespace, true); }