When attempting to debug a webservice, I get the error:
Cannot serialize member System.Exception.Data of type
System.Collections.IDictionary, because it implements IDictionary.
In reading about web services
(
http://msdn2.microsoft.com/en-us/library/ds492xtk.aspx), the documentation
states that exceptions will automatically be handled as a fault element in
the message and then converted to a SoapException in the client.
Additionally the Exception class implements the ISerializable interface
which should be handling the fact that its data member implements the
IDictionary interface.
I pass a collection of data transfer objects to the webservice. Each DTO
has a persistenceException property which will be populated if there is a
problem persisting the individual DTO. This way, the service is not halted
due to an error with a single DTO. DTO's which are updated during
persistence or which experienced an exception are returned to the client in a
collection.
Am I missing something here? Shouldn't exceptions be serializable since
they implement ISerializable othwise, what's the point of implementing the
ISerializable interface for the Exception class? Thank you for your
assistance.
The full error trace follows:
[NotSupportedException: Cannot serialize member System.Exception.Data of
type System.Collections.IDictionary, because it implements IDictionary.]
System.Xml.Serialization.TypeScope.GetDefaultIndex er(Type type, String
memberInfo) +419
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type,
String memberInfo) +30
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, MemberInfo
memberInfo, Boolean directReference) +1491
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source, Boolean directReference, Boolean throwOnError) +285
System.Xml.Serialization.StructModel.GetPropertyMo del(PropertyInfo
propertyInfo) +132
System.Xml.Serialization.StructModel.GetFieldModel (MemberInfo memberInfo)
+148
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a) +2331
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, XmlAttributes a,
Boolean repeats, Boolean openModel) +2080
[InvalidOperationException: There was an error reflecting type
'System.Exception'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, XmlAttributes a,
Boolean repeats, Boolean openModel) +2716
System.Xml.Serialization.XmlReflectionImporter.Imp ortAccessorMapping(MemberMapping
accessor, FieldModel model, XmlAttributes a, String ns, Type
choiceIdentifierType, Boolean rpc, Boolean openModel) +18454
System.Xml.Serialization.XmlReflectionImporter.Imp ortFieldMapping(StructModel
parent, FieldModel model, XmlAttributes a, String ns) +292
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a) +2454
[InvalidOperationException: There was an error reflecting property
'persistenceException'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a) +3961
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a) +1569
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, XmlAttributes a,
Boolean repeats, Boolean openModel) +2080
[InvalidOperationException: There was an error reflecting type
'com.hsb.peoplesoftservices.CustomerDTO'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, XmlAttributes a,
Boolean repeats, Boolean openModel) +2716
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, XmlAttributes a) +49
System.Xml.Serialization.XmlReflectionImporter.Cre ateArrayElementsFromAttributes(ArrayMapping
arrayMapping, XmlArrayItemAttributes attributes, Type arrayElementType,
String arrayElementNs) +471
System.Xml.Serialization.XmlReflectionImporter.Imp ortArrayLikeMapping(ArrayModel model, String ns) +381
System.Xml.Serialization.XmlReflectionImporter.Imp ortAccessorMapping(MemberMapping
accessor, FieldModel model, XmlAttributes a, String ns, Type
choiceIdentifierType, Boolean rpc, Boolean openModel) +10751
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers,
Boolean rpc, Boolean openModel) +1710
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
Boolean openModel) +291
[InvalidOperationException: There was an error reflecting 'Customers'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
Boolean openModel) +1042
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)
+183
System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter
xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault,
XmlReflectionMember[] members, Boolean validate, Boolean openModel, String
key, Boolean writeAccess) +765
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +4263
[InvalidOperationException: Method CustomerService.createOrUpdateCustomers
can not be reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +10259
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod() +149
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding reflectedBinding) +1980
System.Web.Services.Description.ProtocolReflector. Reflect() +734
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[] reflectors) +501
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url) +165
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri) +213
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize() +376
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response) +70
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +104
[InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +303
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +169
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +345
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath) +150
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
+401
System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +183
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +191