Solved

parsing xml and sending a response back

Posted on 2006-06-29
7
256 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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