Web service need to save XML to a file
- October 30, 2009
- 1 reply
- 3861 views
Hi,
I use a web service (use to be CFTTP and was working fine thanks to Ian Skinner) for a VIN decoder (Vehicle Identification Number) they charge per request and i can get all the car options in 3 language, they provided me with the CFM file i need to do the request and i got that part to work fine. but i need to save the XML result so i can have all the options on our server and not having to request it everytime we need to see it.
So this is the CFM that gets the vin from the web service. I need to know if it is possible to get the XML out of there and save it to a file.
<cffunction name="isNull" returntype="string" output="false">
<cfargument name="test" type="variableName" required="Yes">
<cfif isDefined(test)>
<cfreturn Evaluate(test)>
<cfelse>
<cfreturn "">
</cfif>
</cffunction>
<cfscript>
webService = createObject("webservice", "MY_VIN_WS");
countryCode = "US";
languageCode = "en";
if( IsDefined("url.countryCode") ){
countryCode = url.countryCode;
} else {
countryCode = "US";
}
if( IsDefined("url.languageCode") ){
languageCode = url.languageCode;
} else {
languageCode = "en";
}
if( languageCode EQ "es" AND countryCode EQ "CA" ){
languageCode = "en";
}
if( languageCode EQ "fr" AND countryCode EQ "US" ){
languageCode = "en";
}
accountInfo = StructNew();
accountInfo.accountNumber = "MY_ACCOUNTx";
accountInfo.accountSecret = "MY_PASSWORD";
accountInfo.locale = StructNew();
accountInfo.locale.language = languageCode;
accountInfo.locale.country = countryCode;
version = "";
dataVersionsRequest = StructNew();
dataVersionsRequest.accountInfo = accountInfo;
dataVersions = webService.getDataVersions(dataVersionsRequest);
for (i = 1; i LTE ArrayLen(dataVersions); i=i+1) {
if (dataVersions.country EQ "US"){
version = dataVersions.country & " " & dataVersions.build & " (" & DateFormat(dataVersions.date) & " " & TimeFormat(dataVersions.date) & ")";
}
}
</cfscript>
<cfif IsDefined("url.vin")>
<cfscript>
returnParameters = StructNew();
returnParameters.useSafeStandards = IsDefined("url.useSafeStandards");
returnParameters.excludeFleetOnlyStyles = IsDefined("url.excludeFleetOnlyStyles");
returnParameters.includeAvailableEquipment = IsDefined("url.includeAvailableEquipment");
returnParameters.includeExtendedDescriptions = IsDefined("url.includeExtendedDescriptions");
returnParameters.includeExtendedTechnicalSpecifications = IsDefined("url.includeExtendedTechnicalSpecifications");
returnParameters.includeRegionSpecificStyles = IsDefined("url.includeRegionSpecificStyles");
returnParameters.includeConsumerInformation = IsDefined("url.includeConsumerInformation");
returnParameters.enableEnrichedVehicleEquipment = false;
vinRequest = StructNew();
vinRequest.accountInfo = accountInfo;
vinRequest.vin = url.vin;
vinRequest.manufacturerModelCode = url.manufacturerModelCode;
vinRequest.trimName = url.trimName;
vinRequest.wheelBase = val("url.wheelBase");
vinRequest.manufacturerOptionCodes = ListToArray(url.manufacturerOptionCodes, ",");
vinRequest.equipmentDescriptions = ListToArray(url.equipmentDescriptions, ",");
vinRequest.secondaryEquipmentDescriptions = ListToArray(url.secondaryEquipmentDescriptions, ",");
vinRequest.exteriorColorName = url.exteriorColorName;
vinRequest.returnParameters = returnParameters;
vehicleInfo = webService.getVehicleInformationFromVin(vinRequest);
showInstallCause = IsDefined("url.includeCauseChain");
</cfscript>
</cfif>
I also attach the entire file if you need to see it
Help would be greatly appreciated
