That's the response body. You need to look at the headers too. You can do
this using a HTTP trace tool like Fiddler2, or by connecting to the server
and requesting the page via a telnet type application.
For the URL you gave I used Fiddler2, here's the output of the response
headers:
HTTP/1.1 200 OK
Date: Tue, 17 Mar 2009 11:40:40 GMT
P3P: policyref="
http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR
ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi
IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Cache-Control: private
Connection: close
Content-Type: text/xml; charset=utf-8
Content-Length: 516
As you can see the Content-Type header here is text/xml, so it will be
parsed by the ServerXMLHTTP object automatically. Try the same with your
intranet request. If you don't want to use Fiddler2 (I can highly
recommend it though) you can do it using a telnet type application easily.
For instance, in Windows open a command prompt and type
telnet intranet 80
you'll then have a flashing cursor, type
GET /thisweek?OPTION HTTP/1.1
Host: intranet
and press enter twice at the end (you need to send a blank line, then
another blank line to finish the request). If the server doesn't need any
other HTTP request headers (for instant user-agent information, cookies,
etc) then it should return the xml. You need to look at the first part of
the response before the XML to see the headers. If Content-Type is
missing, or is not set to an xml MIME type, then the ServerXMLHTTP object
will not automatically parse it and you'll get an error if you try to use
the responseXML.xml object.
You can take the output though and use a DOM object to load it and parse
it. eg.
Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
xmlHTTP.open "GET","
http://myIntranetSite/thisweek?OPTION",false
xmlHTTP.send
mResponseXML = xmlHTTP.responseText
If mResponseXML = "" Then
'no response, handle it here
Else
Set xml = Server.CreateObject("MSXML2.DOMDocument60")
xml.async = False
xml.validateOnParse = True
xml.LoadXML mResponseXML
If xml.parseError.errorCode <> 0 Then
'error, not valid XML, handle here
Else
For Each TopicChildNode In xml.documentElement.childNodes
...
Next
End If
End If
(code above is untested, but the basics were copied from an application I
have running on a daily basis processing XML data from a remote site).
What the above does is to get the XML from the responseText property (if
the XML is not valid or automatically parsed then responseXML will be
empty, but responseText will not be), then load it into a DOMDocument
object with parse checking turned on, and only if that can be loaded as
XML then will the code go into looping through the childnodes.
Dan
fniles wrote on Mon, 16 Mar 2009 15:15:54 -0500:
Did you mean the file needs to have Content-Type: application/xml or
Content-Type: text/xml ?
When I GET
http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=
CA, it works fine.
The file looks like the following: ( I do not see Content-Type:
application/xml or Content-Type: text/xml in the file, but responseXML
works)
<?xml version="1.0" ?>
- <ResultSet xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps
http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
- <Result precision="address">
<Latitude>37.416397</Latitude>
::
</Result>
</ResultSet>
The intranet file that does not work has the following heading:
<?xml version="1.0" encoding="iso-8859-1"?>
<asx:abap xmlns:asx="
http://www.sap.com/abapxml" version="1.0">
<asx:values>
<TABLE>
:
</TABLE>
</asx:values>
</asx:abap>
Martin Honnen said:
fniles wrote:
Will it make any difference if the XML is generated by SAP using web
services ?
They need to set the HTTP response Content-Type header as
Content-Type: application/xml or
Content-Type: text/xml to have MSXML try to populate responseXML.