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 September 17th, 2004, 04:27 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading XML datastream

This question was asked some time ago but went mostly unanswered.
Any ideas would be appreciated:

I am sending the information from a form to a vendor site. There's s hidden fields on the form that is loaded with the well-formed xml when the submit button is clicked. This is then passed to a vendor web site to get a quote. Their system reads this xml from the hidden field (via request.form) and passes pure xml code as the result (with a response.write). There is no other way to communicate with their system except to use their form handler since among other hidden fields are mandatory default fields that rae used to login etc.

My question is this ... how can I capture this XML returned from the form handler so that I can reformat it properly for display?. The returned XML shows up in my browser window but I can't seem to find a way to get to it.

When I use their url directly as the form handler (action=their url) I get the returned XML displayed in my browser ... If I try to replace their form handler with my own (see below)I get a blank page.

ANy help would be greatly appreciated.

I tried using setting the form action to an asp page. Within this asp page I grab all of the for elements and use the MSXML2.ServerXMLHTTP to send the request but it does not seem to be working. I get expected statement errors:

Public Function SentRequest() As Boolean
   Dim oHTTPS As MSXML2.ServerXMLHTTP50
   Set oHTTPS = New MSXML2.ServerXMLHTTP50
   SentRequest = False
   Dim sFormData As String
   Dim Result As String
   sFormData = Space(0)
   sFormData = sFormData & "requestid=1122"
   sFormData = sFormData & "&"
   sFormData = sFormData & "originzip=" & "46750"
   sFormData = sFormData & "&"
   sFormData = sFormData & "destzip=" & "63303"
  sFormData = sFormData & "&"
  sFormData = sFormData & "ltldd=" & "S"
  sFormData = sFormData & "&"
   sFormData = sFormData & "payment=" & "P"
   Dim SubmitURL As String
   SubmitURL = Space(0)
   SubmitURL = SubmitURL "https://www.myyellow.com/dynamic/services/servlet"
   SubmitURL = SubmitURL & "?CONTROLLER=com.yell.ec.inter.yfsratequote.ht tp."
   SubmitURL = SubmitURL & "controller.RateQuoteAPIController"
   With oHTTPS
      .Open "post", SubmitURL, False
      .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      .SetRequestHeader "Authorization", "Basic yourUserName:yourPassword"
      .Send sFormData
      Debug.Print .ResponseXML.xml
      Debug.Print vbCrLf
      Debug.Print .ResponseText
      DoEvents
   End With
   SentRequest = True
   If oHTTPS Is Nothing = False Then
      Set oHTTPS = Nothing
   End If
End Function


  #2 (permalink)  
Old September 20th, 2004, 04:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Two things I can see wrong:
1. on this line
SubmitURL = SubmitURL "https://www.myyellow.com/dynamic/services/servlet"
you're missing the & to join the 2 strings

2. you can't add your CONTROLLER argument in this way. ServerXMLHTTP doesn't support it. You must put the "CONTROLLER=com.yell.ec.inter.yfsratequote.httpcon troller.RateQuoteAPIController" bit in the sFormData variable along with all the other params.

Also, you should check the responseStatus = 200 before you try to read the responseText or responseXML. (Edit: the property name is status not responseStatus)

hth
Phil
  #3 (permalink)  
Old September 20th, 2004, 07:45 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was able to get this working after some sweating this week end:

<%
Dim PostData
Dim xml
Dim objXMLHTTP

PostData = PostData & "&requestid="
PostData = PostData & "&originzip=08075"
PostData = PostData & "&destzip=08648"
PostData = PostData & "&ltldd="
PostData = PostData & "&payment="

set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.open "POST", "https://www.myyellow.com/dynamic/services/servlet?CONTROLLER=com.yell.ec.inter.yfsratequote. http.controller.RateQuoteAPIController", False, _
"user","pwd"
xml.send "& PostData &"
strStatus = xml.Status
strRetval = xml.responseText
set xml = nothing
%>

  #4 (permalink)  
Old September 20th, 2004, 08:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Glad you got it working, but why have you switched to the old Microsoft.XMLHTTP component? This isn't designed for use in ASP. See http://support.microsoft.com/default.aspx?kbid=290761 in particular the comment in Q4
Quote:
quote:Using XMLHTTP in server side applications like Active Server Pages (ASP) ... is not supported
  #5 (permalink)  
Old September 20th, 2004, 01:48 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

At the time advise was minimal for ServerXMLHTTP in my researching this problem.
I decided to use what seemed to be working for other people in this situation.
Thanks for this article, I may update to ServerXMLHTTP once I am situated with this project.

  #6 (permalink)  
Old September 22nd, 2004, 01:17 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the tip on ServerXMLHTTP.

I checked out the URL given and found a very terse usage example.

I'm new to .asp/.aspx and need to implement a function that interfaces a remote service returning XML.

This function/class/??? needs to be callable from both .ASP and .ASPX server environments.

I've struggled with creating a com .dll from C# and haven't figured that out.

Might a function declared in a .ASP that's included into either a customer's .ASP or .ASPX work?

Tips on this and ServerXMLHTTP much appreciated. :)))

Tnx for this group and all the help being given.

curt



Similar Threads
Thread Thread Starter Forum Replies Last Post
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
Reading XML evidica C# 0 July 25th, 2006 10:33 AM
Parsing xml datastream using XMLDOM realgone_ XML 8 September 23rd, 2004 08:50 AM
Reading images straight from datastream shinmai PHP How-To 4 December 16th, 2003 05:21 PM
Reading XML datastream returned from vendor marabunta Classic ASP XML 1 September 8th, 2003 09:23 AM





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