Page view counter
How to get a meaningful message from web service response exception
Last post 07-08-2008 3:54 AM by rishu. 6 replies.
Sort Posts:
07-03-2008 6:17 AM
How to get a meaningful message from web service response exception

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,

rishu

 

rishu

Loading...
Joined on 06-18-2008
Posts 39
07-03-2008 7:11 AM
Marked as Answer
Re: How to get a meaningful message from web service response exception

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.

[C# MVP]
Unblog|WebSite|IttyUrl

pbromberg

Loading...
Joined on 06-25-2002
Orlando FL
Posts 238
07-03-2008 8:14 AM
Re: How to get a meaningful message from web service response exception

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.

 

Regards,

rishu

rishu

Loading...
Joined on 06-18-2008
Posts 39
07-07-2008 1:08 AM
Re: How to get a meaningful message from web service response exception

Hi:

  Please refer to:

http://silverlight.net/forums/p/17944/60019.aspx#60019

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Loading...
Joined on 03-16-2007
Posts 1,616
07-07-2008 11:50 PM
Re: How to get a meaningful message from web service response exception

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?

 

 Regards

rishu

Loading...
Joined on 06-18-2008
Posts 39
07-08-2008 2:27 AM
Marked as Answer
Re: How to get a meaningful message from web service response exception

Hi:

  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.

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Loading...
Joined on 03-16-2007
Posts 1,616
07-08-2008 3:54 AM
Re: How to get a meaningful message from web service response exception

Hi Allen,

 

Thanks for your reply. It would be great if we can get support for SOAP fault messages in the release.

 

Regards,

Dheeraj

rishu

Loading...
Joined on 06-18-2008
Posts 39
Microsoft Communities