473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ServerXMLHTTP.3.0 parsing problem

I'm using an ASP 3.0 page to query the USPS site for shipping rate info using
the ServerXMLHTTP.3.0 object. The code is as follows:

set objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
objSrvHTTP.open "GET",
"http://production.shippingapis.com/ShippingAPI.dll?API=RateV2&XML=" &
xmlDoc.xml, False
objSrvHTTP.send

The request is successful, as indicated when I pretty print the resulting
response like this:

Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

The result is a well-formed XML document in the expected format. However,
when I try to parse the actual XML from objSrvHTTP.responseXML, I get
nothing. It's as if the XML doesn't exist. I also tried parsing
objSrvHTTP.responseXML.xml instead, but that didn't work either. I know the
XML response is being returned properly (as indicated when I pretty print the
responseText), but no matter what I try, I can't parse, print, or otherwise
access the actual XML! I'm hoping there's a simple solution to this, since
it's only a few lines of code but has been causing me no small amount of
frustration...

Thanks in advance,

Jason
May 31 '07 #1
4 5927
Jason wrote:
I'm using an ASP 3.0 page to query the USPS site for shipping rate info using
the ServerXMLHTTP.3.0 object. The code is as follows:

set objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
objSrvHTTP.open "GET",
"http://production.shippingapis.com/ShippingAPI.dll?API=RateV2&XML=" &
xmlDoc.xml, False
objSrvHTTP.send

The request is successful, as indicated when I pretty print the resulting
response like this:

Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

The result is a well-formed XML document in the expected format. However,
when I try to parse the actual XML from objSrvHTTP.responseXML, I get
nothing. It's as if the XML doesn't exist.
Please check
objSrvHTTP.GetAllResponseHeaders()
to see whether the server sends the proper Content-Type header (e.g.
application/xml or text/xml) so that MSXML populates the responseXML
document.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 31 '07 #2
"Martin Honnen" wrote:
Please check
objSrvHTTP.GetAllResponseHeaders()
to see whether the server sends the proper Content-Type header (e.g.
application/xml or text/xml) so that MSXML populates the responseXML
document.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Hi Martin,

The only result I get from
Response.Write(objSrvHTTP.GetAllResponseHeaders()) is this:
Expand|Select|Wrap|Line Numbers
  1. Server: Microsoft-IIS/5.0 Date: Thu, 31 May 2007 16:08:53 GMT
  2. Connection: close
Do I need to use a different method to get the content-type header? As you
can see, I'm not very familiar with this server object. I did try explicitly
setting the content-type of the Response object to "text/xml", but that
didn't seem to have any effect.

Thanks for considering my problem, and further help would be greatly
appreciated.
May 31 '07 #3
Jason wrote:
The only result I get from
Response.Write(objSrvHTTP.GetAllResponseHeaders()) is this:
Expand|Select|Wrap|Line Numbers
  1. Server: Microsoft-IIS/5.0 Date: Thu, 31 May 2007 16:08:53 GMT
  2. Connection: close

Do I need to use a different method to get the content-type header? As you
can see, I'm not very familiar with this server object. I did try explicitly
setting the content-type of the Response object to "text/xml", but that
didn't seem to have any effect.
The server you are making your request to needs to set the HTTP response
header
Content-Type: application/xml
so that MSXML populates the responseXML document.
If you can't change the server settings of that server then, if you want
a DOM document, you are left with e.g.
Set responseXML = CreateObject("Msxml2.DOMDocument.3.0")
responseXML.async = False
responseXML.load objSrvHTTP.responseStream

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 31 '07 #4


"Martin Honnen" wrote:
>
The server you are making your request to needs to set the HTTP response
header
Content-Type: application/xml
so that MSXML populates the responseXML document.
If you can't change the server settings of that server then, if you want
a DOM document, you are left with e.g.
Set responseXML = CreateObject("Msxml2.DOMDocument.3.0")
responseXML.async = False
responseXML.load objSrvHTTP.responseStream

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
..responseStream was the key. I was already using an XML DOM document, but
was attempting to load it via the objSrvHTTP.responseXML. Thanks so much for
your help!
May 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike D | last post by:
I have been reading these posts and I thought I may be able to use serverXMLhttp for my current problem. My company requires all of their divisions to use the same template for intranet sites. ...
3
by: Dana | last post by:
I am having a problem with the following code: Response.CharSet = "UTF-8" url = "http://www.domain.com/myisapi.dll" set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "POST", url,...
1
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
0
by: anshu | last post by:
Hi, I've to migrate an existing code in asp to asp.Net. The asp code uses ServerXMLHTTP to call some services. Same thing will be done using HttpWebRequest in the asp.Net code. The problem is...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
8
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
7
by: Ed McNierney | last post by:
I'm trying to use ServerXMLHTTP on an ASP (not ASP.NET) page to retrieve large binary data from a remote server. When the request is large (more than a few megabytes), the ServerXMLHTTP page jumps...
10
by: Lambuz | last post by:
Hi all, I'm trying to use a ServerXMLHTTP connection in async mode to request Page2.asp from Page1.asp. Both pages are inside 2 different virtual directories with Windows Integrated...
1
by: niklang | last post by:
Hi everybody, I have an ASP page that uses the MSXML2.ServerXMLHTTP object to read a stylesheet from IIS as follows: strXSLPath = "http://localhost/ej/ejdetail.xsl.asp" ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.