axis2 (1.3) 客户端问题

发布于 2024-09-04 02:02:39 字数 2642 浏览 3 评论 0原文

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

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

  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("标题 pierwszy");
    m1.setRead(假);
    m1.setRoomNr(房间号);
    System.err.println("返回消息");
    返回消息2返回;
    

    }

我的 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)

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

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

I've got problem with making my first web service.

  1. I create a MOCK api which i want to test. My action:

    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;
    

    }

My HotelMessage class looks like that:

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
        }

After making aar, i upload this to mu axis2 on tomcat, then:

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

everything works just fine, but I got this exception, while i was trying to call getMessages("STH") action with code:

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();
    }

i've got this Exception:

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)

Could anyone please help me ? I've tried to google it, but didn't found anything useful.
Thx
Tzim

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

他是夢罘是命 2024-09-11 02:02:39

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

In your mock API you never point msg2return[0] to m1.

淤浪 2024-09-11 02:02:39

解决方案:重新启动tomcat并使用axis2...

Solution: restart tomcat with axis2 in it...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文