From c8fd40887c22e5e6945875ae2dbeefeace805f32 Mon Sep 17 00:00:00 2001 From: "harishd%netscape.com" Date: Mon, 21 Apr 2003 23:23:26 +0000 Subject: [PATCH] Patch provided by rayw@netscape.com: Ignore xsi:type if it's not a proper subtype of the schema-guaranteed type. b=202597, r=harishd@netscape.com, sr=jst@netscape.com git-svn-id: svn://10.0.0.236/trunk@141543 18797224-902f-48f8-a5cc-f745e15eee43 --- .../soap/src/nsDefaultSOAPEncoder.cpp | 74 ++++++++++--------- .../soap/src/nsDefaultSOAPEncoder.cpp | 74 ++++++++++--------- 2 files changed, 82 insertions(+), 66 deletions(-) diff --git a/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp b/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp index 34f5dfd0e3a..fae75996466 100644 --- a/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp +++ b/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp @@ -1890,17 +1890,17 @@ NS_IMETHODIMP return rv; if (enc) { nsAutoString oldstyle; - encoding->GetStyleURI(oldstyle); + rv = encoding->GetStyleURI(oldstyle); if (NS_FAILED(rv)) return rv; nsAutoString style; - encoding->GetStyleURI(style); + rv = enc->GetNodeValue(style); if (NS_FAILED(rv)) return rv; if (!style.Equals(oldstyle)) { nsCOMPtr < nsISOAPEncoding > newencoding; - encoding->GetAssociatedEncoding(style, PR_FALSE, - getter_AddRefs(newencoding)); + rv = encoding->GetAssociatedEncoding(style, PR_FALSE, + getter_AddRefs(newencoding)); if (NS_FAILED(rv)) return rv; if (newencoding) { @@ -1990,38 +1990,46 @@ NS_IMETHODIMP subsubType = subType; if (subsubType) { // Loop up the hierarchy, to check and look for decoders - nsCOMPtr < nsISchemaType > lookupType = subsubType; - do { - if (lookupType == subType) { // Tick off the located super classes - subType = nsnull; - } - if (lookupType == type) { // Tick off the located super classes - type = nsnull; - } - if (!decoder) { - nsAutoString schemaType; - nsAutoString schemaURI; - nsresult rc = lookupType->GetName(schemaType); - if (NS_FAILED(rc)) - return rc; - rc = lookupType->GetTargetNamespace(schemaURI); - if (NS_FAILED(rc)) - return rc; - nsAutoString encodingKey; - SOAPEncodingKey(schemaURI, schemaType, encodingKey); - rc = aEncoding->GetDecoder(encodingKey, getter_AddRefs(decoder)); + for(;;) { + nsCOMPtr < nsISchemaType > lookupType = subsubType; + do { + if (lookupType == subType) { // Tick off the located super classes + subType = nsnull; + } + if (lookupType == type) { // Tick off the located super classes + type = nsnull; + } + if (!decoder) { + nsAutoString schemaType; + nsAutoString schemaURI; + nsresult rc = lookupType->GetName(schemaType); + if (NS_FAILED(rc)) + return rc; + rc = lookupType->GetTargetNamespace(schemaURI); + if (NS_FAILED(rc)) + return rc; + nsAutoString encodingKey; + SOAPEncodingKey(schemaURI, schemaType, encodingKey); + rc = aEncoding->GetDecoder(encodingKey, getter_AddRefs(decoder)); + if (NS_FAILED(rc)) + return rc; + } + nsCOMPtr supertype; + rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype)); if (NS_FAILED(rc)) return rc; + lookupType = supertype; + } while (lookupType); + if (!type) { + type = subsubType; + break; } - nsCOMPtr supertype; - rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype)); - if (NS_FAILED(rc)) - return rc; - lookupType = supertype; - } while (lookupType); - if (type || subType) // If the proper subclass relationships didn't exist, then error return. - return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_TYPE_SUBCLASS","The type of the element or xsi:type must be a subclass of the required type."); - type = subsubType; // If they did, then we now have a new, better type. + decoder = nsnull; + if (!subType) { + subType = type; + } + subsubType = subType; + } } } if (!decoder) { diff --git a/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp b/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp index 34f5dfd0e3a..fae75996466 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp @@ -1890,17 +1890,17 @@ NS_IMETHODIMP return rv; if (enc) { nsAutoString oldstyle; - encoding->GetStyleURI(oldstyle); + rv = encoding->GetStyleURI(oldstyle); if (NS_FAILED(rv)) return rv; nsAutoString style; - encoding->GetStyleURI(style); + rv = enc->GetNodeValue(style); if (NS_FAILED(rv)) return rv; if (!style.Equals(oldstyle)) { nsCOMPtr < nsISOAPEncoding > newencoding; - encoding->GetAssociatedEncoding(style, PR_FALSE, - getter_AddRefs(newencoding)); + rv = encoding->GetAssociatedEncoding(style, PR_FALSE, + getter_AddRefs(newencoding)); if (NS_FAILED(rv)) return rv; if (newencoding) { @@ -1990,38 +1990,46 @@ NS_IMETHODIMP subsubType = subType; if (subsubType) { // Loop up the hierarchy, to check and look for decoders - nsCOMPtr < nsISchemaType > lookupType = subsubType; - do { - if (lookupType == subType) { // Tick off the located super classes - subType = nsnull; - } - if (lookupType == type) { // Tick off the located super classes - type = nsnull; - } - if (!decoder) { - nsAutoString schemaType; - nsAutoString schemaURI; - nsresult rc = lookupType->GetName(schemaType); - if (NS_FAILED(rc)) - return rc; - rc = lookupType->GetTargetNamespace(schemaURI); - if (NS_FAILED(rc)) - return rc; - nsAutoString encodingKey; - SOAPEncodingKey(schemaURI, schemaType, encodingKey); - rc = aEncoding->GetDecoder(encodingKey, getter_AddRefs(decoder)); + for(;;) { + nsCOMPtr < nsISchemaType > lookupType = subsubType; + do { + if (lookupType == subType) { // Tick off the located super classes + subType = nsnull; + } + if (lookupType == type) { // Tick off the located super classes + type = nsnull; + } + if (!decoder) { + nsAutoString schemaType; + nsAutoString schemaURI; + nsresult rc = lookupType->GetName(schemaType); + if (NS_FAILED(rc)) + return rc; + rc = lookupType->GetTargetNamespace(schemaURI); + if (NS_FAILED(rc)) + return rc; + nsAutoString encodingKey; + SOAPEncodingKey(schemaURI, schemaType, encodingKey); + rc = aEncoding->GetDecoder(encodingKey, getter_AddRefs(decoder)); + if (NS_FAILED(rc)) + return rc; + } + nsCOMPtr supertype; + rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype)); if (NS_FAILED(rc)) return rc; + lookupType = supertype; + } while (lookupType); + if (!type) { + type = subsubType; + break; } - nsCOMPtr supertype; - rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype)); - if (NS_FAILED(rc)) - return rc; - lookupType = supertype; - } while (lookupType); - if (type || subType) // If the proper subclass relationships didn't exist, then error return. - return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_TYPE_SUBCLASS","The type of the element or xsi:type must be a subclass of the required type."); - type = subsubType; // If they did, then we now have a new, better type. + decoder = nsnull; + if (!subType) { + subType = type; + } + subsubType = subType; + } } } if (!decoder) {