I'm trying to integrate with UPS' Online Tools in order to get shipping rates. The problem I'm running into appears to be specific to ColdFusion 5 as my code runs fine on CF7. Basically, UPS doesn't like my XML when sent via CF5, but it's fine with that same XML when sent via CF7. Unfortunately, this needs to work on CF5 :\
This code fails to return the desired response on CF5... <cfhttp url="#request.getURL()#" method="post"> <cfhttpparam type="formfield" name="data" value="#accessRequestXML##ratingServiceSelectionRequestXML#"> </cfhttp>
...while this code works fine on CF7: <cfhttp url="#request.getURL()#" method="post"> <cfhttpparam type="xml" name="data" value="#accessRequestXML##ratingServiceSelectionRequestXML#"> </cfhttp>
I have a feeling it has something to do CF5's non-existent <cfhttp>/<cfhttpparam> options with regards to content type, character sets, etc.
On Tue, Jun 10, 2008 at 5:49 PM, Ubqtous <ubqt...@gmail.com> wrote:
> Hello all,
> I'm trying to integrate with UPS' Online Tools in order to get > shipping rates. The problem I'm running into appears to be specific to > ColdFusion 5 as my code runs fine on CF7. Basically, UPS doesn't like > my XML when sent via CF5, but it's fine with that same XML when sent > via CF7. Unfortunately, this needs to work on CF5 :\
> This code fails to return the desired response on CF5... > <cfhttp url="#request.getURL()#" method="post"> > <cfhttpparam type="formfield" name="data" > value="#accessRequestXML##ratingServiceSelectionRequestXML#"> > </cfhttp>
> ...while this code works fine on CF7: > <cfhttp url="#request.getURL()#" method="post"> > <cfhttpparam type="xml" name="data" > value="#accessRequestXML##ratingServiceSelectionRequestXML#"> > </cfhttp>
> I have a feeling it has something to do CF5's non-existent > <cfhttp>/<cfhttpparam> options with regards to content type, character > sets, etc.
> Wow, thats a tough one. If it was MX, possibly you could have used the > underlying JAVA. Maybe there's an old cfx tag that would do the trick?
> Sami
> On Tue, Jun 10, 2008 at 5:49 PM, Ubqtous <ubqt...@gmail.com> wrote:
>> Hello all,
>> I'm trying to integrate with UPS' Online Tools in order to get >> shipping rates. The problem I'm running into appears to be specific to >> ColdFusion 5 as my code runs fine on CF7. Basically, UPS doesn't like >> my XML when sent via CF5, but it's fine with that same XML when sent >> via CF7. Unfortunately, this needs to work on CF5 :\
>> This code fails to return the desired response on CF5... >> <cfhttp url="#request.getURL()#" method="post"> >> <cfhttpparam type="formfield" name="data" >> value="#accessRequestXML##ratingServiceSelectionRequestXML#"> >> </cfhttp>
>> ...while this code works fine on CF7: >> <cfhttp url="#request.getURL()#" method="post"> >> <cfhttpparam type="xml" name="data" >> value="#accessRequestXML##ratingServiceSelectionRequestXML#"> >> </cfhttp>
>> I have a feeling it has something to do CF5's non-existent >> <cfhttp>/<cfhttpparam> options with regards to content type, character >> sets, etc.
I suspect that the issue runs deeper than that -- according to the CF
7 docs, the XML type for cfhttpparam does several things that I do not
think are supported in CF 5:
> XML: identifies the request as having a content-type of text/xml. Specifies that the value attribute contains the body of the HTTP request. Used to send XML to the destination URL. ColdFusion does not URL encode the XML data.
In other words, in order to work in the same manner, the HTTP request
in CF 5 must have a content-type of text/xml (with the UTF-8 charset,
as Oğuz indicated), the content must not be URL encoded, and the XML
should comprise the body of the request.
This last item is significant because I do not believe that there is
any way to send a POST in CF 5 that has body content in the proper
format for your needs. The formfield type is not going to work, as it
will send data in URL encoded name-value pairs, e.g.:
data=[URL encoded XML]
So even if you could work around the content-type issue (you can set
values in the CGI scope in place of actual header support, but if CF 5
implements the CGI type in the same way that CF 7 does, then URL
encoding may break content-type values), I don't think your XML data
will arrive at the destination as valid XML.
I think Sami is on the right track, as you will probably need to look
outside CF's core functionality for this task.
I hope that helps,
--
Ezra Parker
On Jun 10, 11:01 pm, Ubqtous <ubqt...@gmail.com> wrote:
> I too have a feeling that this is a charset issue. CF5 uses ISO-8859-1
> while CF7 uses UTF-8, which is probably why my code runs as is on CF7.
> I tried using <cfcontent type="text/html; charset=UTF-8"> to change
> the charset for the page generating and posting the XML, but it had no
> effect.
> On Wed, 11 Jun 2008 00:44:32 -0400, you wrote:
> OD> Be also careful to format all XML output with utf8 charset.
> --
> Ubqtous
> <)) "I Can't Get Behind That!" by Henry Rollins from "Talk Is Cheap
> Vol. 4"
The issue isn't with XML preparation or parsing as far as I can tell, it is with the transmission of the XML to UPS. <cfhttp> on CF5 doesn't provide the means to transmit XML in the necessary manner (text/xml; UTF-8; non-URL-encoded; no name-value pair in the post, just value).