Solved

parsing xml and sending a response back

Posted on 2006-06-29
7
253 Views
Last Modified: 2013-12-24
another server is sending our server xml. for now i just want to find out how to receive that xml and send a response back saying "i got it" by sending back this line.

<?xml version="1.0" encoding="iso-8859-1"?><status><result>success</result></status>

so using the following code to try and do that, i am getting a "The system cannot locate the resource specified" error on the last line (i.e <cfset xmlHTTP.send(xmlDoc2)>)

any idea why it can't find it?


<!-- RETRIEVE XML FROM OTHER SERVER -->
<cfset xml = url.xmlToPass>

<cfobject name="xmlDoc" class="msxml.domDocument" action="create" type="COM">

<cfset xmlDoc.async="False">

<cfset xmlDoc.loadXML(xml)>

<cfset ParseErr = xmlDoc.parseError>

<cfoutput><b>#ParseErr.errorCode#</b><br /><b>#ParseErr.reason#</b></cfoutput>


<!-- SEND XML RESONSE BACK TO OTHER SERVER -->

<cfset xml2="<?xml version='1.0' encoding='iso-8859-1'?><status><result>success</result></status>">

<cfobject name="xmlDoc2" class="msxml.domDocument" action="create" type="COM">

<cfset xmlDoc2.async="False">

<cfset xmlDoc2.loadXML(xml2)>

<cfset ParseErr2 = xmlDoc2.parseError>
<cfoutput><b>#ParseErr2.errorCode#</b><br /><b>#ParseErr2.reason#</b></cfoutput>

<cfobject name="xmlHTTP" class="Microsoft.XMLHTTP" action="create" type="COM">


<cfset xmlHTTP.open("POST", "http://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#", false)>
 
<cfset xmlHTTP.setRequestHeader("Method","POST")>
<cfset xmlHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")>
<cfset xmlHTTP.setRequestHeader("Content-Length", 180)>
<cfset xmlHTTP.setRequestHeader("Version","HTTP/1.0")>

     
<cfset xmlHTTP.send(xmlDoc2)>
0
Comment
Question by:sagardeo
  • 6
7 Comments
 

Author Comment

by:sagardeo
Comment Utility
oh we are still on cold fusion server 4.5...
0
 

Author Comment

by:sagardeo
Comment Utility
anybody? :)
0
 

Author Comment

by:sagardeo
Comment Utility
i found the following code, would this work? i'm a bit confused about the last line, shouldn't it be -> xmlhttp.Send(xml)



<script language="JavaScript1.2">
<!--
function sendXMLResponse()
{ var xml = "<?xml version='1.0' encoding='iso-8859-1'?><status><result>success</result></status>"
 var blah = new ActiveXObject("msxml.domDocument")
 blah.loadXML(xml)
 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
 xmlhttp.Open("POST", "https://www.website.com", false)
 xmlhttp.setRequestHeader("Method","POST")
 xmlhttp.setRequestHeader("Content-Length", 180)
 xmlhttp.setRequestHeader("Version","HTTP/1.0")
 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
 xmlhttp.Send("<some>asdf</some>")
}
//-->
</script>
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 3

Accepted Solution

by:
cyrk earned 500 total points
Comment Utility
I don't really understand what you are doing after the first cfobject..why do you need that?

I'm not really sure, but worth a try..

<cfset xml2="<?xml version='1.0' encoding='iso-8859-1'?><status><result>success</result></status>">
<cfobject name="xmlDoc2" class="msxml2.ServerXMLHTTP.3.0" action="create" type="COM">

<cfset xmlDoc2.open("POST", "http://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#", false)>
 
<cfset xmlDoc2.setRequestHeader("Method","POST")>
<cfset xmlDoc2.setRequestHeader("Content-Type","application/x-www-form-urlencoded")>
<cfset xmlDoc2.setRequestHeader("Content-Length", 180)>
<cfset xmlDoc2.setRequestHeader("Version","HTTP/1.0")>

<cfset xmlDoc2.send(xml2)>
0
 

Author Comment

by:sagardeo
Comment Utility
>>I don't really understand what you are doing after the first cfobject..why do you need that?

I am trying to send a xml response back to that other sever..

specifically, i am trying to send back:

<?xml version='1.0' encoding='iso-8859-1'?><status><result>success</result></status>

is there a better way to do this?

the part that says:

#CGI.SERVER_NAME##CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#"

is suppose to the url of that other server..
0
 

Author Comment

by:sagardeo
Comment Utility
decided to just use the following:

http://www.activsoftware.com/xml/xmlparser/
0
 

Author Comment

by:sagardeo
Comment Utility
our server shows that it support php so maybe i'll have the response sent back using php.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now