数组作为Axis2 POJO Webservices中的参数?

时间:2011-07-05 06:52:29

标签: web-services axis2 pojo

我是Axis2 / Webservice的新手,我正在尝试将简单的POJO转换为web服务(下面的代码)。类PieceInfo注释为@XmlRootElement,我有一个类ObjectFactory,它在方法中返回PieceInfo(下面的代码)。使用PieceInfo工作的方法,使用List<PieceInfo>PieceInfo[]作为参数的方法会抛出JAXB异常,例如java.util.List is not known to this context。我认为List或数组应该可以正常工作。我做错了什么?

@WebService (name="KMPService",targetNamespace="http://www.ict.ie.tss/")
@MTOM
public interface KMPServiceInterface {

@WebMethod
void updateRootInfo(String username, String password, PieceInfo info);

@WebMethod
PieceInfo getRootInfo(String username, String password);

@WebMethod
void put(String username, String password, List<PieceInfo> infoList);

@WebMethod
PieceInfo[] get(String username, String password,
    PieceInfo[] infoList);

@WebMethod
void deleteEntries(String username, String password,
    PieceInfo[] infoList);

}

ObjectFacotry:

@XmlRegistry
public class ObjectFactory {

public PieceInfo createPieceInfo(){
    return new PieceInfo();
}

 }

2 个答案:

答案 0 :(得分:1)

似乎答案是:不要使用Axis2 。现在使用cxf,所有内容都可以使用Lists和Arrays开箱即用。

答案 1 :(得分:0)

使用数组而不是java.util.List。

请记住,Web服务应该与所有内容互操作,例如.Net Web服务客户端,他们不知道如何构建java.util.List对象,但应该能够弄清楚如何构建数组PieceInfo对象。

希望这会消除您对“不为此背景所知”的问题。还要确保PieceInfo具有零参数构造函数,以便Axis框架可以创建一个。