Closed Bug 202597 Opened 21 years ago Closed 21 years ago

SOAP services do not honor XML Schema subtype rules for xsi:type

Categories

(Core :: XML, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: rayw, Assigned: rayw)

References

Details

Attachments

(1 file)

Often, there is an element in the schema in the WSDL file that has been assigned
a fairly-specific subtype.  But then xsi:type appears on the element, and,
instead of being a subtype is a more-common supertype.  This is an error from an
xml schema perspective, but since SOAP doesn't care about schema validity, they
don't care that this is common.

For example, the schema file may declare a new type called ArrayOfString which
derives from soap-enc:Array and declares that the subtype is a string.  But then
when the element appears, xsi:type="soap-enc:Array" is attached, which according
to schema should be a subtype.

The current code carefully checks and rejects it if this does not hold true.

It needs to be patched so that it effectively ignores the xsi:type if it is not
a proper subtype of the schema-guaranteed type.  At least that is my theory for
today.
Comment on attachment 121197 [details] [diff] [review]
Patch v1.0 [ provided by rayw@netscape.com ]

>Index: extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp,v
>retrieving revision 1.70
>diff -u -u -r1.70 nsDefaultSOAPEncoder.cpp
>--- extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp	18 Apr 2003 00:11:34 -0000	1.70
>+++ extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp	21 Apr 2003 17:01:16 -0000
>@@ -1894,7 +1894,7 @@
>       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)) {
>@@ -1990,38 +1990,46 @@
>       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<nsISchemaType> supertype;
>+          rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype));
>           if (NS_FAILED(rc))
>             return rc;
>+          lookupType = supertype;
>+        } while (lookupType);
>+        if (!type) {
>+          type = subsubType;
>+          break;
>         }
>-        nsCOMPtr<nsISchemaType> 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) {
Attachment #121197 - Flags: superreview?(jst)
Attachment #121197 - Flags: review+
Comment on attachment 121197 [details] [diff] [review]
Patch v1.0 [ provided by rayw@netscape.com ]

@@ -1894,7 +1894,7 @@
       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)) {

If you grab more context for the above code, you'll see:

      nsAutoString oldstyle;
      encoding->GetStyleURI(oldstyle);

Add "rv = " before the above line.

      if (NS_FAILED(rv))
	return rv;
      nsAutoString style;
      encoding->GetStyleURI(style);

Same here (as you did in the patch).

      if (NS_FAILED(rv))
	return rv;
      if (!style.Equals(oldstyle)) {
	nsCOMPtr < nsISOAPEncoding > newencoding;
	encoding->GetAssociatedEncoding(style, PR_FALSE,
					getter_AddRefs(newencoding));

And same here too!

	if (NS_FAILED(rv))
	  return rv;

sr=jst with the above fixed.
Attachment #121197 - Flags: superreview?(jst) → superreview+
Fix checked in with jst's suggestions.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Blocks: 190182
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: