Solved

parsing xml and sending a response back

Posted on 2006-06-29
7
254 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
ID: 17013293
oh we are still on cold fusion server 4.5...
0
 

Author Comment

by:sagardeo
ID: 17019035
anybody? :)
0
 

Author Comment

by:sagardeo
ID: 17019307
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Accepted Solution

by:
cyrk earned 500 total points
ID: 17022348
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
ID: 17033869
>>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
ID: 17100758
decided to just use the following:

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

Author Comment

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

Featured Post

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

929 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

10 Experts available now in Live!

Get 1:1 Help Now