Skip to main content
Inspiring
September 11, 2018
Answered

Sending XML with CFHTTP

  • September 11, 2018
  • 1 reply
  • 3997 views

I have some code that works perfectly well with one customer, but with another it's a total fail. They are telling me that the content type is not being sent.

The goal is to send a XML data to them over SSL/Port 8443

Am I missing something here that some servers react badly to?

<cfparam name="form_timeout" default="5">

<cfparam name="form_port" default="8443">

<cfset objXml = createObject("component","xml2Struct")>

<!--- Request XML--->

<cfxml variable="xmlRequest">

<?xml version="1.0" encoding="UTF-8"?>

<request>

<header>

<signature>BHNUMS</signature>

<details>

<productCategoryCode>01</productCategoryCode>

<specVersion>43</specVersion>

</details>

</header>

<transaction>

<primaryAccountNumber>9877890000000000001</primaryAccountNumber>

<processingCode>615400</processingCode>

<transactionAmount>000000000000</transactionAmount>

<transmissionDateTime>140223183057</transmissionDateTime>

<systemTraceAuditNumber>385224</systemTraceAuditNumber>

<localTransactionTime>103057</localTransactionTime>

<localTransactionDate>140223</localTransactionDate>

<merchantCategoryCode>5411</merchantCategoryCode>

<pointOfServiceEntryMode>011</pointOfServiceEntryMode>

<acquiringInstitutionIdentifier>60300000063</acquiringInstitutionIdentifier>

<retrievalReferenceNumber>000007385224</retrievalReferenceNumber>

<merchantTerminalId>26065     001   </merchantTerminalId>

<merchantIdentifier>60300000063    </merchantIdentifier>

<merchantLocation>Simulation</merchantLocation>

<transactionCurrencyCode>840</transactionCurrencyCode>

<additionalTxnFields>

<productId>07675019009</productId>

<redemptionPin>#form_redemptioncode#</redemptionPin>

</additionalTxnFields>

</transaction>

</request>

</cfxml>

<!---Make a test request --->

<cfhttp url="HTTPS URL OF CUSTOMER HERE" method="post" port="#form_port#" timeout="#form_timeout#">

    <cfhttpparam type="header" name="Accept" value="application/xml" />

    <cfhttpparam type="header" name="Accept-Language" value="en-us,en" />

    <cfhttpparam type="header" name="Accept-Charset" value="utf-8" />

    <cfhttpparam type="header" name="Keep-Alive" value="115" />

    <cfhttpparam type="header" name="Connection" value="keep-alive" />

    <cfhttpparam type="body" value="#xmlRequest#" />

</cfhttp>

<CFOUTPUT>#cfhttp.statuscode#</CFOUTPUT>

This topic has been closed for replies.
Correct answer ACS LLC

Well this is proving to be a bit of a nightmare, I'm now getting a 400 error, so their server can't accept it

They told me they needed Application/xml

So I add the header

<cfhttpparam type="header" name="Content-Type" value="Application/xml" />

So all the headers look like this now

<cfhttpparam type="header" name="Accept" value="application/xml" />

    <cfhttpparam type="header" name="Accept-Language" value="en-us,en" />

    <cfhttpparam type="header" name="Accept-Charset" value="utf-8" />

    <cfhttpparam type="header" name="Keep-Alive" value="115" />

    <cfhttpparam type="header" name="Connection" value="keep-alive" />

    <cfhttpparam type="body" value="#xmlRequest#" />

    <cfhttpparam type="header" name="Content-Type" value="Application/xml" />


I got it!

It did need this

<cfhttpparam type="header" name="Content-Type" value="Application/xml" />

This was incorret

<cfhttpparam type="header" name="Accept" value="application/xml" />

Even though I had fixed it, I had been supplied some bad data, or at least not explained clearly, so once that was fixed it all worked.

Their server was just throwing a 400 status, so it was rather uninformative.

1 reply

WolfShade
Legend
September 11, 2018

There could be several things at play, here.  I do find it odd that you are trying to send SSL/TLS on port 8443.  Typically, SSL/TLS is done on port 443 (reserved).

If your webserver is using only TLS 1.0 or 1.1, and the client browser is restricted to TLS 1.2, that could cause issues.  Conversely, if your webserver is only 1.2 and the client browser isn't set up for 1.2, that could also cause issues.

HTH,

^ _ ^

Community Expert
September 11, 2018

Yeah, the key is to separate these two issues. I'd try sending it manually using a browser and Fiddler to see what's happening. As for the TCP/8443 bit, that's not surprising for internal HTTPS services, it's a pretty standard port for those.

Dave Watts, Fig Leaf Software

Dave Watts, Eidolon LLC
ACS LLCAuthor
Inspiring
September 11, 2018

Yes, this is an internal server to server post. I have a dashboard that I use to push config such as timeout, but that just triggers the CFHTTP port.

Both the customers I am using this with are using 8443, and it's fine with one of them

I did try a hit on the URL with a browser, but it won't connect to the link, I guess because I am not sending XML content

I'm not familiar with fiddler