c# - What is the best way to return multiple FaultExceptions from one WCF call? -
as question says banging head on best way return multiple faultexceptions 1 wcf call:
the scenario following:
clienta makes call clientb
clientb makes many calls serverc of may return faultexceptions
i return faultexceptions clienta , have not come across way it.
i have tried serializing , de-serializing both faultexceptions , messagefault objects xmlserializer, datacontractserializer , netdatacontractserializer no avail.
the elements care reason, code, , detail. last resort manually write code serialize reason , code, hoping avoid that.
are there other ways this missing ?
edit: judging responses have gotten think question not clear
in pseudo code trying following:
class clienta() { main() { clientb.operateonmanyvalues(array[] values) } } clientb() { operateonmanyvalues(array[] values) { foreach(val val in values) { try { serverc.operateononevalue(val) } catch(faultexception ex) { errorlist.add(ex) } } return errorlist } }
edit 2:
first of want thank attempting answer question. feel of answers answers different problems.
1 poster suggested throw exception error. unfortunately how system intended work. each value operated on independent of others , unaffected success or error of other values. not want 1 error affect processing of other values.
poster suggested returning sort of data structure faultexception data faults. do, problem returning list of faultexceptions throws serialization errors. there way serialize faultexception can return multiple in list wcf call ?
well... don't understand second part of scenario. if client b acts following
serverc.a(); [...] serverc.b(); [...] serverc.c();
or
while(condition) serverc.call();
then first exception automatically rethrown client b , possibly rethrown a, don't have multiple exceptions handle.
but if clientb calls several methods of serverc different threads may have that. still, if clientb calls services serverc this
try { serverc.a(); } catch(exception ex) { //store exception } [...] try{ serverc.b(); } catch(exception ex) { //store exception b } [...] try { serverc.c(); } catch(exception ex) { //store exception c }
you have deal own way.
in order have consistent exception
that reports information root cause, have use innerexception
property of faultexception
class, can't hold array of innerexceptions.
if yours case in collect multiple exceptions , want report them all
then may create custom faultexception class, inheriting former, property exception[] innerexceptions
.
but, again, don't believe have kind of "multiple exceptions". perhaps meant nested exceptions, handled innerexception regular property.
if show pseudo-code of help.
Comments
Post a Comment