我正在使用 Spring Boot SOAP Webservice Sample 项目创建 SOAP Web 服务。如果我使用以下代码动态生成的 WSDL 显示操作。
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "AvailNotifRequest")
@ResponsePayload
public OTAHotelAvailNotifRS getAvailNotif(@RequestPayload AvailNotifRequest request) {
但我需要请求元素像这样改变。
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "OTAHotelAvailNotifRQ")
@ResponsePayload
public OTAHotelAvailNotifRS getOTAHotelAvailNotifRQ(@RequestPayload OTAHotelAvailNotifRQ request) {
我在此链接 Spring web service dynamic wsdl not generating message for a schema element 上发现了类似的问题回答说我们需要在请求元素后添加后缀请求,如 AvailNotifRequest 但我想用 OTAHotelAvailNotifRQ 作为我的请求输入。
我该如何使用它,因为当我像这样更改请求输入时,我没有在 wsdl 中进行操作。
最佳答案
根据 official Spring-WS documentation :
The <dynamic-wsdl> builds a WSDL from a XSD schema by using conventions. It iterates over all element elements found in the schema, and creates a message for all elements. Next, it creates WSDL operation for all messages that end with the defined request or response suffix. The default request suffix is Request; the default response suffix is Response, though these can be changed by setting the requestSuffix and responseSuffix attributes on <dynamic-wsdl />, respectively.
换句话说,您可以使用
setRequestSuffix
和 setResponseSuffix
在 DefaultWsdl11Definition为了指定一个不同于默认的请求和响应后缀。在上述情况下,例如可能是:wsdl11Definition.setRequestSuffix("RQ");
wsdl11Definition.setResponseSuffix("RS");
关于web-services - Spring Boot SOAP Web 服务动态 WSDL 生成不起作用如果从请求负载元素中删除请求后缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39094070/