Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
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 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
Old May 31st, 2007, 10:41 AM
Registered User
Join Date: May 2007
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,

Old May 31st, 2007, 10:55 AM
Friend of Wrox
Join Date: Jul 2003
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


Old June 1st, 2007, 01:18 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
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)

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

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