Java Restful Web Services给出错误

时间:2013-11-24 18:17:08

标签: java web-services rest post jersey

//Back end

@Path("/travelgood")
public class TravelgoodResource {

@POST
@Path("/{bookingNo}/{name}/{number}/{expMonth}/{expYear}")
public boolean bookingFlight(@PathParam("bookingNo") String bookingNo, @PathParam("name") String name, @PathParam("number") String number, @PathParam("expMonth") String expMonth, @PathParam("expYear") String expYear) {
    ws.tg.BookType booking = new ws.tg.BookType();
    booking.setBookingnumber(Integer.parseInt(bookingNo));
    CreditCardInfoType cci = new CreditCardInfoType();
    cci.setName(name);
    cci.setNumber(number);
    CreditCardInfoType.ExpirationDate ed = new CreditCardInfoType.ExpirationDate();
    ed.setYear(Integer.parseInt(expYear));
    ed.setMonth(Integer.parseInt(expMonth));
    cci.setExpirationDate(ed);
    booking.setCreditcardinformation(cci);
    boolean myBooking = false;
    try {

        myBooking = bookFlight(booking);
    } catch (BookFault ex) {
        Logger.getLogger(TravelgoodResource.class.getName()).log(Level.SEVERE, null, ex);
    }
    return myBooking;
}

private static boolean bookFlight(ws.tg.BookType input2) throws BookFault {
    ws.tg.Lameduck2Service service = new ws.tg.Lameduck2Service();
    ws.tg.Lameduck2PortType port = service.getLameduck2PortTypeBindingPort();
    return port.bookFlight(input2);
}

}


//TEST CLASS (Client)

public class TravelGoodRESTTest {

Client client = Client.create();

@Test
public void TestbookFlight() {
    WebResource r = client.resource("htttp://localhost:8080/tg/webresources/travelgood/1/Donovan%20Jasper/50408818/6/9");
    System.out.println("testBookFlight: "+r.post(String.class));
}
}

运行单元测试时,它会出现以下错误:

Caused an ERROR: POST htttp://localhost/8080/tg/webresources/travelgood/1/Donovan%20Jasper/50408818/6/9 returned a response status of 500 internal server error

0 个答案:

没有答案