[Mono-devel-list] [patch] handle SOAP invocation without arguments in SoapReader

Lluis Sanchez lluis at ximian.com
Mon Sep 13 13:16:42 EDT 2004


Patch commited.
Thanks!

Lluis.

On dl, 2004-09-13 at 04:36 +0200, Stefan Paletta wrote:
> Hi!
> 
> Funny enough, SoapReader does not handle calls to methods that take no
> arguments if serialized as an empty element (every SOAP client I
> tested does that, including Mono itself).
> 
> Deserialize(Stream,ISoapMessage) reads the XML until after <soap:Body>,
> then hands off to the code in DeserializeMessage(ISoapMessage) below,
> and expects to be able to read the closing </soap:Body></soap:Envelope>
> tags afterwards.
> If the SOAP invocation was delivered as an empty element, e.g.
> <soap:Body><ns1:TheMethod /></soap:Body>, the code below read until
> after </soap:Body> as it expected <ns1:TheMethod></ns1:TheMethod>
> rather than an empty element, and later the caller would encounter an
> XmlException on its last call to xmlReader.ReadEndElement() due to
> having reached EOF.
> 
> Attached is a patch to fix this issue, a diff -w is included below for
> your reading convenience.
> 
> --- SoapReader.cs	24 Aug 2004 14:36:07 -0000	1.13
> +++ SoapReader.cs	13 Sep 2004 01:47:18 -0000
> @@ -228,9 +228,11 @@
>  			long paramValuesId = NextAvailableId;
>  			int[] indices = new int[1];
>  
> +			if (!xmlReader.IsEmptyElement)
> +			{
> +				int i = 0;
>  			int initialDepth = xmlReader.Depth;
>  			xmlReader.Read();
> -			int i = 0;
>  			while(xmlReader.Depth > initialDepth) 
>  			{
>  				long paramId, paramHref;
> @@ -266,10 +268,15 @@
>  				}
>  				i++;
>  			}
> +				xmlReader.ReadEndElement();
> +			}
> +			else
> +			{
> +				xmlReader.Read();
> +			}
>  
>  			message.ParamNames = (string[]) paramNames.ToArray(typeof(string));
>  			message.ParamValues = paramValues.ToArray();
> -			xmlReader.ReadEndElement();
>  			RegisterObject(paramValuesId, message.ParamValues, null, 0, null, null);
>  			return true;
>  		}
> 
> -Stefan




More information about the Mono-devel-list mailing list