troubleshooting Question

Sending objects containing objects from WCF Server

Avatar of parabellum
parabellum asked on
.NET ProgrammingWCF
2 Comments1 Solution458 ViewsLast Modified:

I have a WCF Server that returns a ResponseType class object that i have created. The class is shown in the code section.

When the WCF Client  invokes a WCF Server Function and the   server operation is a success
(for example  WCF server succesfully connects to the database)  ResponseObj will be  some
string data. In this scenario everything is working fine. (r_type.ResponseObj="Connection is OK")

But  when   a exception occurs at the WCF server  i catch that exception and want to inform the client about the exception. And i want to directly send the exception object to the WCF client. So i use something like this:
catch(Exception ex)
return r_type;

But  at the WCF client i get the exception : Server is in the faulted state.

In short  when the object type ResponseType is a complex object like Exception class object
instead of int or string, the system does not work.
Is there a workaround to overcome this issue ?

Note : If i add  another DataMember  like Exception ex to the ResponseType Class then i can
succesfully send the exception to the client. But I do not want to add a DataMember  for
each type of exception. By using reflection at the client (.GetType())  i can already understand
the type of the object.

I am sorry and i hope i have made myself clear.

 public class ResponseType
        private object responseObj;    
        private string additionalData;

        public object ResponseObj
            get { return responseObj; }
            set { responseObj = value; }
        public string AdditionalData
            get { return additionalData; }
            set { additionalData = value; }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros