繁体   English   中英

CXF Soap Web服务输入和输出消息作为ComplexType的一部分

[英]CXF Soap Webservices input and output messages as part of ComplexType

我将CXF用于我的Web服务。 我有豆

public class Document {
    private int id;
    private String name;
    private String description;
    private Date createdDate;
//....getters/setters
}

我有一个webmethod界面

@WebMethod(operationName = "SaveDocument")
Document saveDocument(@WebParam(name = "document") Document document);

输入消息没有ID和createdDate,是否有可能? 还是我应该做两个2豆。 一个用于输入,另一个用于响应? 喜欢

public class DocumentIn {
    private String name;
    private String description;
//....getters/setters
}

public class DocumentOut {
    private int id;
    private String name;
    private String description;
    private Date createdDate;
//....getters/setters
}

和网络方法

@WebMethod(operationName = "SaveDocument")
DocumentOut saveDocument(@WebParam(name = "document") DocumentIn document);

您可以使用与参数和结果相同的类型。 只需原始类型。 如果您使用

Integer id

而不是int,可以将其设置为null,这意味着可以省略SOAP XML中的'id'元素。

另外,如果文档相同,并且您仅在服务器端添加了“ id”和“ createdDate”,则也可以使用INOUT参数,请参见http://tomee.apache.org/examples-trunk/webservice-holder/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM