RESTful Web服务,Spring-WS负载或Spring 3 MVC REST控制器采用哪种方式?


问题内容

我是的初学者Spring Webservices。我正在尝试使用创建合同优先的Web服务spring-ws 2.0。我已经完成web.xml(MessageDispatcherServlet)配置,我的合同设计(XSD),生成的JAXB类和服务实现。我对端点感到困惑。以下哪个是mvc
rest控制器或指定的哪个,在哪种情况下正确使用?为什么?提前致谢。

@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);
    }
}

要么

@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);
    }
}

问题答案:

前者用于Soap电话,后者用于休息(我想您也包括Jackson在内)

您在前者中所做的是声明一个端点,该端点将在传入肥皂调用时使用适当的名称空间和localPart进行调用。在您的情况下PersonRequest。

我建议您看一下参考指南的第3章,该指南解释了一个简单的示例:http :
//static.springsource.org/spring-
ws/sites/2.0/reference/html/tutorial.html

后者仅用于对URL的其余调用,并将传入的参数转换为PersonReadRequestType实例。