调用SOAP函数时出现NullPointer异常

时间:2014-07-16 14:47:40

标签: java web-services soap nullpointerexception

我正在尝试以下代码从Web服务运行SOAP方法。

public de.externalwebservices.worms.aphiav1_0.AphiaRecord[] getAphiaChildrenByID(int aphiaID, int offset, boolean marine_only) throws java.rmi.RemoteException{
   if (aphiaNameServicePortType == null)
       _initAphiaNameServicePortTypeProxy();
   return aphiaNameServicePortType.getAphiaChildrenByID(aphiaID, offset, marine_only);}

我打电话给名为 WORMSWSDAO 的第二个班级:

public AphiaRecord[] getAphiaChildrenByID(int AphiaID){
    AphiaRecord[] result = new AphiaRecord[0];
    try {
        result = port.getAphiaChildrenByID(AphiaID, 1, false);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}

然后我按照以下方式在主程序中运行它:

public static void main(String[] args) throws RemoteException {

    WORMSWSDAO  wDAO = new WORMSWSDAO();

    AphiaRecord [] result = wDAO.getAphiaChildrenByID(219275);
    System.out.println(result[1].getFamily());


}

但是在运行之后我得到的只是一个空指针异常..

0 个答案:

没有答案