如何编写具有多个参数的Apache-CXF post Rest服务客户端

时间:2014-05-04 03:38:18

标签: java rest cxf

我需要使用多个参数调用Rest POST API。以下是post rest api的签名

@POST
@Consumes({"application/json" })
@Produces("application/json")
@Path("/service/postEmployeeBatch")
Response postEmployeeBatch(Employee employee, Organization org);

以下是Rest客户端代码

List<Object> providers = new ArrayList<Object>();
ObjectMapper mapper = new ObjectMapper();
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.setMapper(mapper);
providers.add(provider);
WebClient client = WebClient.create("http://test.com:8080/EmployeeService",            providers);
client.path("service/postEmployeeBatch/");
client.type("application/json").accept("application/json");
Employee emp = ...
Organization org = ....
//Response r = client.post(emp, org);

我不清楚如何使用多个输入参数调用WebClient.post。我很感激任何帮助或指导,

0 个答案:

没有答案