首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自web服务方法的tomcat6 web服务调用不是from

来自web服务方法的tomcat6 web服务调用不是from
EN

Stack Overflow用户
提问于 2012-06-11 21:21:12
回答 1查看 115关注 0票数 0

我正在开发一个公开Web服务的Java web应用程序。该web服务对同一tomcat服务器上的另外两个java web服务进行远程调用。如果我尝试从其他两个服务调用方法,我会得到一堆错误,这会导致自动生成的代码中出现NoSuchMethodError。我使用的是Netbeans 6.9、sun java 1.6和apache tomcat 6.0.26。我单独测试了web服务,它们工作得很好。

谢谢您抽时间见我。

让我说得更具体一些

我有一个带有RecommendationManager web服务的RecommendationWeb web应用程序:

代码语言:javascript
复制
@WebService()
public class RecommendationManager {
    public ArrayList<Long> getRecommendation(long userId, int NumOfRecommendations) {
        List<RecommendedItem> recommendations = this.myHModel.getRecommendations(userId, NumOfRecommendations);
        ArrayList<Long> result = new ArrayList<Long>();
        Iterator itr = recommendations.iterator();
        while(itr.hasNext()) {
            RecommendedItem recItem = (RecommendedItem) itr.next();
            result.add(new Long(recItem.getItemID()));
        }
        return result;
    }
}

和带有ETL_WS web服务的ETL_Procedures web应用程序:

代码语言:javascript
复制
@WebService()
public class ETL_WS {
    public ArrayList<Long> getCorrespondingActiveCouponsForRecommendation(ArrayList<Long> itemCategories, int numOfRecoms) {
    int sumOfAllRecommendedCategories = 0;
    Iterator itr = itemCategories.iterator();
    ArrayList<Coupon> coupons = new ArrayList<Coupon>();
    ArrayList<Long> recommendedCoupons = new ArrayList<Long>();
    HashMap productOccurences = new HashMap();
    while(itr.hasNext()) {
        Long item = (Long) itr.next();
        int val = 0;
        ArrayList<Coupon> temp = (ArrayList<Coupon>) couponMap.getCoupon(item);
        if(temp != null) {
            Iterator itr_a = temp.iterator();
            while(itr_a.hasNext()) {
                val += 1;
                sumOfAllRecommendedCategories += 1;
                Coupon tmp_coupon = (Coupon) itr_a.next();
                if(tmp_coupon.isActive())
                    coupons.add(tmp_coupon);
            }
            productOccurences.put(item, new Integer(val));
        }
    }
    long currentCat = coupons.get(0).getItem_id();
    int categoryRecs = 0;
    Integer currentOccurence = (Integer) productOccurences.get(new Long(currentCat));
    int maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories);
    int tempRecItems = 0;
    int listIndex = 0;
    while(tempRecItems < numOfRecoms && listIndex < coupons.size()) {
        if(categoryRecs < maxCategoryItems && currentCat == coupons.get(listIndex).getItem_id()) {
            recommendedCoupons.add(coupons.get(listIndex).getItem_id());
            listIndex += 1;
            tempRecItems += 1;
            categoryRecs += 1;
        }else if(categoryRecs < maxCategoryItems && currentCat != coupons.get(listIndex).getItem_id()) {
            recommendedCoupons.add(coupons.get(listIndex).getItem_id());
            currentCat = coupons.get(listIndex).getItem_id();
            currentOccurence = (Integer) productOccurences.get(new Long(currentCat));
            maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories);
            categoryRecs = 1;
            listIndex += 1;
            tempRecItems += 1;
        }else {
            recommendedCoupons.add(coupons.get(listIndex).getItem_id());
            currentCat = coupons.get(listIndex).getItem_id();
            currentOccurence = (Integer) productOccurences.get(new Long(currentCat));
            maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories);
            categoryRecs = 1;
            listIndex += 1;
            tempRecItems += 1;
        }
    }

    return recommendedCoupons;
}
}

这两个方法在Recommended_Interface web应用程序中从INTERFACE_LAYER web服务调用:

代码语言:javascript
复制
@WebService()
public class INTERFACE_LAYER {
    public ArrayList<Long> requestRecommendation(long userID, int noOfRecoms) {
    ArrayList<Long> recommendedCoupons = null;
    ArrayList<Long> recommendedItems = (ArrayList<Long>) getRecommendation(userID, noOfRecoms);
        recommendedCoupons = (ArrayList<Long>) getCorrespondingActiveCouponsForRecommendation(recommendedItems, noOfRecoms);
    return recommendedCoupons;
}

private static java.util.List<java.lang.Long> getRecommendation(long arg0, int arg1) {
    ws.recommender.RecommendationManagerService service = new ws.recommender.RecommendationManagerService();
    ws.recommender.RecommendationManager port = service.getRecommendationManagerPort();
    return port.getRecommendation(arg0, arg1);
}

private static java.util.List<java.lang.Long> getCorrespondingActiveCouponsForRecommendation(java.util.List<java.lang.Long> arg0, int arg1) {
    ws.etl.ETLWSService service = new ws.etl.ETLWSService();
    ws.etl.ETLWS port = service.getETLWSPort();
    return port.getCorrespondingActiveCouponsForRecommendation(arg0, arg1);
}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-26 15:02:16

不工作的原因是Web Service的方法ArrayList的返回值。当我将其更改为String时,它起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10980923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档