7.4. Decode the Payload

Procedure 7.1. Task

  1. The process method is only the start. Now we must provide methods to decode the incoming Message payload (the Body):
    		  public void reserveSeat (Message message) throws Exception
    	String seatNumber = message.getBody().get(“org.example.flight.seatnumber”);
    	String flight = 
    	boolean success = 
            airlineReservationSystem.reserveSeat(seatNumber, flight);
    	// now create a response Message
    	Message responseMessage = ...
    	// now deliver the response Message
    This code illustrates how the information within the body is extracted and then used to invoke a method on some business logic. In the case of reserveSeat, a response is expected by the client. This response message is constructed using any information returned by the business logic as well as delivery information obtained from the original received message. In this example, we need the To address for the response, which we take from the ReplyTo field of the incoming message. We also need to relate the response with the original request and we accomplish this through the RelatesTo field of the response and the MessageID of the request.
  2. Code every operation supported by the service similarly.