Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Solved!</p> <p>I can't return String, I have return Greeting object to the client.</p> <pre><code>using System; using System.ServiceModel; using System.Net.Security; namespace com.blogspot.jeanjmichel.model { [MessageContract] public class Greeting { private String userGreeting; private void SetGreeting() { DateTime now = DateTime.Now; if (now.Hour &gt;= 7 &amp;&amp; now.Hour &lt;= 11) { this.userGreeting = "Good morning"; } else if (now.Hour &gt;= 12 &amp;&amp; now.Hour &lt;= 17) { if (now.Hour == 12 || now.Hour == 13) { this.userGreeting = "Good afternoon, it's lunch time!"; } else { this.userGreeting = "Good afternoon"; } } else if (now.Hour &gt;= 18 &amp;&amp; now.Hour &lt;= 20) { this.userGreeting = "Good evening"; } else { this.userGreeting = "Good night"; } } [MessageBodyMember(Order = 1, ProtectionLevel = ProtectionLevel.EncryptAndSign)] public String UserGreeting { get { return this.userGreeting; } } public Greeting() { this.SetGreeting(); } } } using System; using System.ServiceModel; using com.blogspot.jeanjmichel.model; namespace com.blogspot.jeanjmichel.services.contract { [ServiceContract(Namespace = "http://jeanjmichel.blogspot.com/services/v0.0.1")] public interface IGetGreeting { [OperationContract] Greeting GetGreeting(Credential credential); } } using System; using System.ServiceModel; using com.blogspot.jeanjmichel.services.contract; using com.blogspot.jeanjmichel.model; namespace com.blogspot.jeanjmichel.services { [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, Namespace = "http://jeanjmichel.blogspot.com/services/v0.0.1")] public class GetGreetingService: IGetGreeting { public Greeting GetGreeting(Credential credential) { if (String.IsNullOrEmpty(credential.Token)) { throw new FaultException("Inform the security phrase, and try again."); } else { if (credential.Token.Equals("mySeCuriTyP@ss")) { Greeting g = new Greeting(); return g; } else { throw new FaultException("Wrong password."); } } } } } </code></pre>
 

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