Thứ Sáu, 22 tháng 8, 2014

Developing web service using JAX-WS

Demo : Happy Consumer International Bank (HCIB), a leading multinational organization having established branches all over the world is now starting its banking services in India. The Bank has employed you as a full time System Consultant with them. It wants to deploy a Web Service that will offer credit card validation and online banking facilities that are typically offered by all the multinational banks. The main priorities for the online banking system are reliability, availability and serviceability of the application. Additionally, the system should be highly scalable and secure as the bank expects substantial growth in the
future. Consider yourself to be a part of the team that implements the credit card validation module. Develop a JAX_RPC based Web Service that exposes the boolean validateCreditCard(cardNumber) method. This method implements the logic for credit card number validation, and returns a boolean value indicating whether the card number is valid or not. Logic for credit card number validation:
Step 1: Multiply the alternate digits of the credit card number by 2 starting with the second digit from the right (the first right--hand digit is the check digit).
Step 2: Add the individual digits comprising the products obtained in Step 1 to each of the unaffected digits in the original number.
Step 3: The sum of all digits obtained after Step 2 as well as unaffected digits must be a number which is a multiple of 10 (30, 40, 50, etc.) for the credit card number to be valid.

Chúng ta sẽ thực hiện như sau :
Tạo Java Web Application và tạo webservice
Code trong web service như trên
Test thử web service vừa tạo
Sau bước này chúng ta sẽ tạo một client , ở đây tôi chọn new Java Application :
Tạo Web Service Client
Copy đường dẫn WSDL khi tạo Web Service Client
Để kết nối được với nhau ta kéo method validateCart vào trong main class.
viết code trong main
Kết quả thu được
DEMO tại đây.

NHẬN XÉT :
-Có thể thực hiện edit web service mà không lo ảnh hưởng tới client.
-Có thể sử dụng cho nhiều client

Không có nhận xét nào:

Đăng nhận xét