Friday 5 August 2016

Developing WCF Services | WCF Service for Banking Transaction


In this walkthrough, I would build a WCF Service to support Banking Transaction in ATM. Create a new project, Open  VS 2012 >New Projects > Visual C#  >  WCF  > WCF Service Application.
Visual studio provides a mock service implementation as shown below,lets run and test the services. Select the service1.svc file and then run the project this launches the test client.
In the WCF-Test Client, you can see the list of method/operation all available in the service. Double click the GetData operation and right pane, provide the request data and click invoke to trigger the service. Service Response is shown in the bottom half of right pane. Similarly test the other operation.
Lets implement Banking service, below is the interface for banking service having two operations ATMTransaction and ValidateCustomer. DataContracts are Transaction Request and Response as shown below.
Here is the service implementation layer, for IBankingService. Service Layer call internal method to perform required operation.
Here is business Logic implementation for ATM Transaction Operation which uses internal Transaction and InterATMTransaction methods. These methods connects to DB using ADO.net as shown
Similarly, ValidateCustomer Operation is shown below
WCF Serive implementation is completed, lets run and host the service locally in IIS. WCF service connects to below database, CustomerAccount and ATMTransactions tables are shown below. 
Here is the service wsdl of BankingService. Having ATMTransaction and ValidateCustomer Operations
Lets test the service from WCF-Test Client as shown below and the transactions are stored in the SQL tables.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.