【问题标题】:cxf parameter optimaizationcxf参数优化
【发布时间】:2010-12-10 09:21:15
【问题描述】:

在 cxf 网络服务中我的请求是

<student>
    <name>jaleel</name>
     <age>26</age>
</student>

这里我想把年龄作为可选的

怎么可能;

我在 cxf 中使用 spring java。

我的终点是

<bean id="tsetService" class="com.maxartists.tsm.server.TestServiceImpl"></bean>

<jaxws:endpoint id="issure_password_request" 
                     address="/testserver">    
                    <jaxws:implementor>
                            <bean parent="tsetService" />
                    </jaxws:implementor>
     </jaxws:endpoint> 

我的网络服务方法是

@WebService
public interface TestService {
@WebMethod
    public String test( Testvo type);
    @WebMethod
    public Result validation(@WebParam(name="pwvalue") Studentvo ipvo);

这是我的参数类型

公开课 Studentvo { 字符串名称; 年龄;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name= name;
}

public void setAge(int age){

 this.age = age;

}

公共 int getAge(){ 回归年龄; }

【问题讨论】:

    标签: wsdl cxf endpoint


    【解决方案1】:

    如果您将年龄的“类型”从“int”更改为 Integer,它将自动变为可选。

    或者,您可以向 getter/setter/field 添加一个 @XmlElement(required="false") 属性,这也应该使其成为可选的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-11
      • 2021-04-20
      • 2016-05-20
      • 1970-01-01
      • 1970-01-01
      • 2017-09-04
      • 2016-02-03
      相关资源
      最近更新 更多