[Javascript] problem with ResponseXml.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KaNos

    [Javascript] problem with ResponseXml.

    Hello aspx world,
    I consume a webservice with Javascript functions.
    But the response is ok and, very strange, document is null.
    How to resolve this problem thanks ??????



    xmlHttpRequest. open("POST", myAddressLocati on, false);
    xmlHttpRequest. setRequestHeade r("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest. send(xmldocumen tSoapRequest);
    if (xmlHttpRequest .readyState == 4)
    {
    alert(xmlHttpRe quest.responseT ext); // response ok

    var xmldocumentSoap Response = xmlHttpRequest. responseXML;

    alert(xmldocume ntSoapResponse. documentElement == null); // response is
    true ?
    }

    The well formed webservice response with responseText.

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelop e xmlns:soap="htt p://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <InitializeResp onse xmlns="http://www.euristyle.c om/">
    <InitializeResu lt>
    <cocd xmlns="http://ltsc.ieee.org/xsd/1484_11_3"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocat ion="http://ltsc.ieee.org/xsd/1484_11_3ieee_1 484_11_3_2005.x sd">
    <commentsFromLe arner/>
    <commentsFromLM S/>
    <completionStat us>unknown</completionStatu s>
    <completionThre shold/>
    <credit>credi t</credit>
    <entry>ab_initi o</entry>
    <exit/>
    <interactions/>
    <launchData/>
    <learnerId>1234 567890</learnerId>
    <learnerName>My </learnerName>
    <learnerPrefere nceData>
    <audioCaptionin g>no_change</audioCaptioning >
    <audioLevel>1 </audioLevel>
    <deliverySpeed> 1</deliverySpeed>
    <language>fr-FR</language>
    </learnerPreferen ceData>
    <location/>
    <maxTimeAllow ed/>
    <mode>normal</mode>
    <objectives/>
    <progressMeasur e/>
    <scaledPassingS core/>
    <score/>
    <sessionTime/>
    <successStatus> unknown</successStatus>
    <suspendData/>
    <timeLimitActio n>continue_no_m essage</timeLimitAction >
    <totalTime>PT0S </totalTime>
    <dataModelVersi on>1.0</dataModelVersio n>
    </cocd>
    </InitializeResul t>
    </InitializeRespo nse>
    </soap:Body>
    </soap:Envelope>


  • Martin Honnen

    #2
    Re: [Javascript] problem with ResponseXml.



    KaNos wrote:

    xmlHttpRequest. open("POST", myAddressLocati on, false);
    xmlHttpRequest. setRequestHeade r("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest. send(xmldocumen tSoapRequest);
    if (xmlHttpRequest .readyState == 4)
    {
    alert(xmlHttpRe quest.responseT ext); // response ok
    >
    var xmldocumentSoap Response = xmlHttpRequest. responseXML;
    >
    alert(xmldocume ntSoapResponse. documentElement == null); // response is
    true ?
    Check xmlHttpRequest. getAllResponseH eaders(), what does that show, in
    particular for the HTTP Content-Type header?
    And if that is script with IE then check
    xmlHttpRequest. responseXML.par seError.errorCo de
    If that is not 0 then check
    xmlHttpRequest. responseXML.par seError.reason

    --

    Martin Honnen --- MVP XML

    Comment

    • KaNos

      #3
      Re: [Javascript] problem with ResponseXml.

      Hello Martin,
      The HTTP Header is :

      Server: Microsoft-IIS/5.1
      Date: Tue, 08 Aug 2006 15:54:04 GMT
      X-Powered-By: ASP.NET
      X-AspNet-Version: 2.0.50727
      Cache-Control: private, max-age=0
      Content-Type: application/soap+xml; charset=utf-8
      Content-Length: 1289

      And xmlHttpRequest. responseXML.par seError.errorCo de is 0. So i think no
      error.
      Where is my problem ?
      Thanks,

      "Martin Honnen" <mahotrash@yaho o.dea écrit dans le message de news:
      eOynoEwuGHA.122 4@TK2MSFTNGP03. phx.gbl...
      >
      >
      KaNos wrote:
      >
      >
      >xmlHttpRequest .open("POST", myAddressLocati on, false);
      >xmlHttpRequest .setRequestHead er("Content-Type", "text/xml;
      >charset=utf-8");
      >xmlHttpRequest .send(xmldocume ntSoapRequest);
      >if (xmlHttpRequest .readyState == 4)
      >{
      > alert(xmlHttpRe quest.responseT ext); // response ok
      >>
      > var xmldocumentSoap Response = xmlHttpRequest. responseXML;
      >>
      > alert(xmldocume ntSoapResponse. documentElement == null); // response
      >is true ?
      >
      Check xmlHttpRequest. getAllResponseH eaders(), what does that show, in
      particular for the HTTP Content-Type header?
      And if that is script with IE then check
      xmlHttpRequest. responseXML.par seError.errorCo de
      If that is not 0 then check
      xmlHttpRequest. responseXML.par seError.reason
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      Comment

      • KaNos

        #4
        Re: [Javascript] problem with ResponseXml.

        Hello Martin,
        The HTTP Header is :

        Server: Microsoft-IIS/5.1
        Date: Tue, 08 Aug 2006 15:54:04 GMT
        X-Powered-By: ASP.NET
        X-AspNet-Version: 2.0.50727
        Cache-Control: private, max-age=0
        Content-Type: application/soap+xml; charset=utf-8
        Content-Length: 1289

        And xmlHttpRequest. responseXML.par seError.errorCo de is 0. So i think no
        error.
        Where is my problem ?
        Thanks,

        "Martin Honnen" <mahotrash@yaho o.dea écrit dans le message de news:
        eOynoEwuGHA.122 4@TK2MSFTNGP03. phx.gbl...
        >
        >
        KaNos wrote:
        >
        >
        >xmlHttpRequest .open("POST", myAddressLocati on, false);
        >xmlHttpRequest .setRequestHead er("Content-Type", "text/xml;
        >charset=utf-8");
        >xmlHttpRequest .send(xmldocume ntSoapRequest);
        >if (xmlHttpRequest .readyState == 4)
        >{
        > alert(xmlHttpRe quest.responseT ext); // response ok
        >>
        > var xmldocumentSoap Response = xmlHttpRequest. responseXML;
        >>
        > alert(xmldocume ntSoapResponse. documentElement == null); // response
        >is true ?
        >
        Check xmlHttpRequest. getAllResponseH eaders(), what does that show, in
        particular for the HTTP Content-Type header?
        And if that is script with IE then check
        xmlHttpRequest. responseXML.par seError.errorCo de
        If that is not 0 then check
        xmlHttpRequest. responseXML.par seError.reason
        >
        --
        >
        Martin Honnen --- MVP XML
        http://JavaScript.FAQTs.com/


        Comment

        • Martin Honnen

          #5
          Re: [Javascript] problem with ResponseXml.



          KaNos wrote:

          The HTTP Header is :
          >
          Server: Microsoft-IIS/5.1
          Date: Tue, 08 Aug 2006 15:54:04 GMT
          X-Powered-By: ASP.NET
          X-AspNet-Version: 2.0.50727
          Cache-Control: private, max-age=0
          Content-Type: application/soap+xml; charset=utf-8
          Content-Length: 1289
          >
          And xmlHttpRequest. responseXML.par seError.errorCo de is 0. So i think no
          error.
          Where is my problem ?
          I think the problem is
          Content-Type: application/soap+xml
          which is probably technically correct but not recognized by
          MSXML/XMLHttpRequest as an XML MIME type, it only looks for
          application/xml or text/xml to decide whether to populate responseXML.

          So you either need to change the server to send the generic XML
          Content-Type application/xml or you need to try to solve that on the
          client where with MSXML/IE you could do e.g.
          xmlHttpRequest. responseXML.loa d(xmlHttpReques t.responseBody)
          when you receive the response.

          With Mozilla you can do
          xmlHttpRequest. overrideMimeTyp e('application/xml')
          before you send the request to convince it to parse the response as XML
          into the responseXML object even if the Content-Type the server sends is
          not recognized as an XML MIME type.



          --

          Martin Honnen --- MVP XML

          Comment

          • KaNos

            #6
            Re: [Javascript] problem with ResponseXml.

            Great Martin,
            I've developed the webservice in C# with DotNet V2. Do uou know how can
            i do to change the XML MIME type directly in the webservice source code ?
            Real Thanks,

            "Martin Honnen" <mahotrash@yaho o.dea écrit dans le message de news:
            %233QrtbwuGHA.3 936@TK2MSFTNGP0 4.phx.gbl...
            >
            >
            KaNos wrote:
            >
            >
            > The HTTP Header is :
            >>
            >Server: Microsoft-IIS/5.1
            >Date: Tue, 08 Aug 2006 15:54:04 GMT
            >X-Powered-By: ASP.NET
            >X-AspNet-Version: 2.0.50727
            >Cache-Control: private, max-age=0
            >Content-Type: application/soap+xml; charset=utf-8
            >Content-Length: 1289
            >>
            >And xmlHttpRequest. responseXML.par seError.errorCo de is 0. So i think no
            >error.
            >Where is my problem ?
            >
            I think the problem is
            Content-Type: application/soap+xml
            which is probably technically correct but not recognized by
            MSXML/XMLHttpRequest as an XML MIME type, it only looks for
            application/xml or text/xml to decide whether to populate responseXML.
            >
            So you either need to change the server to send the generic XML
            Content-Type application/xml or you need to try to solve that on the
            client where with MSXML/IE you could do e.g.
            xmlHttpRequest. responseXML.loa d(xmlHttpReques t.responseBody)
            when you receive the response.
            >
            With Mozilla you can do
            xmlHttpRequest. overrideMimeTyp e('application/xml')
            before you send the request to convince it to parse the response as XML
            into the responseXML object even if the Content-Type the server sends is
            not recognized as an XML MIME type.
            >
            >
            >
            --
            >
            Martin Honnen --- MVP XML
            http://JavaScript.FAQTs.com/

            Comment

            • Martin Honnen

              #7
              Re: [Javascript] problem with ResponseXml.



              KaNos wrote:

              I've developed the webservice in C# with DotNet V2. Do uou know how can
              i do to change the XML MIME type directly in the webservice source code ?
              If your class implementing the web service inherits from the WebService
              class then in the web service methods I think it should be possible to
              do e.g.
              Context.Respons e.ContentType = "applicatio n/xml";
              I haven't tried that however. Let us know whether that approach works
              for you.




              --

              Martin Honnen --- MVP XML

              Comment

              • KaNos

                #8
                Re: [Javascript] problem with ResponseXml.

                Ok, I found a solution.
                To the web service was a SOAP 1.2 request with the namespace

                just change it with a SOAP 1.1 request with
                xmlns=http://www.w3.org/2003/05/soap-envelope and now it works fine.
                Real thanks Martin.


                "Martin Honnen" <mahotrash@yaho o.dea écrit dans le message de news:
                u7g3tRxuGHA.151 2@TK2MSFTNGP03. phx.gbl...
                >
                >
                KaNos wrote:
                >
                >
                > I've developed the webservice in C# with DotNet V2. Do uou know how
                >can i do to change the XML MIME type directly in the webservice source
                >code ?
                >
                If your class implementing the web service inherits from the WebService
                class then in the web service methods I think it should be possible to do
                e.g.
                Context.Respons e.ContentType = "applicatio n/xml";
                I haven't tried that however. Let us know whether that approach works for
                you.
                >
                >
                >
                >
                --
                >
                Martin Honnen --- MVP XML
                http://JavaScript.FAQTs.com/

                Comment

                Working...