From: rboudwin on
I'm not sure if I understand XML well enough to communicate this clearly. The
initial CFXML that I sent appears to be working without errors. I dump out the
XML string and output the string as you suggested. This shows the xml
information that is submitted via a cfhttp post. There should be a response
from the place that the xml post is sending to with a returned xml response.
I'm not sure how to read the returned xml response from authorizenet showing if
it was approved or had an error. I've attached my complete code to make it
easier to understand.

I'm not sure what to do after I submit it to get the response xml back (not
what I sent).

<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">

<merchantAuthentication>
<name>#admin.APIloginID#</name>
<transactionKey>#admin.transactionKey#</transactionKey>
</merchantAuthentication>

<subscription>
<name>#form.x_bank_acct_name#</name>
<paymentSchedule>
<interval>
<length>#admin.length#</length>
<unit>#admin.unit#</unit>
</interval>
<startdate>#variables.startdate#</startdate>
<totalOccurrences>#admin.totalOccurrences#</totalOccurrences>
<trialOccurrences>#admin.trialOccurrences#</trialOccurrences>
</paymentSchedule>
<amount>#admin.amount#</amount>
<trialAmount>#admin.trialamount#</trialAmount>
<payment>
<creditCard>
<cardNumber>#form.x_card_num#</cardNumber>
<expirationDate>#form.x_month##form.x_year#</expirationDate>
</creditCard>
</payment>
<order>
<invoiceNumber>#order.orderid#</invoiceNumber>
<description>#admin.description#</description>
</order>
<customer>
<email>#order.x_email#</email>
</customer>
<billto>
<firstName>#variables.firstname#</firstName>
<lastName>#variables.lastname#</lastName>
</billto>
<shipto>
<firstName>#order.x_ship_to_first_name#</firstName>
<lastName>#order.x_ship_to_last_name#</lastName>
<address>#order.x_ship_to_address#</address>
<city>#order.x_ship_to_city#</city>
<state>#order.x_ship_to_state#</state>
<zip>#order.x_ship_to_zip#</zip>
<country>#order.x_ship_to_country#</country>
</shipto>

</subscription>

</ARBCreateSubscriptionRequest>

</cfoutput>
</cfxml>


<cfdump var="#xmlString#">

<cfhttp URL="https://api.authorize.net/xml/v1/request.api" method="post">
<cfhttpparam name="xmlString" value="#xmlString#" type="xml">
</cfhttp>

<cfoutput>#cfhttp.fileContent#</cfoutput>

From: rboudwin on
Thanks for your replies. I see why I wasn't "seeing" my response. I was
getting an error, "connection failure." I'm beginning to believe it's to do
with cfhttp. So . . . this is taking much more time than it should. Anyone
else having trouble connecting with cfhttp?

From: Ian Skinner on
So . . . this is taking much more time than it should. Anyone
else having trouble connecting with cfhttp?

No, I have used cfhttp just fine. What happens if you go to that URL in
a browser?

One thing that looks odd to me. You are using <cfxml...>. This creates
an XML OBJECT, not a STRING, in the CF memory. You are not going to be
able to pass an OBJECT like this through an HTTP Post parameter. You
could use the toString() function to convert that object to a string.

A better solution my be to use the <cfsavecontent var="xmlString"> tag
instead of the <cfxml...> tag. This tag creates a string by default.
Other then this, it has a second advantage over the <cfxml...> tag in
that you can use different <?xml ... ?> prolog. With the <cfxml...>
tag, a standard prolog is used and it can not be easily changed, if one
wants to use a different one. Of course, if one wants this string to
become an object on the cf server one would use the xmlParse() function.


From: rboudwin on
CFXML and cfsavecontent are unfamiliar territory for me. Thank you for guiding
me.

I'm still getting the same error, "Connection failure." I have to think it
is something basic that I'm missing.



<cfsavecontent variable="myXML"><cfoutput><?xml version='1.0'
encoding='UTF-8'?>

<XML Code goes here>

</cfsavecontent>

<cfset stringXML = tostring(#myXML#)>
<cfhttp method="post" url="https://api.authorize.net/xml/v1/request.api">
<cfhttpparam type="XML" name="XMLUpload" value="#stringXML#">
</cfhttp>

<cfoutput>#cfhttp.FileContent#</cfoutput>

From: Ian Skinner on
CFXML and cfsavecontent are unfamiliar territory for me. Thank you for
guiding me.

<cfsavecontent variable="myXML"><cfoutput><?xml version='1.0'
encoding='UTF-8'?>
<XML Code goes here>
</cfsavecontent>

<cfset stringXML = tostring(#myXML#)>

I can see that. You are still incorrectly matching functions.
<CFXML...> creates a ColdFusin XML object. You would use the
toString(xmlOjbect) if you wanted a string representation of that object.

<cfsaveContent ...> Creates a String, xml or otherwise. You would use
xmlParse() of an xml string if you wanted an object.

An experiment for some edification.

<cfxml variable="aVar">
<root>
<node>A</node>
<node>B</node>
</root>
<cfxml>

<cfdump var="#AVar#">

<cfoutput>#toString(aVar)#</cfoutput>

<cfsaveContent variable="bVar">
<root>
<node>A</node>
<node>B</node>
</root>
</cfsaveContent>

<cfoutput>#bVar#</cfoutput>

<cfdump var="#xmlParse(bVar)#">


For the other potential issue, are you sure the CF server can access
that url resource. That there is no firewall, proxy or other security
layer preventing access.

What happens if you put 'https://api.authorize.net/xml/v1/request.api'
in the the location bar of your favorite browser? What happens if you
do this from the CF server? Assuming you have direct access to the CF
server.