[wsf-javascript-dev] svn commit r3500 - trunk/wsf/javascript/native/src
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Jonathan,
Following commit, line 197 (if (newDoc.documentElement.tagName ==
soapPrefix + "Fault") {) will fail in browsers other than IE or IE7.
In the prior "If" statement to be valid, "soapPrefix" is a MUST. This is
the reason why I've added "soapPrefix = response.prefix". As you have
said, .prefix is not universal, we need to get the soapPrefix before
doing the prior if statement.
Thank you
Saminda
svn@wso2.org wrote:
> Author: jonathan
> Date: Mon Jun 4 18:33:42 2007
> New Revision: 3500
>
> Modified:
> trunk/wsf/javascript/native/src/WSRequest.js
> Log:
> Added workaround for IE receiving application/xml+soap and then not populating the responseXML for this "unknown" media type.
>
> Also improved some of the error checking.
>
> Modified: trunk/wsf/javascript/native/src/WSRequest.js
> ==============================================================================
> --- trunk/wsf/javascript/native/src/WSRequest.js (original)
> +++ trunk/wsf/javascript/native/src/WSRequest.js Mon Jun 4 18:33:42 2007
> @@ -158,57 +158,62 @@
> this.error = null; // How would I tell?
> } else {
> var browser = WSRequest.util._getBrowser();
> -
> - var response = this._xmlhttp.responseXML.documentElement;
> - if (response) {
> +
> + if (this._xmlhttp.responseText != "") {
> + if ((browser == "ie" || browser == "ie7") && this._xmlhttp.responseXML.documentElement == null) {
> + // unrecognized media type (probably application/soap+xml)
> + var responseXMLdoc = new ActiveXObject("Microsoft.XMLDOM");
> + responseXMLdoc.loadXML(this._xmlhttp.responseText);
> + var response = responseXMLdoc.documentElement;
> + } else {
> + var response = this._xmlhttp.responseXML.documentElement;
> + }
> var soapPrefix = "";
> if (browser == "ie" || browser == "ie7") {
> i = response.tagName.indexOf(':');
> - soapPrefix = (i < 0) ? "" : response.tagName.substring(0, i + 1);
> + soapPrefix = (i<0) ? "" : response.tagName.substring(0,i+1);
> }
> var soapBody = response.getElementsByTagName(soapPrefix + "Body")[0];
> -
> if (soapBody != null && soapBody.hasChildNodes()) {
> - // Need to set the prefix for fault handling
> - soapPrefix = response.prefix;
> -
> - var newDoc;
> +
> + var newDoc;
> if (browser == "gecko")
> {
> try {
> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
> } catch(e) {
> }
> - var newDoc = document.implementation.createDocument("", "", null);
> + var newDoc = document.implementation.createDocument("","",null);
> newDoc.appendChild(soapBody.firstChild);
> }
> -
> +
> if (browser == "ie" || browser == "ie7") {
> var newDoc = new ActiveXObject("Microsoft.XMLDOM");
> newDoc.appendChild(soapBody.firstChild);
> }
> -
> +
> this.responseXML = newDoc;
> this.responseText = WSRequest.util._serializeToString(newDoc);
> -
> - if (newDoc.documentElement.tagName == soapPrefix + ":Fault") {
> + if (newDoc.documentElement.tagName == soapPrefix + "Fault") {
> this.error = new WSError();
> this.error.code = newDoc.getElementsByTagName("faultcode")[0].firstChild.nodeValue;
> this.error.reason = newDoc.getElementsByTagName("faultstring")[0].firstChild.nodeValue;
> this.error.detail =
> WSRequest.util._serializeToString(newDoc.getElementsByTagName("detail")[0]);
> }
> -
> } else {
> + // empty SOAP body - not necessarily an error
> this.responseXML = null;
> this.responseText = "";
> this.error = null;
> - // Should there be a fault for no response?
> }
> - }else {
> + } else {
> this.responseXML = null;
> this.responseText = "";
> - this.error = null;
> + this.error = new WSError();
> + this.error.code = "HTTP" + this._xmlhttp.status;
> + this.error.reason = "No SOAP Body.";
> + this.error.detail = this._xmlhttp.statusText;
> }
> }
> }
>
> _______________________________________________
> Wsf-javascript-dev mailing list
> Wsf-javascript-dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/wsf-javascript-dev
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGZR/NYmklbLuW6wYRAv75AJ9Qk2Gqcd5Rq30LT4oh6FAs+/+S/ACgpKu5
YyBLO4ginF8naqAa5coeuWA=
=l8a7
-----END PGP SIGNATURE-----
_______________________________________________
Wsf-javascript-dev mailing list
Wsf-javascript-dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/wsf-javascript-dev
- Login or register to post comments
- Printer friendly version
- 913 reads











RE: [wsf-javascript-dev] svn commit r3500 - trunk/wsf/javascript
Oh, that is truly ugly. When you get a DOM back from Firefox's XMLHTTP object, it gives you a DOM that ignores namespaces (at least as far as getElementsByTagName is concerned). But if you make a new DOM, namespaces aren't ignored. Inconcievable!
I needed a more general solution to improve fault handling, so I changed the code to do browser-specific TRUE namespace matching. Hope this meets with your approval.
Jonathan Marsh - http://www.wso2.com - http://auburnmarshes.spaces.live.com
> -----Original Message-----
> From: saminda abeyruwan [mailto:saminda@wso2.com]
> Sent: Tuesday, June 05, 2007 1:33 AM
> To: wsf-javascript-dev@wso2.org
> Cc: Jonathan Marsh
> Subject: Re: [wsf-javascript-dev] svn commit r3500 -
> trunk/wsf/javascript/native/src
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Jonathan,
>
> Following commit, line 197 (if (newDoc.documentElement.tagName ==
> soapPrefix + "Fault") {) will fail in browsers other than IE or IE7.
>
> In the prior "If" statement to be valid, "soapPrefix" is a MUST. This
> is
> the reason why I've added "soapPrefix = response.prefix". As you have
> said, .prefix is not universal, we need to get the soapPrefix before
> doing the prior if statement.
>
> Thank you
>
> Saminda
>
> svn@wso2.org wrote:
> > Author: jonathan
> > Date: Mon Jun 4 18:33:42 2007
> > New Revision: 3500
> >
> > Modified:
> > trunk/wsf/javascript/native/src/WSRequest.js
> > Log:
> > Added workaround for IE receiving application/xml+soap and then not
> populating the responseXML for this "unknown" media type.
> >
> > Also improved some of the error checking.
> >
> > Modified: trunk/wsf/javascript/native/src/WSRequest.js
> >
> =======================================================================
> =======
> > --- trunk/wsf/javascript/native/src/WSRequest.js (original)
> > +++ trunk/wsf/javascript/native/src/WSRequest.js Mon Jun 4
> 18:33:42 2007
> > @@ -158,57 +158,62 @@
> > this.error = null; // How would I tell?
> > } else {
> > var browser = WSRequest.util._getBrowser();
> > -
> > - var response = this._xmlhttp.responseXML.documentElement;
> > - if (response) {
> > +
> > + if (this._xmlhttp.responseText != "") {
> > + if ((browser == "ie" || browser == "ie7") &&
> this._xmlhttp.responseXML.documentElement == null) {
> > + // unrecognized media type (probably
> application/soap+xml)
> > + var responseXMLdoc = new
> ActiveXObject("Microsoft.XMLDOM");
> > + responseXMLdoc.loadXML(this._xmlhttp.responseText);
> > + var response = responseXMLdoc.documentElement;
> > + } else {
> > + var response =
> this._xmlhttp.responseXML.documentElement;
> > + }
> > var soapPrefix = "";
> > if (browser == "ie" || browser == "ie7") {
> > i = response.tagName.indexOf(':');
> > - soapPrefix = (i < 0) ? "" :
> response.tagName.substring(0, i + 1);
> > + soapPrefix = (i<0) ? "" :
> response.tagName.substring(0,i+1);
> > }
> > var soapBody = response.getElementsByTagName(soapPrefix
> + "Body")[0];
> > -
> > if (soapBody != null && soapBody.hasChildNodes()) {
> > - // Need to set the prefix for fault handling
> > - soapPrefix = response.prefix;
> > -
> > - var newDoc;
> > +
> > + var newDoc;
> > if (browser == "gecko")
> > {
> > try {
> >
> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRea
> d");
> > } catch(e) {
> > }
> > - var newDoc =
> document.implementation.createDocument("", "", null);
> > + var newDoc =
> document.implementation.createDocument("","",null);
> > newDoc.appendChild(soapBody.firstChild);
> > }
> > -
> > +
> > if (browser == "ie" || browser == "ie7") {
> > var newDoc = new
> ActiveXObject("Microsoft.XMLDOM");
> > newDoc.appendChild(soapBody.firstChild);
> > }
> > -
> > +
> > this.responseXML = newDoc;
> > this.responseText =
> WSRequest.util._serializeToString(newDoc);
> > -
> > - if (newDoc.documentElement.tagName == soapPrefix +
> ":Fault") {
> > + if (newDoc.documentElement.tagName == soapPrefix +
> "Fault") {
> > this.error = new WSError();
> > this.error.code =
> newDoc.getElementsByTagName("faultcode")[0].firstChild.nodeValue;
> > this.error.reason =
> newDoc.getElementsByTagName("faultstring")[0].firstChild.nodeValue;
> > this.error.detail =
> >
> WSRequest.util._serializeToString(newDoc.getElementsByTagName("detail")
> [0]);
> > }
> > -
> > } else {
> > + // empty SOAP body - not necessarily an error
> > this.responseXML = null;
> > this.responseText = "";
> > this.error = null;
> > - // Should there be a fault for no response?
> > }
> > - }else {
> > + } else {
> > this.responseXML = null;
> > this.responseText = "";
> > - this.error = null;
> > + this.error = new WSError();
> > + this.error.code = "HTTP" + this._xmlhttp.status;
> > + this.error.reason = "No SOAP Body.";
> > + this.error.detail = this._xmlhttp.statusText;
> > }
> > }
> > }
> >
> > _______________________________________________
> > Wsf-javascript-dev mailing list
> > Wsf-javascript-dev@wso2.org
> > http://wso2.org/cgi-bin/mailman/listinfo/wsf-javascript-dev
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGZR/NYmklbLuW6wYRAv75AJ9Qk2Gqcd5Rq30LT4oh6FAs+/+S/ACgpKu5
> YyBLO4ginF8naqAa5coeuWA=
> =l8a7
> -----END PGP SIGNATURE-----
_______________________________________________
Wsf-javascript-dev mailing list
Wsf-javascript-dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/wsf-javascript-dev