1

我已经在java中的axis2-1.6.2中实现了webservice客户端,当我第一次调用时我得到响应,随后第二次我得到以下错误

java.lang.NullPointerException
 at org.apache.axis2.client.OperationClient.prepareMessageContext(OperationClient.java:293)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:180)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
 at org.apache.axis2.ccws.CustomerCareServiceStub.subscriberRetrieveLite(CustomerCareServiceStub.java:2380)
        at Prepost.SubscriberRetrieveBalance.subscriberRetrieveLite(SubscriberRetrieveBalance.java:111)
        at Prepost.CheckUser.doGet(CheckUser.java:149)

这是 API 实现类构造函数,它设置了所有请求都相同的唯一参数

public SubscriberRetrieveBalance(String url, String strCON_TimeOut, String strSO_TimeOut) {
    try {
        this.url = url;
        stub = new CustomerCareServiceStub(url);
        ServiceClient sClient = stub._getServiceClient();
        Options options = sClient.getOptions();
        options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE);
        options.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
        //options.setTimeOutInMilliSeconds(2000);
        TransportInDescription transportIn = new TransportInDescription("HTTP");
        options.setTransportIn(transportIn);
        options.setProperty(HTTPConstants.SO_TIMEOUT, Integer.parseInt(strSO_TimeOut));
        options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, Integer.parseInt(strCON_TimeOut));
        sClient.setOptions(options);
    } catch (Exception e) {
        if (e.getMessage().equals("Can not find the external id")) {
            System.out.println("Exception ::" + e.getMessage());
        }
    }
}

并且在 servlet 中调用它,出于性能问题,我为不同的 2 个状态(url)创建此类的对象,并在第一次请求针对各个状态时将这些对象保存到 hashmap,然后创建新对象并将该对象用于后续请求那个状态

SubscriberRetrieveBalance objBal = null;
            BalanceBean bal = new BalanceBean();
            if (mapObj.isEmpty() || (mapObj.get(strIP) == null)) {

                objBal = new SubscriberRetrieveBalance(url, strCON_TimeOut, strSO_TimeOut);
                mapObj.put(strIP, objBal);
            } else {

                objBal = mapObj.get(strIP);
            }
            bal = objBal.subscriberRetrieveLite(strMsisdn, userId, token, strCircleId, strCircleName, strSessionId, strDlgId);

它第一次给出响应,然后为属于该状态的所有请求给出空指针异常和上述错误

此代码适用于axis2-1.5

在axis2-1.6.2版本中是否有任何变化,每次需要API实现类的新对象

请建议。

4

0 回答 0