Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to create a custom response type and return that from your service. The client (who called the service) should read the response and be responsible for popping up a message box stating whether or not the service call was a success.</p> <p>Here is what the type could look like:</p> <pre><code>[DataContract] public class SendMessageResponse { [DataMember] public bool Successful { get; set; } [DataMember] public List&lt;string&gt; Messages { get; set; } public SendMessageResponse() { this.Successful = true; this.Messages = new List&lt;string&gt;(); } public void ProcessException( Exception ex ) { this.Messages.Add( ex.Message ); this.Successful = false; } } </code></pre> <p>Here is what the service code would look like:</p> <pre><code>[WebMethod] public SendMessageResponse SendMessage(...) { var response = new SendMessageResponse(); try { // Do your send message stuff here... response.Successful = true; // or whatever you want to say } catch( Exception ex ) { response.ProcessException( ex ); } return response; } </code></pre> <p>This way, your service never faults the channel and will always return your response object (even in the case of an exception). You can then use your response object to communicate to the client the status of your service call.</p> <p>Here is what the client might look like:</p> <pre><code>public void SendMessage( MessageServiceClient proxy, string mail, string authstr ) { MessageServiceClient.SendMessageResponse response = proxy.SendMessage( mail, authstr ); if( response.Successful ) { MessageBox.Show( "Message Sent" ); } else { MessageBox.Show( "Message Failed to Send: " + response.Messages.FirstOrDefault() ); } } </code></pre> <p>The client code is a rough example, but it should give you an idea of what I'm talking about.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload