Here is how I am creating the xml at this time using dom.
Code: Select all
<?php
$dom = new DOMDocument('1.0');
//create root element <book> and append it to the document
$REQUEST_GROUP = $dom->appendChild($dom->createElement('REQUEST_GROUP'));
$REQUEST_GROUP->setAttribute('MISMOVersionID','2.1');
$REQUEST=$REQUEST_GROUP->appendChild($dom->createElement('REQUEST'));
$REQUEST->setAttribute('LoginAccountIdentifier','testuser');
$KEY=$REQUEST->appendChild($dom->createElement('KEY'));
$KEY->setAttribute('_NAME','MemberID');
$KEY->setAttribute('_Value','100');
$REQUEST_DATA=$REQUEST->appendChild($dom->createElement('REQUEST_DATA'));
$CREDIT_REQUEST=$REQUEST_DATA->appendChild($dom->createElement('CREDIT_REQUEST'));
$CREDIT_REQUEST->setAttribute('MISMOVersionID','2.1');
$CREDIT_REQUEST_DATA=$CREDIT_REQUEST->appendChild($dom->createElement('CREDIT_REQUEST_DATA'));
$CREDIT_REQUEST_DATA->setAttribute('CreditRequestID','CRReq0001');
$CREDIT_REQUEST_DATA->setAttribute('BorrowerID','BorRec0001');
$CREDIT_REQUEST_DATA->setAttribute('CreditReportRequestActionType','Submit');
$CREDIT_REQUEST_DATA->setAttribute('CreditReportType','Consumer');
$CREDIT_REQUEST_DATA->setAttribute('CreditRequestType','Individual');
$CREDIT_REPOSITORY_INCLUDED=$CREDIT_REQUEST_DATA->appendChild($dom->createElement('CREDIT_REPOSITORY_INCLUDED'));
$CREDIT_REPOSITORY_INCLUDED->setAttribute('_EquifaxIndicator','N');
$CREDIT_REPOSITORY_INCLUDED->setAttribute('_ExperianIndicator','Y');
$CREDIT_REPOSITORY_INCLUDED->setAttribute('_TransUnionIndicator','N');
$LOAN_APPLICATION=$CREDIT_REQUEST->appendChild($dom->createElement('LOAN_APPLICATION'));
$BORROWER=$LOAN_APPLICATION->appendChild($dom->createElement('BORROWER'));
$BORROWER->setAttribute('BorrowerID','BorRec0001');
$BORROWER->setAttribute('_FirstName','EVPAULA');
$BORROWER->setAttribute('_MiddleName','');
$BORROWER->setAttribute('_LastName','Consumer');
$BORROWER->setAttribute('_SSN','376988419');
$_RESIDENCE=$BORROWER->appendChild($dom->createElement('_RESIDENCE'));
$_RESIDENCE->setAttribute('_StreetAddress','10655 Birch St');
$_RESIDENCE->setAttribute('_City','Burbank');
$_RESIDENCE->setAttribute('_State','Ca');
$_RESIDENCE->setAttribute('_PostalCode','20906');
$dom -> formatOutput = true;
$result= $dom->saveXML();
//echo $result;
?>
I am still getting an error when I post it (I am getting a null returned). I'm trying to figure out is the issue with my post with curl not including information needed to define this as a xml document or a problem with the xml document itself or of course a problem with the server I am sending the info to.
Here is the php curl code
Code: Select all
<?php
/** * Define POST URL and also payload */
require 'createxml.php';
$headers = get_curl_headers();
define('XML_PAYLOAD', '$result');
define('XML_POST_URL','$url');
/** * Initialize handle and set options */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, XML_POST_URL);
curl_setopt($ch, CURLOPT_USERPWD, '$userid:$password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //Don't verify ssl certificate
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
/** * Execute the request and also time the transaction */
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch);
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;
/** * Check for errors */
if ( curl_errno($ch) ){
$result = 'cURL ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
}
else {
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode)
{
case 200:
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
/** * Close the handle */
curl_close($ch);
/** * Output the results and time */
echo 'Total time for request: ' . $totalTime . "\n";
echo $result;
/** * Exit the script */
exit(0);
function get_curl_headers() {
$headers = array();
$headers[] = "Content-Type: text/xml"; //or maybe text/xml
$headers[] = "X-VPS-Timeout: 30";
$headers[] = "X-VPS-VIT-OS-Name: Windows 2003 Server"; // Name of your OS
$headers[] = "X-VPS-VIT-OS-Version: RHEL 4"; // OS Version
$headers[] = "X-VPS-VIT-Client-Type: PHP/cURL"; // What you are using
$headers[] = "X-VPS-VIT-Client-Version: 0.01"; // For your info
$headers[] = "X-VPS-VIT-Client-Architecture: x86"; // For your info
$headers[] = "X-VPS-VIT-Integration-Product: MyApplication"; // For your info, would populate with application name
$headers[] = "X-VPS-VIT-Integration-Version: 0.01"; // Application version
return $headers;
}
?>