[Mono-dev] Serialization problem in WCF

SuperCiccio sc_030268 at yahoo.it
Fri Aug 6 10:14:07 EDT 2010


I'm using Mono 2.6.7/MS .NET 3.5SP1
I have a serialization problem trying to make Mono WCF interact with MS WCF.

The service is defined as the following:

    [OperationContract]
    ServiceResult<string> TestMethod(string varA, int varB);

where ServiceResult<T> is a generic class for returning results, so defined:

    [Serializable]
    public class ServiceResult<T> : ServiceResult
    {
        public T Value { get; set; }
    }

where ServiceResult is in turn roughly

    [Serializable]
    public class ServiceResult
    {
        public bool Error { get; set; }
        public List<ResultInfo> ResultInfoList { get; set; }
    }

and so on..

When talking Mono <-> Mono or MS <-> MS all goes well, but when trying to
make them interact problems arise.
In particular, with Mono server, when the message returns to client (the
call terminates correctly on server) there are deserialization errors:

1) using netTcpBinding

System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter
threw an exception while trying to deserialize the message: There was an
error while trying to deserialize parameter
http://tempuri.org/:TestMethodResult. The InnerException message was
''EndElement' 'TestMethodResult' from namespace 'http://tempuri.org/' is not
expected. Expecting element '_x003C_Error_x003E_k__BackingField'.'.  Please
see InnerException for more details. --->
System.Runtime.Serialization.SerializationException: ...
   at
System.Runtime.Serialization.XmlObjectSerializerReadContext.ThrowRequiredMemberMissingException(XmlReaderDelegator
xmlReader, Int32 memberIndex, Int32 requiredIndex, XmlDictionaryString[]
memberNames)
   at ReadServiceResultOfstringFromXml(XmlReaderDelegator ,
XmlObjectSerializerReadContext , XmlDictionaryString[] ,
XmlDictionaryString[] )
   at
System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator
xmlReader, XmlObjectSerializerReadContext context)
   at
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator
reader, String name, String ns, DataContract& dataContract)


2) using basicHttpBinding

System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter
threw an exception while trying to deserialize the message: There was an
error while trying to deserialize parameter
http://tempuri.org/:TestMethodResult. The InnerException message was 'There
was an error deserializing the object of type
myApp.ServiceResult`1[[System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]. The '<' character,
hexadecimal value 0x3C, cannot be included in a name. Line 1, position
304.'.  Please see InnerException for more details. --->
System.Runtime.Serialization.SerializationException: ... --->
System.Xml.XmlException: ...
   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader
reader, XmlException exception)
   at System.Xml.XmlUTF8TextReader.VerifyNCName(String s)
   at System.Xml.XmlUTF8TextReader.ReadQualifiedName(PrefixHandle prefix,
StringHandle localName)
   at System.Xml.XmlUTF8TextReader.ReadStartElement()
   at System.Xml.XmlUTF8TextReader.Read()
   at System.Runtime.Serialization.XmlReaderDelegator.Read()
   at
System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator
xmlReader, XmlObjectSerializerReadContext context)
   at
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator
reader, String name, String ns, DataContract& dataContract)


Bugs in Mono serialization?
Can I do anything as a workaround?
-- 
View this message in context: http://mono.1490590.n4.nabble.com/Serialization-problem-in-WCF-tp2316370p2316370.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list