Using non-exposable methods of service interface

This recipe explains the usage of methods that are not exposed through a web service interface. These methods are private to the web service implementation and cannot be used for integration through the web service mechanism. In the Java code, such methods have private access as well.

How to do it…

In the CreditCardGateway class, , we implement the Void credit card operation which checks whether the credit card data is authorized and if a possibility of fraud exists. If the transaction is accepted, then we forward the request of the backend system.

public TransactionResponse Void(String token, BigDecimal amount) {
  if ( isAuthorised(token) && isFraud(token) ) {
    BackEndSystem.getInstance().voidOp(UUID.fromString(token), amount);
    return new TransactionResponse("Success.", 20002, token);  
  } else {
    return new TransactionResponse("Authorization invalid or fraud suspect.", 9997, null);     
  }
}

As a result of the transaction, we send the operation data back to the client.

How it works…

We can see the following two methods in the previous code snippet:

  • isAuthorised
  • isFraud

These two methods have a private scope in the CreditCardGateway class and likewise are not exposed as a web service operation.

Furthermore, the BackEndSystem.getInstance().voidOp call implements the a to the public method of a backend system, which is not exposed as a web service operation either.

We can see that with JavaBean, we can freely decide what public methods will become available and are exposed as web service operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset