Microsoft 9GD00001 Computer Accessories User Manual


 
306 Microsoft Visual Studio 2010: A Beginner’s Guide
We started customizing the contract when changing the name of IService1 to
ICustomerService, but we need to continue by defining the methods that will become
part of the CustomerService contract: GetCustomers, GetCustomer, InsertCustomer,
UpdateCustomer, and DeleteCustomer. In practice, there will be more methods you’ll
want, just to customize the contract for the special needs of your application, but these
methods depict typical scenarios you’ll frequently encounter and are representative of any
work you’ll perform. Listing 11-2 shows the modifications to ICustomerService to support
customer operations. After making the changes in Listing 2, your application won’t
compile until you implement the ICustomerService interface in the next section. Please
make the changes, if you’re following along, and keep reading until the next section.
Listing 11-2 WCF service contract implementation
C#:
[ServiceContract]
public interface ICustomerService
{
[OperationContract]
Customer GetCustomer(int custID);
[OperationContract]
List<Customer> GetCustomers();
[OperationContract]
int InsertCustomer(Customer cust);
[OperationContract]
void UpdateCustomer(Customer cust);
[OperationContract]
void DeleteCustomer(int custID);
}
VB:
<ServiceContract()>
Public Interface ICustomerService
<OperationContract()>
Function GetCustomer(ByVal custID As Integer) As Customer
<OperationContract()>
Function GetCustomers() As List(Of Customer)