gpt4 book ai didi

java - axis2 (1.3) 客户端问题

转载 作者:行者123 更新时间:2023-12-01 16:04:15 25 4
gpt4 key购买 nike

(axis2 1.3,struts2 2.1.8.1,tomcat 6.x,java 1.5.0)

我在制作第一个网络服务时遇到问题。

  1. 我创建了一个我想测试的 MOCK api。我的行动:

    public HotelMessage[] getMessages(String roomNr) {
    HotelMessage[] msg2return = new HotelMessage[1];
    HotelMessage m1 = new HotelMessage();
    m1.setId(1L);
    m1.setMessage("wiadomosc pierwsza");
    m1.setTitle("title pierwszy");
    m1.setRead(false);
    m1.setRoomNr(roomNr);
    System.err.println("returning messages");
    return msg2return;

    }

我的 HotelMessage 类如下所示:

import java.io.Serializable;
import java.sql.Date;

public class HotelMessage implements Serializable{

private static final long serialVersionUID = -6785924436619067967L;
private long id;
private boolean read;
private String roomNr;
private String title;
private String message;
private Date create_date;

//setters + getters
}

制作完aar后,我将其上传到tomcat上的mu axis2,然后:

wsdl2java.bat -uri http://localhost:8088/axis2/services/HotelAPI?wsdl -d adb -s -S .

一切工作正常,但当我尝试使用代码调用 getMessages("STH") 操作时,出现了此异常:

HotelAPIStub.GetMessages getMessages = new HotelAPIStub.GetMessages();
getMessages.setParam0("ble");
HotelAPIStub.HotelMessage[] tmp;
try{
HotelAPIStub.GetMessagesResponse resp3 = stub.getMessages(getMessages);
tmp = resp3.get_return();
System.err.println("THERE ARE "+tmp.length+"MESSAGES!");
}catch (RemoteException ex){
System.err.println("NO MESSAGES!");
ex.printStackTrace();
}

我遇到了这个异常:

org.apache.axis2.AxisFault: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at com.swmind.IPTV.hotel.HotelAPIStub.getMessages(HotelAPIStub.java:371)
at com.swmind.IPTV.hotel.actions.ShowBillClass.execute(ShowBillClass.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

有人可以帮我吗?我尝试用谷歌搜索,但没有发现任何有用的东西。谢谢齐姆

最佳答案

在您的模拟 API 中,您永远不会将 msg2return[0] 指向 m1

关于java - axis2 (1.3) 客户端问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2974289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com