responseXML.documentElement.childNodes Error

Discussion in 'ASP General' started by fniles, Mar 16, 2009.

  1. fniles

    fniles Guest

    In my ASP page I open a file on the intranet and reads in as XML stream.
    I can open the file fine, but when I do "For Each TopicChildNode In
    xmlHttp.responseXML.documentElement.childNodes" I got the error "HTTP 500
    Internal Server error" "The website cannot display the page. Most likely
    causes:
    The website is under maintenance
    The website has a programming error"

    If I open and reads a file from say
    "http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=CA"
    I do NOT get any error.

    What causes the error in this case and how can I fix it ?
    Thank you.

    Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
    xmlHTTP.open "GET","http://myIntranetSite/thisweek?OPTION",false
    xmlHTTP.send
    For Each TopicChildNode In
    mlHttp.responseXML.documentElement.childNodes -> ERROR here
    :
    next
     
    fniles, Mar 16, 2009
    #1
    1. Advertising

  2. fniles wrote on Mon, 16 Mar 2009 10:38:35 -0500:

    > In my ASP page I open a file on the intranet and reads in as XML
    > stream.
    > I can open the file fine, but when I do "For Each TopicChildNode In
    > xmlHttp.responseXML.documentElement.childNodes" I got the error "HTTP
    > 500 Internal Server error" "The website cannot display the page. Most
    > likely causes:
    > The website is under maintenance
    > The website has a programming error"


    > If I open and reads a file from say
    > "http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    > JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=
    > CA" I do NOT get any error.


    > What causes the error in this case and how can I fix it ?
    > Thank you.


    > Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
    > xmlHTTP.open "GET","http://myIntranetSite/thisweek?OPTION",false
    > xmlHTTP.send
    > For Each TopicChildNode In
    > lHttp.responseXML.documentElement.childNodes -> ERROR here :
    > next


    If the URL being requested does not return XML then responseXML will be
    empty so again you'll get an error.

    If you turn off "Show Friendly Error Messages" in IE, what does the error
    then show? Often the real error message is hidden by IE unless you do this,
    seeing the raw error might give you an idea of what the problem is.

    Also, if your code above is a copy-paste then you appear to be missing an x
    in "In mlHttp" which should be "In xmlHttp".

    --
    Dan
     
    Daniel Crichton, Mar 16, 2009
    #2
    1. Advertising

  3. fniles

    fniles Guest

    Thank you.
    Will it make any difference if the XML is generated by SAP using web
    services ?

    I will ask the client to turn off "Show Friendly Error Messages" in IE and
    see what he gets.

    > Also, if your code above is a copy-paste then you appear to be missing an
    > x in "In mlHttp" which should be "In xmlHttp".

    Yes, it's a typo when I posted the question on the forum. In my ASP page, it
    does say xmlHTTP.

    Thank you.

    "Daniel Crichton" <> wrote in message
    news:...
    > fniles wrote on Mon, 16 Mar 2009 10:38:35 -0500:
    >
    >> In my ASP page I open a file on the intranet and reads in as XML
    >> stream.
    >> I can open the file fine, but when I do "For Each TopicChildNode In
    >> xmlHttp.responseXML.documentElement.childNodes" I got the error "HTTP
    >> 500 Internal Server error" "The website cannot display the page. Most
    >> likely causes:
    >> The website is under maintenance
    >> The website has a programming error"

    >
    >> If I open and reads a file from say
    >> "http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    >> JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=
    >> CA" I do NOT get any error.

    >
    >> What causes the error in this case and how can I fix it ?
    >> Thank you.

    >
    >> Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
    >> xmlHTTP.open "GET","http://myIntranetSite/thisweek?OPTION",false
    >> xmlHTTP.send
    >> For Each TopicChildNode In
    >> Http.responseXML.documentElement.childNodes -> ERROR here :
    >> next

    >
    > If the URL being requested does not return XML then responseXML will be
    > empty so again you'll get an error.
    >
    > If you turn off "Show Friendly Error Messages" in IE, what does the error
    > then show? Often the real error message is hidden by IE unless you do
    > this, seeing the raw error might give you an idea of what the problem is.
    >
    > Also, if your code above is a copy-paste then you appear to be missing an
    > x in "In mlHttp" which should be "In xmlHttp".
    >
    > --
    > Dan
    >
     
    fniles, Mar 16, 2009
    #3
  4. So long as it's valid XML and the correct MIME header is sent it should
    work. But if the XML is invalid then it's not going to work.

    Dan

    fniles wrote on Mon, 16 Mar 2009 12:19:13 -0500:

    > Thank you.
    > Will it make any difference if the XML is generated by SAP using web
    > services ?


    > I will ask the client to turn off "Show Friendly Error Messages" in IE
    > and see what he gets.


    >> Also, if your code above is a copy-paste then you appear to be
    >> missing an x in "In mlHttp" which should be "In xmlHttp".

    > Yes, it's a typo when I posted the question on the forum. In my ASP
    > page, it does say xmlHTTP.


    > Thank you.


    > "Daniel Crichton" <> wrote in message news:...
    >> fniles wrote on Mon, 16 Mar 2009 10:38:35 -0500:


    >>> In my ASP page I open a file on the intranet and reads in as XML
    >>> stream.
    >>> I can open the file fine, but when I do "For Each TopicChildNode In
    >>> xmlHttp.responseXML.documentElement.childNodes" I got the error
    >>> "HTTP 500 Internal Server error" "The website cannot display the
    >>> page. Most likely causes:
    >>> The website is under maintenance
    >>> The website has a programming error"


    >>> If I open and reads a file from say
    >>> "http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    >>> JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&
    >>> state=
    >>> CA" I do NOT get any error.


    >>> What causes the error in this case and how can I fix it ?
    >>> Thank you.


    >>> Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
    >>> xmlHTTP.open "GET","http://myIntranetSite/thisweek?OPTION",false
    >>> xmlHTTP.send
    >>> For Each TopicChildNode In
    >>> Http.responseXML.documentElement.childNodes -> ERROR here :
    >>> next


    >> If the URL being requested does not return XML then responseXML will
    >> be empty so again you'll get an error.


    >> If you turn off "Show Friendly Error Messages" in IE, what does the
    >> error then show? Often the real error message is hidden by IE unless
    >> you do this, seeing the raw error might give you an idea of what the
    >> problem is.


    >> Also, if your code above is a copy-paste then you appear to be
    >> missing an x in "In mlHttp" which should be "In xmlHttp".


    >> --
    >> Dan
     
    Daniel Crichton, Mar 16, 2009
    #4
  5. 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.


    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Mar 16, 2009
    #5
  6. fniles

    fniles Guest

    Thank you.

    Did you mean the file needs to have Content-Type: application/xml or
    Content-Type: text/xml ?

    When I GET
    http://local.yahooapis.com/MapsServ...&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" <> wrote in message
    news:%...
    > 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.
    >
    >
    > --
    >
    > Martin Honnen --- MVP XML
    > http://JavaScript.FAQTs.com/
     
    fniles, Mar 16, 2009
    #6
  7. fniles

    fniles Guest

    Thank you.

    What do you mean by MIME header is sent ?

    When I GET
    http://local.yahooapis.com/MapsServ...&street=701 First Ave&city=Sunnyvale&state=CA,
    it works fine.
    The file looks like the following:
    <?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>


    "Daniel Crichton" <> wrote in message
    news:...
    > So long as it's valid XML and the correct MIME header is sent it should
    > work. But if the XML is invalid then it's not going to work.
    >
    > Dan
    >
    > fniles wrote on Mon, 16 Mar 2009 12:19:13 -0500:
    >
    >> Thank you.
    >> Will it make any difference if the XML is generated by SAP using web
    >> services ?

    >
    >> I will ask the client to turn off "Show Friendly Error Messages" in IE
    >> and see what he gets.

    >
    > >> Also, if your code above is a copy-paste then you appear to be
    > >> missing an x in "In mlHttp" which should be "In xmlHttp".

    >> Yes, it's a typo when I posted the question on the forum. In my ASP
    >> page, it does say xmlHTTP.

    >
    >> Thank you.

    >
    >> "Daniel Crichton" <> wrote in message
    >> news:...
    > >> fniles wrote on Mon, 16 Mar 2009 10:38:35 -0500:

    >
    > >>> In my ASP page I open a file on the intranet and reads in as XML
    > >>> stream.
    > >>> I can open the file fine, but when I do "For Each TopicChildNode In
    > >>> xmlHttp.responseXML.documentElement.childNodes" I got the error
    > >>> "HTTP 500 Internal Server error" "The website cannot display the
    > >>> page. Most likely causes:
    > >>> The website is under maintenance
    > >>> The website has a programming error"

    >
    > >>> If I open and reads a file from say
    > >>> "http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    > >>> JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&
    > >>> state=
    > >>> CA" I do NOT get any error.

    >
    > >>> What causes the error in this case and how can I fix it ?
    > >>> Thank you.

    >
    > >>> Set xmlHTTP = Server.CreateObject("Msxml2.serverXMLHTTP.3.0")
    > >>> xmlHTTP.open "GET","http://myIntranetSite/thisweek?OPTION",false
    > >>> xmlHTTP.send
    > >>> For Each TopicChildNode In
    > >>> Http.responseXML.documentElement.childNodes -> ERROR here :
    > >>> next

    >
    > >> If the URL being requested does not return XML then responseXML will
    > >> be empty so again you'll get an error.

    >
    > >> If you turn off "Show Friendly Error Messages" in IE, what does the
    > >> error then show? Often the real error message is hidden by IE unless
    > >> you do this, seeing the raw error might give you an idea of what the
    > >> problem is.

    >
    > >> Also, if your code above is a copy-paste then you appear to be
    > >> missing an x in "In mlHttp" which should be "In xmlHttp".

    >
    > >> --
    > >> Dan

    >
    >
    >
     
    fniles, Mar 16, 2009
    #7
  8. 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:

    > Thank you.


    > 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" <> wrote in message news:%...
    >> 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.



    >> --


    >> Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
     
    Daniel Crichton, Mar 17, 2009
    #8
  9. fniles

    fniles Guest

    Thank you so much for your help.

    I will try your suggestion with the DOM object.

    How can I telnet
    http://local.yahooapis.com/MapsServ...&street=701 First Ave&city=Sunnyvale&state=CA ?
    Do I need to surround the URL with " ?
    What port shall I use ?

    "Daniel Crichton" <> wrote in message
    news:e4dX$...
    > 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:
    >
    >> Thank you.

    >
    >> 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" <> wrote in message
    >> news:%...
    > >> 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.

    >
    >
    > >> --

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

    >
    >
     
    fniles, Mar 17, 2009
    #9
  10. fniles wrote on Tue, 17 Mar 2009 12:03:26 -0500:

    > Thank you so much for your help.


    > I will try your suggestion with the DOM object.


    > How can I telnet http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    > JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=
    > CA ?
    > Do I need to surround the URL with " ?
    > What port shall I use ?


    You would do

    telnet local.yahooapis.com 80

    then type

    GET
    /MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=CA
    HTTP/1.1
    Host: local.yahooapis.com


    (note that the GET and up to and including the HTTP/1.1 needs to all be on a
    single line). It's really much easier to use Fiddler2 :)


    Dan




    > "Daniel Crichton" <> wrote in message news:e4dX$...
    >> 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:


    >>> Thank you.


    >>> 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" <> wrote in message
    >>> news:%...
    >>>> 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.



    >>>> --


    >>>> Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
     
    Daniel Crichton, Mar 17, 2009
    #10
  11. fniles

    fniles Guest

    Thank you for your help !

    "Daniel Crichton" <> wrote in message
    news:%...
    > fniles wrote on Tue, 17 Mar 2009 12:03:26 -0500:
    >
    >> Thank you so much for your help.

    >
    >> I will try your suggestion with the DOM object.

    >
    >> How can I telnet
    >> http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_
    >> JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=
    >> CA ?
    >> Do I need to surround the URL with " ?
    >> What port shall I use ?

    >
    > You would do
    >
    > telnet local.yahooapis.com 80
    >
    > then type
    >
    > GET
    > /MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&street=701+First+Ave&city=Sunnyvale&state=CA
    > HTTP/1.1
    > Host: local.yahooapis.com
    >
    >
    > (note that the GET and up to and including the HTTP/1.1 needs to all be on
    > a single line). It's really much easier to use Fiddler2 :)
    >
    >
    > Dan
    >
    >
    >
    >
    >> "Daniel Crichton" <> wrote in message
    >> news:e4dX$...
    > >> 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:

    >
    > >>> Thank you.

    >
    > >>> 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" <> wrote in message
    > >>> news:%...
    > >>>> 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.

    >
    >
    > >>>> --

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

    >
    >
    >
    >
     
    fniles, Mar 17, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Skip Montanaro
    Replies:
    4
    Views:
    963
    Uche Ogbuji
    Sep 4, 2004
  2. Omer  Ahmad
    Replies:
    0
    Views:
    411
    Omer Ahmad
    Aug 30, 2004
  3. Max
    Replies:
    1
    Views:
    604
    Martin Honnen
    Aug 9, 2006
  4. Kyle
    Replies:
    6
    Views:
    259
    Lasse Reichstein Nielsen
    Jan 25, 2004
  5. JJA
    Replies:
    2
    Views:
    210
Loading...

Share This Page