-----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