Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2007, 10:41 AM
Registered User
Join Date: May 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ServerXMLHTTP.3.0 problem returning XML

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
The request is successful, as indicated when I pretty print the resulting response like this:
Response.ContentType = "text/xml"
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,

Reply With Quote
  #2 (permalink)  
Old May 31st, 2007, 10:55 AM
Friend of Wrox
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post

Hi Jason,

responseXML returns a dom containing the parsed response, you should be able to do something like...
Set oDom = objServerHTTP.responseXML
If oDom.parseError <> 0 Then
   Response.Write "error: " & oDom.parseError.reason
   Response.Write oDom.xml
End If


Reply With Quote
  #3 (permalink)  
Old June 1st, 2007, 01:18 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If the responseText looks fine but responseXML is empty then the usual problem is that the content type is set incorrectly on the server, something you are probably unable to change. In that case you need to create an msxml2.domdocument.x.0 and use loadXML to read the responseText. Replace x with the version number. You should make an effort to use version 6 for this and the original ServerXMLHTTP if possible, if not use 3 or 4.


Joe (Microsoft MVP - XML)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning XML from aspx page to windows app monuindia2002 .NET Web Services 1 February 10th, 2006 07:18 PM
returning XML from ASP page amrit_82 Classic ASP Professional 4 July 6th, 2004 05:37 PM
problem in Function returning Recordset pankaj_pp Classic ASP Professional 1 June 3rd, 2004 11:23 AM
ASP and ServerXMLHTTP oscarledesma Classic ASP XML 0 October 22nd, 2003 08:17 AM
ServerXMLHTTP Problem AgentSmith Classic ASP Components 0 August 1st, 2003 01:44 PM

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

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