Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / February 2008



Tip: Looking for answers? Try searching our database.

How you post XML Request to a webpage?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amm85 - 04 Jan 2008 21:51 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.