我的问题是:如何设置CXF系统以使服务方法签名与客户端签名相同?即使使用@RequestWrapper? 另请参阅两年前提出的问题:old question
在@WebMethod上使用@RequestWrapper时,会导致nillable =" true"在生成的WSDL中。 从这个WSDL我用Maven(cxf-codegen-plugin)生成java,当设置nillable时,方法的参数被包装。
@WebMethod(action = "getAvailableMoments")
@RequestWrapper(className = "webservice.wrappers.GetAvailableMomentsWrapper")
public List<Moment> getAvailableMoments(LocalDate selectedDate) {
}
包装器看起来像这样:
@XmlAccessorType(XmlAccessType.FIELD)
public class GetAvailableMomentsWrapper implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(required = true)
@XmlJavaTypeAdapter(value = LocalDateAdapter.class, type = LocalDate.class)
@XmlSchemaType(name = "date")
private LocalDate selectedDate;
}
然后wsdl的一部分看起来像这样:
...
<xs:element name="getAvailableMoments" nillable="true" type="tns:getAvailableMomentsWrapper"/>
...
然后生成的java代码如下所示:
@WebMethod(action = "getAvailableMoments")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "getAvailableMomentsResponse", targetNamespace = "calendar.service.vetsware.nl", partName = "parameters")
public GetAvailableMomentsResponse getAvailableMoments(
@WebParam(partName = "parameters", name = "getAvailableMoments", targetNamespace = "calendar.service.vetsware.nl")
GetAvailableMomentsWrapper parameters
);
但是当我设置nillable =&#34; false&#34;时,java代码看起来像我想要的那样:
@WebMethod(action = "getAvailableMoments")
@RequestWrapper(localName = "getAvailableMoments", targetNamespace = "calendar.service.vetsware.nl", className = "nl.vetsware.service.calendar.GetAvailableMomentsWrapper")
@ResponseWrapper(localName = "getAvailableMomentsResponse", targetNamespace = "calendar.service.vetsware.nl", className = "nl.vetsware.service.calendar.GetAvailableMomentsResponse")
@WebResult(name = "return", targetNamespace = "")
public java.util.List<nl.vetsware.service.calendar.Moment> getAvailableMoments(
@WebParam(name = "selectedDate", targetNamespace = "")
java.time.LocalDate selectedDate
);