Solved

receive XML request and return it using classic ASP

Posted on 2014-02-03
2
1,489 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:NeilT
2 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
>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:NeilT
Comment Utility
superb, thank you works perfectly :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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