// Just for display purposes on the host.
public MagicEightBallService()
{
Console.WriteLine("The 8-Ball awaits your question...");
}
public string ObtainAnswerToQuestion(string userQuestion)
{
string[] answers = { "Future Uncertain", "Yes", "No",
"Hazy", "Ask again later", "Definitely" };
// Return a random response.
Random r = new Random();
return string.Format("{0}? {1}.",
userQuestion, answers[r.Next(answers.Length)]);
}
}
At this point, our WCF service library is complete. However, before we construct a host for this
service, let’s examine some additional details of the [ServiceContract] and [OperationContract]
attributes.
Do'stlaringiz bilan baham: |