-1

C sharp 的 Easy Http 库有一种将数据发布到 url 的方法,

var customer = new Customer(); 
    customer.Name = "Joe"; 
    customer.Email = "joe@smith.com";
    var http = new HttpClient();
    http.Post("url", customer, HttpContentTypes.ApplicationJson);

寻找一些库来将数据发布到 Java 的 URL。

4

2 回答 2

0

Jersey是一个很棒的免费 API,用于对 URL进行POSTs 和s 操作。GET

MultivaluedMap<String, String> formParams = new MultivaluedMapImpl();
formParams.add("requestXML",requestXML);
formParams.add("version","1");

WebResource webResource = Client.create().resource("http://myurl.org/");
String response = webResource.type(MediaType.APPLICATION_FORM_URLENCODED).post(String.class, formParams);
于 2013-08-26T13:40:05.227 回答
0

您可以使用 Apache 的HTTPClient在 Java中创建基本HTTP操作。

例如,aPOST看起来像这样:

HttpPost httpPost = new HttpPost("http://some-web-site");
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("name", "Joe"));
nvps.add(new BasicNameValuePair("email", "joe@smith.com"));
httPost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity result = response.getEntity();
于 2013-08-26T13:42:23.407 回答