mrcl23 / xmlrpcnet

Automatically exported from code.google.com/p/xmlrpcnet
0 stars 0 forks source link

there is no possibility to allow <nil/> values in response #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
we need some times to return some values with <nil/>, thats not in xml-rpc
standard but have to be in xml-rpc extension.

we fixed our client with this diff:

--- XmlRpcSerializer.cs   2008-09-19 14:32:01.000000000 +0200
+++ XmlRpcSerializer.cs 2008-04-30 08:56:44.000000000 +0200
@@ -867,10 +867,6 @@
           ParsedType = typeof(DateTime);
           ParsedArrayType = typeof(DateTime[]);
         }
-        else if (node.Name == "nil")
-        {
-            return "";
-        }
       }
       return retObj;
     }

i don't really know if this is the right solution for this problem.

Original issue reported on code.google.com by 4maxim@gmail.com on 19 Sep 2008 at 1:02

GoogleCodeExporter commented 9 years ago
Hello,

We had the same problem communicating with Magento (written in PHP -
http://www.magentocommerce.com/).
<value><nil/></value> seem to be a common practice...

As said above, the thing is that in the method ParseValue method (file
XmlRpcSerializer:869) there is no "else if(node.Name == "nil")" and in this 
case, the
method returns null. Which is fine in our case.

But later, the code wants to get the type of the value and so throws a
NullReferenceException.
We resolved the problem by adding a test before getting value:
File XmlRpcStruct.cs:39, replace
      if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 
by
      if (value != null && XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 

Even if the "<nil/>" is not standard and not supposed to be supported, to my 
sense,
the fact that there is no final "else" case and then later throw a
NullReferenceException when the situation is reached is a bug.
The lib should explicitely exclude the unsupported cases by adding something 
like
      else{ throw new NotSupportedException("some message"); }
or at least make an Assert.

Original comment by alainca...@gmail.com on 16 Dec 2008 at 2:48

GoogleCodeExporter commented 9 years ago

Original comment by ChasC...@gmail.com on 19 Dec 2008 at 1:58

GoogleCodeExporter commented 9 years ago
I also need this to be completed. The Wikidot.com API uses <nil/> for some of 
it's responses.

I will try modifying my copy of the library based on the suggestions above, but 
I'd certainly appreciate it being part of the official release.

Thanks,
Shane

Original comment by Leige...@gmail.com on 16 Oct 2010 at 8:53

GoogleCodeExporter commented 9 years ago
<nil/> values supported in release 3.0

Original comment by ChasC...@gmail.com on 6 Mar 2011 at 10:08

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by Leige...@gmail.com on 6 Mar 2011 at 10:27