p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP XML (http://p2p.wrox.com/forumdisplay.php?f=69)
-   -   Reading XML datastream (http://p2p.wrox.com/showthread.php?t=18565)

realgone_ September 17th, 2004 04:27 PM

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



pgtips September 20th, 2004 04:42 AM

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

realgone_ September 20th, 2004 07:45 AM

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
%>


pgtips September 20th, 2004 08:11 AM

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

realgone_ September 20th, 2004 01:48 PM

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.


curt504 September 22nd, 2004 01:17 PM

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



All times are GMT -4. The time now is 07:43 AM.

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