Holder的使用

 
 Holder的使用 

如果使用javax.xml.rpc.holders.*Holder,JBoss启动WebService时,会报错:Cannot synchronize to any of these methods
13:14:19,734 ERROR [MainDeployer] Could not start deployment: file:/E:/IDE/JBoss4.2/jboss-4.2.2.GA/server/default/deploy/OrderTicket.war/
java.lang.IllegalStateException: Cannot synchronize to any of these methods:
public java.lang.String sample.OrderTickService.getNameStr(javax.xml.rpc.holders.StringHolder)

解决办法,将javax.xml.rpc.holders.StringHolder改为javax.xml.ws.Holder
使用Holder 作为参数类型
例如:
错误方法:
    @WebMethod
    public boolean open(
            @WebParam(name = "payType" ) int payType,
                                            StringHolder strHolder,
            @WebParam(name = "resInfoHolder" ) ResultInfoHolder resInfoHolder);
// ResultInfo是一个自定义类
// ResultInfoHolder声明如下
package com.test.ws.holders;
public final class ResultInfoHolder implements javax.xml.rpc.holders.Holder {
    public com.test.ws.ResultInfo value;

    public ResultInfoHolder() {
    }

    public ResultInfoHolder(com.test.ws.ResultInfo value) {
        this.value = value;
    }

}


正确方法:
    @WebMethod
    public boolean open2(
            @WebParam(name = "payType" ) int payType,
                                            Holder strHolder,
            @WebParam(name = "resInfoHolder" ) Holder resInfoHolder);
            // ResultInfo是一个自定义类

 

javax.xml.ws.Holder是JAX-WS 2.0才有的

你可能感兴趣的:(webservice)