// Ask a question, receive an answer!
[OperationContract]
string ObtainAnswerToQuestion(string userQuestion);
}
■
Note
It is permissible to define a service contract interface that contains methods not adorned with the
[OperationContract]
attribute. However, such members will not be exposed through the WCF runtime.
As you know from your study of the interface type (see Chapter 9), interfaces are quite useless
until they are implemented by a class or structure, in order to flesh out their functionality. Like a
real Magic 8-Ball, the implementation of our service type (MagicEightBallService) will randomly
return a canned answer from an array of strings. Also, our default constructor will display an infor-
mation message that will be (eventually) displayed within the host’s console window (for diagnostic
purposes):
C H A P T E R 2 5
■
I N T R O D U C I N G W I N D O W S C O M M U N I C AT I O N F O U N D AT I O N
885
8849CH25.qxd 10/16/07 10:51 AM Page 885
public class MagicEightBallService : IEightBall
{
Do'stlaringiz bilan baham: |