有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

web服务Java Restful web服务提供错误

//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) 个答案