473,473 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[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", myAddressLocation, false);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.send(xmldocumentSoapRequest);
if (xmlHttpRequest.readyState == 4)
{
alert(xmlHttpRequest.responseText); // response ok

var xmldocumentSoapResponse = xmlHttpRequest.responseXML;

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

The well formed webservice response with responseText.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://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>
<InitializeResponse xmlns="http://www.euristyle.com/">
<InitializeResult>
<cocd xmlns="http://ltsc.ieee.org/xsd/1484_11_3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ltsc.ieee.org/xsd/1484_11_3ieee_1484_11_3_2005.xsd">
<commentsFromLearner/>
<commentsFromLMS/>
<completionStatus>unknown</completionStatus>
<completionThreshold/>
<credit>credit</credit>
<entry>ab_initio</entry>
<exit/>
<interactions/>
<launchData/>
<learnerId>1234567890</learnerId>
<learnerName>My</learnerName>
<learnerPreferenceData>
<audioCaptioning>no_change</audioCaptioning>
<audioLevel>1</audioLevel>
<deliverySpeed>1</deliverySpeed>
<language>fr-FR</language>
</learnerPreferenceData>
<location/>
<maxTimeAllowed/>
<mode>normal</mode>
<objectives/>
<progressMeasure/>
<scaledPassingScore/>
<score/>
<sessionTime/>
<successStatus>unknown</successStatus>
<suspendData/>
<timeLimitAction>continue_no_message</timeLimitAction>
<totalTime>PT0S</totalTime>
<dataModelVersion>1.0</dataModelVersion>
</cocd>
</InitializeResult>
</InitializeResponse>
</soap:Body>
</soap:Envelope>
Aug 8 '06 #1
7 4992


KaNos wrote:

xmlHttpRequest.open("POST", myAddressLocation, false);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.send(xmldocumentSoapRequest);
if (xmlHttpRequest.readyState == 4)
{
alert(xmlHttpRequest.responseText); // response ok

var xmldocumentSoapResponse = xmlHttpRequest.responseXML;

alert(xmldocumentSoapResponse.documentElement == null); // response is
true ?
Check xmlHttpRequest.getAllResponseHeaders(), what does that show, in
particular for the HTTP Content-Type header?
And if that is script with IE then check
xmlHttpRequest.responseXML.parseError.errorCode
If that is not 0 then check
xmlHttpRequest.responseXML.parseError.reason

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 8 '06 #2
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.parseError.errorCode is 0. So i think no
error.
Where is my problem ?
Thanks,

"Martin Honnen" <ma*******@yahoo.dea écrit dans le message de news:
eO**************@TK2MSFTNGP03.phx.gbl...
>

KaNos wrote:

>xmlHttpRequest.open("POST", myAddressLocation, false);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
xmlHttpRequest.send(xmldocumentSoapRequest);
if (xmlHttpRequest.readyState == 4)
{
alert(xmlHttpRequest.responseText); // response ok

var xmldocumentSoapResponse = xmlHttpRequest.responseXML;

alert(xmldocumentSoapResponse.documentElement == null); // response
is true ?

Check xmlHttpRequest.getAllResponseHeaders(), what does that show, in
particular for the HTTP Content-Type header?
And if that is script with IE then check
xmlHttpRequest.responseXML.parseError.errorCode
If that is not 0 then check
xmlHttpRequest.responseXML.parseError.reason

--

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

Aug 8 '06 #3
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.parseError.errorCode is 0. So i think no
error.
Where is my problem ?
Thanks,

"Martin Honnen" <ma*******@yahoo.dea écrit dans le message de news:
eO**************@TK2MSFTNGP03.phx.gbl...
>

KaNos wrote:

>xmlHttpRequest.open("POST", myAddressLocation, false);
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
xmlHttpRequest.send(xmldocumentSoapRequest);
if (xmlHttpRequest.readyState == 4)
{
alert(xmlHttpRequest.responseText); // response ok

var xmldocumentSoapResponse = xmlHttpRequest.responseXML;

alert(xmldocumentSoapResponse.documentElement == null); // response
is true ?

Check xmlHttpRequest.getAllResponseHeaders(), what does that show, in
particular for the HTTP Content-Type header?
And if that is script with IE then check
xmlHttpRequest.responseXML.parseError.errorCode
If that is not 0 then check
xmlHttpRequest.responseXML.parseError.reason

--

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


Aug 8 '06 #4


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.parseError.errorCode 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.load(xmlHttpRequest.res ponseBody)
when you receive the response.

With Mozilla you can do
xmlHttpRequest.overrideMimeType('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/
Aug 8 '06 #5
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" <ma*******@yahoo.dea écrit dans le message de news:
%2****************@TK2MSFTNGP04.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.parseError.errorCode 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.load(xmlHttpRequest.res ponseBody)
when you receive the response.

With Mozilla you can do
xmlHttpRequest.overrideMimeType('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/

Aug 8 '06 #6


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.Response.ContentType = "application/xml";
I haven't tried that however. Let us know whether that approach works
for you.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 8 '06 #7
Ok, I found a solution.
To the web service was a SOAP 1.2 request with the namespace
http://schemas.xmlsoap.org/soap/envelope/
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" <ma*******@yahoo.dea écrit dans le message de news:
u7**************@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.Response.ContentType = "application/xml";
I haven't tried that however. Let us know whether that approach works for
you.


--

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

Aug 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mikeyjudkins | last post by:
Ive been banging my head on the wall for hours with this one, hopefully someone will know what Im doing wrong here :\ The Goal: I have an xml file that is generated on the fly via JSP which I...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
2
by: Yorian | last post by:
Hi, Another problem another question (as usual). I want to retrieve data through ajax, within the data there is some javascript which needs to be used (I figured that one out using eval ())....
2
by: quindo | last post by:
Hello, I've searched the internet but couldn't find an answer so I'm hoping someone here can help me. A webpage recieves XML from the server using xmlhttp. What I want to do is search in this...
3
by: trentula | last post by:
I've just recently gotten around to JavaScript, especially its brand of OOP, and for the life of me can't figure out why this code doesn't work. Any help will be greatly appreciated. function...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.