3
Im初學者爲Spring Webservices
。我正在嘗試使用spring-ws 2.0
來創建合同優先的Web服務。我完成了web.xml
(MessageDispatcherServlet)配置,我的合同設計(XSD),生成了JAXB
類和服務實現。我困惑在終點。下列哪一個mvc休息控制器或設定值在哪種情況下使用是正確的,爲什麼?提前致謝。REST風格的webservice,Spring-WS有效載荷或Spring 3 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);
}
}
謝謝!有所不同。我只需要REST webservices,所以現在使用** DispatcherServlet **而不是** MessageDispatcherServlet **。 – Sridhar 2013-02-13 10:21:27
@Sridhar標記爲已回答 – 2013-02-14 08:32:30