Results 1 to 2 of 2

Thread: One Endpoint for two services or each service own endpoint?

  1. #1
    Join Date
    Jun 2007
    Posts
    159

    Default One Endpoint for two services or each service own endpoint?

    Hi all,

    I wrote a Web Service which has two services such as calculate and print. Now I just use one endpoint to receive and handle two requests (calculateRequest and printRequest) as follow:
    Code:
    public class MyEndpoint exterds AbstractMarshallingPayloadEndpoint {
    ...
    	@Override
    	protected Object invokeInternal(Object obj) {
    		if (obj instanceof CalculateRequest) {
                      ....
                    } else if (obj instanceof PrintRequest){
                      .....
                    }        
    }
    But I can also use two endpoints, so that each request can be handled by an endpoint as follow:
    Code:
    public class CalculateEndpoint exterds AbstractMarshallingPayloadEndpoint {
    ...
    	@Override
    	protected Object invokeInternal(Object obj) {
                 CalculateRequest = calRequest = (CalculateRequest) obj;
                 ....
            }
    
    }
    and

    Code:
    public class PrintEndpoint exterds AbstractMarshallingPayloadEndpoint {
    ...
    	@Override
    	protected Object invokeInternal(Object obj) {
                 PrintRequest = prtRequest = (PrintRequest) obj;
                 ....
            }
    
    }
    Which method is better?

  2. #2

    Default

    I think that it doesn't really make a difference on such a small scale. However, it's totally legitimate to group multiple actions in one endpoint if you feel the need to.
    In the case I'd use one of the method endpoint mapping rather than hard coding the dispatching logic in the endpoint.
    Tareq Abedrabbo

    My Twitter
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •