Hi all,
I am having problems with posting XML to a server using the CFHTTP tag. The XML is
stored in a seperate file which is read into the code and then posted to the server
using CFHTTP. When I run the code, I get an error from the program at the other end.
It basically says that it is getting invalid XML and gives line 0, position 0 as a
reference. The first line of the xml is the xml header, but when I remove that and
sent the schema without it, I get the exactly the same error. This leads me to think
that the program is being called, but not getting the data which I am sending.
This points me towards the CFHTTPPARAM command as a possible source of the error.
In particular, I am wondering if the name attribute should be set to anything
specific. My understanding is that the CFHTTP post is similar to a form post and the
name is the equivolent to the name of the field which the XML server is to search for
data in. I'm assuming that this is probably not the case otherwise the Datacash docs
would have mentioned it. But just in case, I set the name to the name of the root
schema.
<CFSETTING ENABLECFOUTPUTONLY="No">
<CFSET DataCashTestServerPort = "443">
<CFSET DataCashTestServerURL =
"https://testserver.datacash.com/Transaction">
<CFSET XMLtemplateFile = GetDirectoryFromPath(GetTemplatePath()) &
"xml.dat">
<CFSET XMLDataString = "">
<CFFILE ACTION="READ" FILE="#XMLtemplateFile#" VARIABLE="XMLDataString">
<CFHTTP URL="https://testserver.datacash.com/Transaction" METHOD="POST"
PORT="#DataCashTestServerPort#" RESOLVEURL="true">
<CFHTTPPARAM TYPE="text/xml" NAME="Request"
VALUE="#Trim(XMLDataString)#">
</CFHTTP>
<CFOUTPUT>#cfhttp.filecontent#</CFOUTPUT>
<CFSETTING ENABLECFOUTPUTONLY="No">
The XML file is as follows.This was copied from Datacashs own example (authentication
details changed to protect the innoce...guilty)...
<?xml version="1.0" encoding="UTF-8"?>
<Request>
<Authentication>
<password>??????</password>
<client>?????????<client>
</Authentication>
<Transaction>
<TxnDetails>
<merchantreference>1222256</merchantreference>
<amount currency='USD'>313.37</amount>
</TxnDetails>
<CardTxn>
<method>pre</method>
<Card>
<pan>4242424242424242</pan>
<expirydate>03/05</expirydate>
</Card>
</CardTxn>
</Transaction>
</Request>
And the response that I get returned from their test server is....
<?xml version="1.0" encoding="UTF-8" ?>
- <Response>
<reason>Invalid XML</reason>
<status>60</status>
<information>Parse XML failed - syntax error at line 1, column 0, byte 0</information>
</Response>
Thanks in advance
Martin L. Gill, MSc - Head Programmer
For & on Behalf of UniTech
(The Universal Information Technology Group Ltd)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
URL: http://www.unitech.net
Email: [EMAIL PROTECTED]
UniTech House, 25 Bernard Street, Leith, Edinburgh, EH6 6SH
Tel: +(44) 0131 472 5555
DDI: +(44) 0131 472 5560
Fax: +(44) 0131 472 5556
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]