我是初学者Spring Webservices
。我正在尝试使用创建合同优先的网络服务spring-ws 2.0
。我已经做好了web.xml
(MessageDispatcherServlet)配置,我的合约设计(XSD),生成JAXB
类和服务实现。我对端点感到困惑。以下哪一项(mvc Rest 控制器或 enpoints)在哪种场景下使用是正确的?为什么?提前致谢。
@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);
}
}
前者用于 Soap 调用,后者用于休息(我假设您还包括 Jackson)
您在前者中所做的是声明一个端点,该端点将在传入的肥皂调用时使用适当的命名空间和 localPart 进行调用。在你的情况下 PersonRequest.
我建议您查看参考指南的第 3 章,其中解释了一个简单的示例:http://static.springsource.org/spring-ws/sites/2.0/reference/html/tutorial.html http://static.springsource.org/spring-ws/sites/2.0/reference/html/tutorial.html
后者仅用于对 url 的其余调用,并将传入参数转换为 PersonReadRequestType 实例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)