从webservice返回自定义对象

时间:2014-02-14 16:17:09

标签: java web-services wsdl ejb

我有这个想法:

MyEJBProject中的

@Stateless
class MyBean implements MyRemoteBean{

    @Override
    public String myFunction(){...}
}

@Remote
public interface MyRemoteBean{
    public String myFunction();
}

在MyWEBProject中(带有对MyEJBProject的引用),我有

@WebService
public class MyService{
    @EJB
    MyRemoteBean remoteBean;

    @WebMethod
    public String myWSFunction(){
        return remoteBean.myFunction();
    }
}

这很有用。
但是现在“myFunction”必须返回一个自定义对象,比方说MyResponse。我创建了一个MyResponse类(实现了可序列化)并在所有类上更改了函数的公司,但是当我在WAS7上部署解决方案时,我收到错误,告诉我无法生成wsdl。
我搜索过这个问题,发现可能有很多不同的东西。我错过了什么?一些注释或属性?

提前致谢

修改

我的自定义对象只是

public class MyResponse implements Serializable{
    private static final long serialVersionUID = ...
    ...
    some other String and long variables
}

所以代码是:

@Stateless
class MyBean implements MyRemoteBean{

    @Override
    public MyResponse myFunction(){...}
}

@Remote
public interface MyRemoteBean{
    public MyResponse myFunction();
}

@WebService
public class MyService{
    @EJB
    MyRemoteBean remoteBean;

    @WebMethod
    public MyResponse myWSFunction(){
        return remoteBean.myFunction();
    }
}

相关(不是这样)的堆栈跟踪是

WSWS7054E: The Web Services Description Language (WSDL) file could not be generated for the [MyService] Web service implementation class because of the following error: java.lang.Exception: A WSDL Definition could not be generated for the implementation class: [MyService]
WSWS7027E: JAX-WS Service Descriptions could not be correctly built because of the following error: javax.xml.ws.WebServiceException: WSWS7054E: The Web Services Description Language (WSDL) file could not be generated for the [MyService] Web service implementation class because of the following error: java.lang.Exception: A WSDL Definition could not be generated for the implementation class: [MyService]

0 个答案:

没有答案