I got a XML Request format.....
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Action>AddData</Action>
<ID>1234</ID>
<Name>John</Name>
<Phone>4453433334</Phone>
</Root>
How i post this XML request to a application?.
application url : http://servername/appname/enterdata.jsp
How can i make this work using CFHTTP?.
BKBK - 06 Jan 2008 10:49 GMT
You can post it as a string, using cfhttp and cfhttpparam, with cfhttpparam's
type attribute set to formfield or xml.
<!--- sender.cfm --->
<!--- Save xml as string. Avoid space before processing directive --->
<cfsavecontent variable="xmlString"><?xml version="1.0" encoding="UTF-8"?>
<Root>
<Action>AddData</Action>
<ID>1234</ID>
<Name>John</Name>
<Phone>4453433334</Phone>
</Root>
</cfsavecontent>
<!--- post xml string as form field or as text/xml --->
<cfhttp method="post" url="http://127.0.0.1:8500/website/actionPage.cfm">
<cfhttpparam name="xmlString" type="FormField" value="#xmlString#">
<cfhttpparam name="xmlString" type="XML" value="#xmlString#">
</cfhttp>
<!--- actionPage.cfm --->
<cfif isdefined("form.xmlString")><!--- form field --->
<cfset requestedXMLString = form.xmlString>
<cfelse><!--- xml --->
<cfset requestedData = GetHttpRequestData()>
<cfset requestedXMLString = requestedData.content>
</cfif>
Amm85 - 28 Feb 2008 22:37 GMT
do u need <cfoutput> around <cfsavecontent>
</cfsavecontent>?
Do u need <cfoutput> around <cfhttp> </cfhttp>?.
BKBK - 29 Feb 2008 06:27 GMT
> [i]Do you need <cfoutput> around <cfsavecontent>
> </cfsavecontent>?[/i]
No.