Solved

receive XML request and return it using classic ASP

Posted on 2014-02-03
2
1,643 Views
Last Modified: 2014-02-04
Hi

Bit of a weird question as I no nothing about ASP but need to alter a bit of code. At present I'm having issues as I cannot see the FULL XML code that is being sent to a page (as its part of a CRM system) so what I want to do is basically grab whatever XML request comes to this page, and return it.

By returning it I can then associate this with a field on the screen which it populates, then a basic right click "view source" should hopefully show me the entire XML

Sounds naff right, but its the only way itll work ;)

This is what I have so far, this returns a single value based on what is sent, how can I simply grab all that is sent and chuck it back?

Full code please as I'm a Java, PHP guy.

<%
	' - no cache -
	Response.Expires = -1000

	' - define variables -
	Dim XMLDoc
	Dim outXml
	Dim fridgeNo
	Dim cost
	Dim ffCost
	Dim totalCost
	Dim priceFridge = 10
			
	' - Load XML -	
	Set XMLDoc = CreateObject("Microsoft.XMLDOM")	
	XMLDoc.load(Request)
	
	' - Read XML and get fridgeNo count -
	Set myNode = XMLDoc.SelectSingleNode("//fridgeNo")
	if myNode.text = "" Then
		fridgeNo = cint(0)
	else
		fridgeNo = cint(myNode.text)
	end if           
			
	' - work out fidge cost -
    if fridgeNo=cdbl(0) Then
        cost = cdbl(cost) + cdbl(0)
        ffCost = cdbl(0)
    else
        cost = cdbl(cost) + (fridgeNo * priceFridge)
        ffCost = (fridgeNo * priceFridge)
    end if

	' - build the XML response -
	XMLDoc.SelectSingleNode("//txtFFCost").Text = FormatNumber(ffCost,2)
	XMLDoc.SelectSingleNode("//txtTotalCost").Text = FormatNumber(cost,2)
	XMLDoc.SelectSingleNode("//fridgeNo").Text = ""
	
	' - trap any errors -
	If XMLDoc.parseError.errorcode <> 0 Then
		Response.write("XML Parse Error Code = " & XMLDoc.parseError.errorcode)
		Response.end
	end if
	
	' - return the XML -
	Response.ContentType = "text/xml"
	Response.write(xmlDoc.xml)
	
	' - bye -
	Set XMLDoc = Nothing
%>

Open in new window


thanks
Neil
0
Comment
Question by:Neil Thompson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39829274
>so what I want to do is basically grab whatever XML request comes to this page, and return it.

Where you have

' - Load XML -	
	Set XMLDoc = CreateObject("Microsoft.XMLDOM")	
	XMLDoc.load(Request)

Open in new window

You should be able to write out that variable.

response.write (Request) ' print to screen
response.end()  ' don't bother with the rest of the code
<%
	' - no cache -
	Response.Expires = -1000

	' - define variables -
	Dim XMLDoc
	Dim outXml
	Dim fridgeNo
	Dim cost
	Dim ffCost
	Dim totalCost
	Dim priceFridge = 10
			
	' - Load XML -	
	Set XMLDoc = CreateObject("Microsoft.XMLDOM")	
	XMLDoc.load(Request)

' ******** new code here **************

response.write(Request)
response.end

' ******* end new code ****************
	
	' - Read XML and get fridgeNo count -
	Set myNode = XMLDoc.SelectSingleNode("//fridgeNo")
	if myNode.text = "" Then
		fridgeNo = cint(0)
	else
		fridgeNo = cint(myNode.text)
	end if           
			
	' - work out fidge cost -
    if fridgeNo=cdbl(0) Then
        cost = cdbl(cost) + cdbl(0)
        ffCost = cdbl(0)
    else
        cost = cdbl(cost) + (fridgeNo * priceFridge)
        ffCost = (fridgeNo * priceFridge)
    end if

	' - build the XML response -
	XMLDoc.SelectSingleNode("//txtFFCost").Text = FormatNumber(ffCost,2)
	XMLDoc.SelectSingleNode("//txtTotalCost").Text = FormatNumber(cost,2)
	XMLDoc.SelectSingleNode("//fridgeNo").Text = ""
	
	' - trap any errors -
	If XMLDoc.parseError.errorcode <> 0 Then
		Response.write("XML Parse Error Code = " & XMLDoc.parseError.errorcode)
		Response.end
	end if
	
	' - return the XML -
	Response.ContentType = "text/xml"
	Response.write(xmlDoc.xml)
	
	' - bye -
	Set XMLDoc = Nothing
%>

Open in new window

The above is just for testing so you can see the entire response.
0
 
LVL 3

Author Closing Comment

by:Neil Thompson
ID: 39834861
superb, thank you works perfectly :)
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Hacked 1 71
Asp response.write to clients 6 34
VB script help 23 32
How to add extra IF statement to a loop in MS Access VBA 3 22
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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