Deserialization error while using int[] as a parameter

77 views
Skip to first unread message

Prabu

unread,
Jan 4, 2010, 8:32:34 AM1/4/10
to Rhino.Mocks, sharma...@gmail.com
Hi,
I am using Rhino mocks 3.5 for mocking our web service. I am using a
PartialMock and the mock works fine for other methods but fails for a
method which has int[] as an argument. On changing the argument to int
this works fine.

int TestMethod(int MethodIndex, IDValuePair[] MethodArguments, int[]
SecurityIds, out System.Data.DataSet ResultData, out string ErrorMsg);

<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/
System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-
instance"><HelpLink i:nil="true" /><InnerException><HelpLink
i:nil="true" /><InnerException><HelpLink i:nil="true" /
><InnerException i:nil="true" /><Message>End element 'SecurityIds'
from namespace 'http://webservice.test.com/test' expected. Found
element 'int' from namespace 'http://webservice.test.com/test'. Line
1, position 453.</Message><StackTrace> at
System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader
reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowEndElementExpected
(XmlDictionaryReader reader, String localName, String ns)
at System.Xml.XmlBaseReader.ReadEndElement()
at System.Runtime.Serialization.XmlReaderDelegator.ReadEndElement()
at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue
(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at
System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue
(DataContract dataContract, XmlReaderDelegator reader)
at
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize
(XmlReaderDelegator reader, String name, String ns, DataContract&amp;
dataContract)
at
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize
(XmlReaderDelegator xmlReader, Type declaredType, DataContract
dataContract, String name, String ns)
at
System.Runtime.Serialization.DataContractSerializer.InternalReadObject
(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
at
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions
(XmlReaderDelegator reader, Boolean verifyObjectName)</
StackTrace><Type>System.Xml.XmlException</Type></
InnerException><Message>There was an error deserializing the object of
type System.Int32[]. End element 'SecurityIds' from namespace 'http://
webservice.test.com/test' expected. Found element 'int' from namespace
'http://webservice.test.com/test'. Line 1, position 453.</
Message><StackTrace> at
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions
(XmlReaderDelegator reader, Boolean verifyObjectName)
at System.Runtime.Serialization.DataContractSerializer.ReadObject
(XmlDictionaryReader reader, Boolean verifyObjectName)
at
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart
(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)</
StackTrace><Type>System.Runtime.Serialization.SerializationException</
Type></InnerException><Message>The formatter threw an exception while
trying to deserialize the message: There was an error while trying to
deserialize parameter http://webservice.test.com/test:SecurityIds. The
InnerException message was 'There was an error deserializing the
object of type System.Int32[]. End element 'SecurityIds' from
namespace 'http://webservice.test.com/test' expected. Found element
'int' from namespace 'http://webservice.test.com/test'. Line 1,
position 453.'. Please see InnerException for more details.</
Message><StackTrace>

Thanks,
Prabu

Tim Barcz

unread,
Jan 4, 2010, 11:24:37 AM1/4/10
to rhino...@googlegroups.com
Can you provide a failing test that I (we) can run?


--

You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To post to this group, send email to rhino...@googlegroups.com.
To unsubscribe from this group, send email to rhinomocks+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.





--
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

Praburaj Thiagarajan

unread,
Jan 5, 2010, 1:38:55 AM1/5/10
to rhino...@googlegroups.com, Abhishek Sharma
Hi Tim,
I have a test case with the code:
 
My expectation setting for the call is like below.
Expect.On(MTInterface).Call(MTInterface.TestMethod(0, null, null, out ResultDataset, out ErrorMsg)).OutRef(ResultDataset).Return(0).IgnoreArguments().Constraints(Is.Equal(52), Is.Anything(), Is.Anything(), Is.Anything(), Is.Anything());
 
Test code makes the following call:
resultCode = MTInterface.TestMethod(52,
m_MethodParam, /*Properly populated int[] */m_securityArguments.SecurityIds, out DataSetResult, out errorMsg);
 
A call to the above method fails with the mentioned exception. Am I missing something here..?

Regards,
Prabu

Reply all
Reply to author
Forward
0 new messages