Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML to ASP from SQL to CDONTS

Status
Not open for further replies.

DennisTheMenace

IS-IT--Management
Jul 25, 2001
113
US
I know ASP, SQL and VB Script very well... but have never done anything with ASP receiving XML Data. Here is the scenerio:

I have a software vendor that says his software can send me data via XML to my IIS.

On my IIS I have an existing ASP script that has:
CustID = request("C")
OrderID = request("O")

The script then looks up the customer's e-mail address, and e-mails the cust his order number via CDONTS.

Can we (and how?) have the IIS receive data from a program via XML, process a script, and display nothing (meaning there is no browser, no user, no nothing... just an {get_XMLHttpFormPost} command from the software with the customer id and order id).

I've browsed the many links about XML tutorials, but don't see anything similar to my scenario. Most refer to formatting and displaying.

I posted this same message in the XML Forum without much luck...

Thanks in advance!
-Dennis

=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
You need to know how exactly your data will be arriving.

Take it and stuff it into the microsoft xml parser object and then fetch the values from that object.
 
The proprietary program is executing the following Secondary Process:

{
get_XMLHttpFormPost
(
"http:/"
+"/my_IIS_intranet/script.asp",
"?C="+cust_id
+"&O="+order_id
)
}

>> Take it and stuff it into the
>> microsoft xml parser object
Not too sure what you mean by that?

=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
That looks like a plain QueryString, not XML data.


The following is cut and pasted from Microsoft's XML SDK. It shows how a client (web page in this case) can send XML to IIS. The second part of the example shows an ASP that receives this XML and loads it into the parser. In the second part the parser is only used to save the xml data to a file, but you could instead use it to fetch out the values and use them however you want.
Code:
Example
The following Microsoft® JScript® example posts a DOMDocument containing order information to an Active Server Pages (ASP) page on a server and returns the result as a new XML document.

<script language="JScript">
  function PostOrder(xmldoc)
  {    
    var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
    xmlhttp.Open("POST", "[URL unfurl="true"]http://myserver/orders/processorder.asp",[/URL] false);
    xmlhttp.Send(xmldoc);
    return xmlhttp.responseXML;
  }
</script>
The ASP page on the server loads the posted XML document, processes the order, and builds a resulting XML document.

<%@ language=javascript %>
<% 
   Response.Expires = -1000;
   // Load the posted XML document.
   var doc = Server.CreateObject("Msxml2.DOMDocument.4.0");
   doc.load(Request);
   if (xmlDoc.parseError.errorCode <> 0) {
      var myErr = xmlDoc.parseError;
      alert("You have error " + myErr.reason);
   } else {
      var result = Server.CreateObject("Msxml2.DOMDocument.4.0");
      // Now process the order and build the result document.
      Response.ContentType = "text/xml";
      result.save(Response);
   }
%>

Of course this is of no use to you if you are really using only a QueryString and not XML.
 
How should he be sending it?

Can a sofware package send a QueryString to IIS?? I thought it HAD to be XML - otherwise the asp page requires a browswer - doesn't it??

I guess I'm missing something here....

Is the XML string wrong from the software? Do I need to write my ASP page in a new way?

-Dennis

=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
Is the software is sending a request to IIS that looks like this:

If so that is a plain QueryString... it has nothing to do with XML... You just get the values the same way you would get them from an HTML form with method=GET

You know, something like this:
Var1 = Request.QueryString("C")
Var2 = Request.QueryString("O")

Like you did up in your first post at the top of this thread!


Anything that can talk to port 80 can send an HTTP request. It doesn't have to be a browser. You could do it with Telnet if you really wanted to... just connect to port 80 and start typing it out by hand... if you want to test this then just download the RFC for HTTP and read all about the HTTP protocol, then use HyperTerminal or whatever to connect to the web server and go to town!

Here, I have a better example... you could make an HTML anchor tag ie: <a> that has your querystring embedded in it like this:
<a href=" Here!</a>

See, this is not a submitted form but it is still a querystring....

Well, it is a browser so maybe it isnt actually a better example, but still... all you have to do is send the proper text to TCP/IP port 80 and you are good to go... it doesn't have to be a browser, it could be any old program with a winsock. You can even use the Win32 API to make these network connections.

On the other hand, if this doesn't apply to you and you are definately receiving a string of XML data, then the thing to do is load it into the parser and work with it from there.
 

You could even use netcat if you really wanted to play with things... ;-)



A smile is worth a thousand kind words. So smile, it's easy! :)
 
Sheco... if it simply sends a query string, after it's successful execution, how can I be sure it doesn't leave an open session on the IIS. Should the last 2 lines of the ASP page be
Code:
<%
  ...
session.abandon
response.end
%>

=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
FYI - just found this:
Code:
<%@ EnableSessionState=False %>

Must be the first line

=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top