Skip to main content

Microsoft Silverlight

Answered Question How to get a meaningful message from web service response exceptionRSS Feed

(0)

rishu
rishu

Member

Member

14 points

55 Posts

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

 

pbromberg
pbromberg

Contributor

Contributor

2114 points

368 Posts

Answered Question

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.

rishu
rishu

Member

Member

14 points

55 Posts

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

Allen Chen – MSFT
Allen Ch...

Star

Star

13862 points

1,803 Posts

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.

rishu
rishu

Member

Member

14 points

55 Posts

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

Allen Chen – MSFT
Allen Ch...

Star

Star

13862 points

1,803 Posts

Answered Question

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.

rishu
rishu

Member

Member

14 points

55 Posts

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

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities