【问题标题】:Web Service to Trigger another Web Service?Web 服务触发另一个 Web 服务?
【发布时间】:2011-01-11 17:25:04
【问题描述】:

是否可以从网络服务中触发网络服务?

/**
 * Web service operation
 */
@WebMethod(operationName = "bookFlight")
public String bookFlight(@WebParam(name = "destination")
String destination, @WebParam(name = "seats")
int seats) {
    try {
        String ret = composite.bookFlight(destination, seats);
            if(composite.checkDistance(destination) > 15)
            {

            }
        return ret;
    } catch (FileNotFoundException_Exception ex) {
        Logger.getLogger(compositeBookings.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InterruptedException_Exception ex) {
        Logger.getLogger(compositeBookings.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

在空的 if 函数体中我需要触发另一个 Web 服务...

有接受者吗??

这是我需要从 if 语句启动的 Web 服务

/**
 * Web service operation
 */
@WebMethod(operationName = "bookHotel")
public String bookHotel(@WebParam(name = "destination")
String destination, @WebParam(name = "rooms")
int rooms) {        
    try {
        String ret = composite.bookHotel(destination, rooms);            
        return ret;
    } catch (myhotels.InterruptedException_Exception ex) {
        Logger.getLogger(compositeBookings.class.getName()).log(Level.SEVERE, null, ex);
    } catch (myhotels.FileNotFoundException_Exception ex) {
        Logger.getLogger(compositeBookings.class.getName()).log(Level.SEVERE, null, ex);
    }        
  return null;
}

【问题讨论】:

    标签: java web-services jakarta-ee jax-ws


    【解决方案1】:

    是的有可能,生成您要调用的服务的客户端并从那里调用该服务,

    但如果您有权访问该服务的代码,请直接使用其服务层,而不是从那里调用 SOAP

    【讨论】:

    • 我可以访问代码,但是它需要用户输入,就像父服务一样...
    • however it then requires user input just as the parent service does.. 没有明白这一点,你的意思是服务正在接受参数?如果这是您的意思,那么您可以像简单的 java 方法一样直接传递参数
    • 是的,它需要参数对不起。用户定义,与第一个相同 - @WebParam's
    • 好的,尝试使用简单的java方式调用它们,它应该被调用
    • 我已经更新了原帖。我在netbeans中这样做。当我测试第一个 Web 服务时,我得到了满足 Web 参数的输入框。我只需要调用第二个 Web 服务,或为此做一些事情,提示用户输入更多参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2013-03-27
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多