문제

Im beginner for Spring Webservices. Im trying to create contract-first web services using spring-ws 2.0. I have done web.xml (MessageDispatcherServlet) configurations, my contract-design (XSD), generated JAXB classes and service implementations. Im confused in Endpoints. Which one of the following, mvc rest controllers or enpoints, is correct to 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);
    }
}
도움이 되었습니까?

해결책

The former is used for Soap calls, the latter for rest (I assume you have also included Jackson)

What you're doing in the former is declaring an endpoint which will be called upon an 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 guide which explains a simple example: http://static.springsource.org/spring-ws/sites/2.0/reference/html/tutorial.html

The latter is just for a rest call to the url and will transform the incoming parameters to an PersonReadRequestType instance.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top