I'm trying to integrate a ColdFusion application with a webAPI provided by another company to access their services. Their requirements are that requests should be generated using standard HTTP Posts with the following HTTP Headers:
The sample code they sent on how to access the API are .bat files that call their API via JAVA. Here is one of the .bat files:
I don't see how to do this in ColdFusion. Can anyone tell me how to do this?
I tried this ColdFusion Code that I found on the Internet and inserted sample XML they gave me:
When I use it to try to send the XML, I get this error back from their servers:
Any idea where to go from here? I am apparently their only customer using Coldfusion. Thanks!
- Content-Type: text/XML
- Content-Length: {Length of content}
The sample code they sent on how to access the API are .bat files that call their API via JAVA. Here is one of the .bat files:
Code:
@echo off call classpath.bat java WSClient http://wsdev.THEIRWEBSITE.com/services/v1.2/API.xml
I tried this ColdFusion Code that I found on the Internet and inserted sample XML they gave me:
Code:
<cfsetting enablecfoutputonly="no" showdebugoutput="no" />
<CFSAVECONTENT VARIABLE="strpost">
<?xml version="1.0" encoding="UTF-8"?>
<addNewRecipients xmlns ="http://www.THEIRWEBSITE.com/ws">
<apiVersion>2.7</apiVersion>
<authorization>
<username>MYUSERNAME</username>
<password>MYPASSWD</password>
</authorization>
<recipientDetail>
<firstName>John</firstName>
<lastName>Smith</lastName>
<devices>
<workPhone>
<address>1491830876</address>
<description>Work Phone number</description>
</workPhone>
</devices>
</recipientDetail>
</addNewRecipients>
</CFSAVECONTENT>
<cfoutput>
<CFHTTP URL="http://wsdev.THEIRWEBSITE.com/services/v1.2/" METHOD="post" RESOLVEURL="false">
<CFCONTENT TYPE="text/XML">
<CFHTTPPARAM NAME="xml" TYPE="formfield" VALUE="#strpost#">
</CFHTTP>
</cfoutput>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<title>XML Demo</title>
</head>
<body>
<CFTRY>
<CFOUTPUT>
<strong>received</strong> response from server:
<p></p>
<pre>#cfhttp.header#
#StructKeyList(cfhttp.responseheader)#</pre>
<form><textarea cols="70" rows="20" wrap="off">#cfhttp.filecontent#</textarea></form>
<p></p>
<hr size="1" />
</CFOUTPUT>
<CFCATCH TYPE="any">
<CFTHROW TYPE="display" MESSAGE="can't display" DETAIL="#cfcatch.message#">
</CFCATCH>
<!--- no parse yet --->
<CFCATCH TYPE="xml">
<CFOUTPUT> i have an xml error: <br/><code>#cfcatch.message#<br/>#cfcatch.detail#</code></CFOUTPUT>
</CFCATCH>
<CFCATCH TYPE="display">
<CFOUTPUT>i can't display anything.<br/><code>#cfcatch.message#<br/>#cfcatch.detail#</code></CFOUTPUT>
</CFCATCH>
<CFCATCH TYPE="any">
<CFOUTPUT>
issues with #server#<p></p>
<code>#cfcatch.message#<br />#cfcatch.detail#</code>
</CFOUTPUT>
</CFCATCH>
</CFTRY>
</body>
</html>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<soapenv:faultcode>soapenv:Server.userException</soapenv:faultcode>
<soapenv:faultstring>error: Unexpected end of file after null</soapenv:faultstring>
<soapenv:detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Comment