1

我使用 NetBeans 7.0 创建了一个 Web 服务存根,当我尝试使用它时,它会抛出一个未知的 Exception。我什至不知道要在这里显示我的代码的哪一部分,我只知道粗体线会生成一个未知的异常:

public Businesses[] findBusiness(String query) throws java.rmi.RemoteException {
    Object inputObject[] = new Object[]{
        query
    };

    Operation op = Operation.newInstance(_qname_operation_findBusiness, _type_findBusiness, _type_findBusinessResponse);
    _prepOperation(op);
    op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");
    Object resultObj;
    try {
        resultObj = op.invoke(inputObject);
    } catch (JAXRPCException e) {
        Throwable cause = e.getLinkedCause();
        if (cause instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) cause;
        }
        throw e;
    }

    return businesses_ArrayfromObject((Object[]) resultObj);
}

private static Businesses[] businesses_ArrayfromObject(Object obj[]) {
    if (obj == null) {
        return null;
    }
    Businesses result[] = new Businesses[obj.length];
    for (int i = 0; i < obj.length; i++) {
        result[i] = new Businesses();
        Object[] oo = (Object[]) obj[i];
        result[i].setAddress((String) oo[0]); // **exception here**
        result[i].setEmail((String) oo[1]);
        result[i].setId((Integer) oo[2]);
        result[i].setName((String) oo[3]);
        result[i].setPhoneno((String) oo[4]);
        result[i].setProducts((String) oo[5]);
    }
    return result;
}`

我尝试使用 Web 应用程序使用相同的 Web 服务,并且效果很好。我对导致此异常的原因一无所知。任何评论将不胜感激。

更新

我尝试了其他返回 String 数据类型的服务,它工作正常。所以我想也许 J2ME 有 JPA 实体类型的问题。

所以我的问题是如何正确返回数据,以便 J2ME 客户端可以很好地读取它?

4

0 回答 0