开发者

Web Service to Trigger another Web Service?

Is it possible to trigger a web service from within a web service?

/**
 * 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;
}

In the empty if function body I need to trigger another web service...

Any takers??

Here is the web service I need to launch from the if statement

/**
 * 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;
}


Yes it is possible, generate client of the service you want to call and invoke that service from there,

But if you have access to the code of that service , use its service layer directly rather than invoking a SOAP from there

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜