Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 25th, 2003, 02:40 PM
Authorized User
 
Join Date: Jun 2003
Location: São Paulo, São Paulo, Brazil.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default XMLHTTP

With ASP

//Client (To ASP and ASP .Net)
var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
oXMLHTTP.open('POST', sHRef, false)
oXMLHTTP.send(sXML);

//Server
Set oXML = Server.CreateObject("MSXML.DOMDocument")
oXML.load(Request)

Using ASP that's all right, but in ASP .Net I can't request data in server side.
If anybody can help...please...


Tanks!
Fabio Ferreira Balota

Fabio Ferreira Balota
__________________
Fabio Ferreira Balota
  #2 (permalink)  
Old June 25th, 2003, 03:35 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In ASP.NET, expose data through Web Service, which return an XML document:

<WebMethod()>
Public Function HelloWorld() As String
    HelloWorld = "Hello World"
End Function

this return an XML like:
<string>Hello World</string>

then you can use the same client code to get the data
Hope this help.

Khoa Nguyen
  #3 (permalink)  
Old June 27th, 2003, 07:52 AM
Authorized User
 
Join Date: Jun 2003
Location: São Paulo, São Paulo, Brazil.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't understand your comments.
My problem is request the XML posted by the client using XMLHTTP.
How Do I request XML posted by the client using XMLHTTP???



Quote:
quote:Originally posted by tknguyen
 In ASP.NET, expose data through Web Service, which return an XML document:

<WebMethod()>
Public Function HelloWorld() As String
    HelloWorld = "Hello World"
End Function

this return an XML like:
<string>Hello World</string>

then you can use the same client code to get the data
Hope this help.

Khoa Nguyen
Fabio Ferreira Balota
  #4 (permalink)  
Old June 27th, 2003, 06:03 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is 2 types of client codes:

1) client code run from browser (same as your client-side code in 1st message):

//-------------------------------------
// Client.asp
//-------------------------------------

//request XML object is optional if you want to send data to Server
var oXMLReq = new ActiveXObject("Msxml2.DOMDocument.4.0");
oXMLReq.loadXML("<?xml vedrsion='1.0'?><Root>My request</Root>");

//transport XMLHTTP object
var oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP.4.0");
oXMLHTTP.open("post", sHRef, false);
oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oXMLHTTP.send(oXMLReq); //or oXMLHTTP.send() if no data to send

//response XML object
var oXMLRes = new ActiveXObject("Msxml2.DOMDocument.4.0");
oXMLRes.loadXML(oXMLHTTP.responseText);
alert(oXMLRes.documentElement.text);

2) Client code run on Server (use ServerXMLHTTP instead of XMLHTTP)

<%@ Language=VBScript %>
<%
Dim oXMLReq
Dim oXMLHTTP
Dim oXMLRes

Set oXMLReq = Server.CreateObject("Msxml2.DOMDocument.4.0")
Call oXMLReq.loadXML("<?xml version='1.0'?><Root>My request</Root>")

Set oXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
Call oXMLHTTP.open("post", sHRef, false)
Call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call oXMLHTTP.send(oXMLReq)

Set oXMLRes = Server.CreateObject("Msxml2.DOMDocument.4.0")
Call oXMLRes.loadXML(oXMLHTTP.responseText)
Call Response.Write(oXMLRes.documentElement.text)
%>

Here is Server codes:

//-------------------------------------
// Server_on_ASP.asp
//-------------------------------------
<%@ Language=VBScript %>
<%
Dim oXMLReq
Set oXMLReq = Server.CreateObject("Msxml2.DOMDocument.4.0")
Call oXMLReq.load(Request)
.......... do something with client XML object........

'send a response XML string (not XML object)
Call Response.Write("<MyResponse>OK</MyResponse>")
%>

To request data from ASP.NET Web Service, you must change your client code a little bit

//-------------------------------------
// Client_for_NET.asp
//-------------------------------------

//request data from Web Service "Server_on_NET", method "GetRequest"
var sHRef = "http://server/Server_on_NET.asmx/GetRequest";

//send 2 parameters "ProductID" and "Customer"
var sParams = "ProductID=5&Customer=KhoaNguyen";

var oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP.4.0");
oXMLHTTP.open("POST", sHRef, false);
oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oXMLHTTP.send(sParams);

........ same as above............

//-------------------------------------
// Server_on_NET.asmx (Web Service)
//-------------------------------------
<WebMethod()>
Public Function GetRequest(ByVal ProductID As Integer, ByVal Customer As String) As String
   'do something with ProductID and Customer

   Return "OK"
End Function


You should see "OK" on your client side
Hope this help.
Khoa Nguyen
  #5 (permalink)  
Old July 3rd, 2003, 09:11 PM
Authorized User
 
Join Date: Jun 2003
Location: São Paulo, São Paulo, Brazil.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Khoa Nguyen,

   Sorry, but my english is bad.
   Well, thank you, thank you so much.
   Only you understood what I needed.
   Fantastic!!!
   Congratulations by your knowledge.




Fabio Ferreira Balota
  #6 (permalink)  
Old September 13th, 2003, 02:44 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
       Call oXMLReq.load(Request) does not work. What can be the problem ? Any idea ?
  #7 (permalink)  
Old September 14th, 2003, 12:36 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi vrbhatt,

> Call oXMLReq.load(Request) does not work. What can be the problem ? Any idea ?
Can you show me both your client and server codes ?

Khoa Nguyen
  #8 (permalink)  
Old October 7th, 2003, 05:11 PM
Registered User
 
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi guys,
I need some help with XML HTTP object. I am using the following code to retrieve the HTML in a string of a specified URl. For some reason it doesn't work for the website i need. https://www.dallascounty.org/servlet/padb1#
At first i thought that this doesn't work with Https url's but i have tried with many and it did. When i use the above URl it gives me a 500 Servlet exception.
I am using this in ASP.
<%
  Response.Buffer = True
  Dim objXMLHTTP, xml

  ' Create an xmlhttp object:
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  ' Or, for version 3.0 of XMLHTTP, use:
  ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

  ' Opens the connection to the remote server.
  xml.Open "GET", "http://www.4Guysfromrolla.com/", False

  ' Actually Sends the request and returns the data:
  xml.Send

  'Display the HTML both as HTML and as text
  Response.Write "<h1>The HTML text</h1><xmp>"
  Response.Write xml.responseText
  Response.Write "</xmp><p><p><h1>The HTML Output</h1>"

  Response.Write xml.responseText


  Set xml = Nothing
%>

I'll appreciate your response and if it cannot be done pls if u have any information about retrieving the String of URLS like the one i mentioned? do let me know.
Bye




Similar Threads
Thread Thread Starter Forum Replies Last Post
xmlhttp matteoallorg RSS and Atom 0 July 12th, 2005 12:37 PM
xmlhttp help ojaynet RSS and Atom 2 April 8th, 2005 04:13 PM
XMLHTTP ffbalota ASP.NET 1.0 and 1.1 Professional 1 August 16th, 2003 01:29 PM
XMLHTTP ffbalota Classic ASP Professional 0 June 25th, 2003 02:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.