Read XML from an HTTP POST

First, let’s see how you can post XML over HTTP to another page. This is very simple in ColdFusion:

<cfhttp url="url_to_post_to" method="post">
   <cfhttpparam 
        type="XML" 
        name="XmlDoc" 
        value="#your_xml#">
</cfhttp>

Now, suppose you are posting the XML to a ColdFusion page. How would you read the XML from the HTTP POST body? Again, this is very simple in ColdFusion:

<cfset docContent = GetHTTPRequestData().content>
<cfset myDOM = XmlParse(docContent)>

and now you can manipulate the XML DOM, stored in myDOM, in any way you like.

<cfhttp> documentation
GetHTTPRequestData documentation
ColdFusion XML documentation


Possibly related:


Tagged , | Comments Closed | Trackbacks Closed