Announcement Announcement Module
Collapse
No announcement yet.
One Endpoint for two services or each service own endpoint? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X