What's the way to go for RESTful web service, Spring-WS or Spring 3 MVC REST controllers?

Im a beginner for Spring Webservices

. I am trying to create contracted services using spring-ws 2.0

. I followed configurations web.xml

(MessageDispatcherServlet), my contract design (XSD), generated classes JAXB

and service implementations. I'm confused about the endpoints. Which of the following mvc rest controllers or enpoints is correct for use in which scenario and why? Thanks in advance.

@Endpoint
public class PersonEndpoint {

    @Autowired
    private PersonServiceImpl personService;

    @PayloadRoot(localPart = "PersonRequest", namespace = Constants.PERSON_NAMESPACE)
    public @ResponsePayload
    PersonResponseType personReadMethod(@RequestPayload PersonReadRequestType requestElement) {
        return personService.isBiometricNeeded(requestElement);
    }
}

      

or

@Controller
public class PersonController {

    @Autowired
    private PersonServiceImpl personService;

    @RequestMapping(value = "/person", method = RequestMethod.GET)
    public @ResponseBody
    PersonResponseType personReadMethod(@RequestBody PersonReadRequestType requestElement) {
        return personService.isBiometricNeeded(requestElement);
    }
}

      

+3


source to share


1 answer


The former is used for soap calls, the latter is for rest (I assume you included Jackson as well)

What you do in the first one is declaring an endpoint that will be called by the incoming soap call with the appropriate namespace and localPart. In your case, PersonRequest.



I would recommend taking a look at chapter 3 of the reference manual which explains a simple example: http://static.springsource.org/spring-ws/sites/2.0/reference/html/tutorial.html

The latter is only for calling rest on url and converts the incoming parameters to a PersonReadRequestType instance.

+2


source







All Articles