我正在为restful webservice制作一个java客户端,我想在请求正文中发送一个字符串。
这是我的课。
public class params {
private String test;
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
这是我的主要功能类。
public class testclient implements MessageBodyReader<params> {
public static void main(String[] args) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
params pobj = new params();
pobj.setTest("myname");
System.out.println(service.path("interface").post(params.class);
}
private static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost:8080/ivrservices").build();
}
public boolean isReadable(Class<?> params, Type genericType, Annotation[] arg2,
MediaType arg3) {
return false;
}
public params readFrom(Class<params> arg0, Type arg1,
Annotation[] arg2, MediaType arg3,
MultivaluedMap<String, String> arg4, InputStream arg5)
throws IOException, WebApplicationException {
// TODO Auto-generated method stub
return null;
}
}
我在默认函数中传递什么参数?