
304Microsoft Visual Studio 2010: A Beginner’s Guide
Public Interface ICustomerService
<OperationContract()>
Function GetData(ByVal value As Integer) As String
<OperationContract()>
Function GetDataUsingDataContract(
ByVal composite As CompositeType) As CompositeType
'TODO: Add your service operations here End Interface
'Use a data contract as illustrated in the sample below
'to add composite types to service operations
<DataContract()>
Public Class CompositeType
<DataMember()>
Public Property BoolValue() As Boolean
<DataMember()>
Public Property StringValue() As String
End Class
There are two types in Listing
Starting with the ICustomerService interface, the two most important parts of the code are the ServiceContract and OperationContract attributes. The ServiceContract attribute states that this interface defines a contract for a WCF Web service. Without the ServiceContract attribute, this interface won’t be recognized by WCF. The OperationContract attribute specifies methods that are exposed by the WCF service. Without the OperationContract attribute, a method will not be visible as part of the WCF service.
A WCF service method can work with any of the