Skip to main content
Home Forums General Silverlight Getting Started How to get a meaningful message from web service response exception
6 replies. Latest Post by rishu on July 8, 2008.
(0)
rishu
Member
14 points
55 Posts
07-03-2008 6:17 AM |
Hi ,
I am trying to consume a web service. This service has some input parameters. It is working fine when the input parameter has a corresponding value in the backend and I am getting correct response. But when I pass some value as input parameter which does not have a corresponding value in the backend then Web service response is exception message .the message is something like " For the given value supplied , there is no matching record". I tested this in an external tool.
But when I try this in silverlight, I get the exception as " Message "The remote server returned an unexpected response: (404) Not Found." string". In the result object in my webservice invocation complete method it says:-
"- Result 'e.Result' threw an exception of type System.Reflection.TargetInvocationException' a2xCall.a2xProxies.OpportunityReadConfirmationMessage0001 {System.Reflection.TargetInvocationException}"
The stack trace is as follows:
StackTrace " at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)\r\n at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)\r\n at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)\r\n at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)\r\n at a2xCall.a2xProxies.ManageOpportunityIn02Client.ManageOpportunityIn02ClientChannel.EndRead(IAsyncResult result)\r\n at a2xCall.a2xProxies.ManageOpportunityIn02Client.a2xCall.a2xProxies.ManageOpportunityIn02.EndRead(IAsyncResult result)\r\n at a2xCall.a2xProxies.ManageOpportunityIn02Client.EndRead(IAsyncResult result)\r\n at a2xCall.a2xProxies.ManageOpportunityIn02Client.OnEndRead(IAsyncResult result)\r\n at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)" string
Can anyone help me how can I get the actual exception message instead of "404 not found".
Regards,
pbromberg
Contributor
2102 points
367 Posts
07-03-2008 7:11 AM |
Not having a matching value at the server for a given parameter is an expected business condition and should not throw an exception. So if you are getting an exception at the server for this, you should be returning either a null object for the response, or an appropriate message response depending on your scenario. In other words, don't rely on exceptions for expected business logic.
07-03-2008 8:14 AM |
Hi,
Thanks for your reply.
The service I am consuming is modeled in such a way that when there is no matching record for a given input parameter it returns a fault message .
How can I handle this fault message in silverlight.
Allen Ch...
Star
13858 points
1,801 Posts
07-07-2008 1:08 AM |
Hi:
Please refer to:
http://silverlight.net/forums/p/17944/60019.aspx#60019
Regards
07-07-2008 11:50 PM |
Hi Allen,
Thanks for your reply. It seems that currently there is no support for SOAP faults in silverlight. corret me if I am wrong.
If this is the case then is there any plans to provide this in the future release?
07-08-2008 2:27 AM |
Yes it's not supported currently. I cannot give you assurance at this point as to if it'll be supported in future release. But we'll keep listening to the feedbacks and add more and more features in the future.
07-08-2008 3:54 AM |
Thanks for your reply. It would be great if we can get support for SOAP fault messages in the release.
Dheeraj