The following code is an explanation of how you can call a rest web service in java. Below you can find the actual java code and soapUI configuration. We enumerate 3 type of methods namely: POST, PUT and DELETE.
How to call rest web service using soapUI
public class Person {
private int id;
private String firstName;
private String lastName;
}
@POST
@Path("/")
public ActionStatus create(Person postData) {
}
In soapUI
Method=POST
MediaType=application/json
Json String=
{
"firstName" : "edward",
"lastName" : "legaspi"
}
@PUT
@Path("/")
public ActionStatus update(Person postData) {
}
In soapUI
Method=PUT
MediaType=application/json
{
"id" : 1,
"firstName" : "edward",
"lastName" : "legaspi"
}
@DELETE
@Path("/{personId}")
public ActionStatus delete(@PathParam("personId") Long reservationId) {
}
In soapUI
Method=DELETE
Request Parameters=
name=personId
value=1
style=template
level=resource
Your resource should look like: /xxx/{personId}
0 nhận xét:
Đăng nhận xét