Solved

receive XML request and return it using classic ASP

Posted on 2014-02-03
2
1,726 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 53

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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