package aaa;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Arrays;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
public class Test001 {
public static void main(String[] args) throws Exception {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(new MediaType("application", "x-www-form-urlencoded"));
// headers.getAccept().clear();
// .setAccept(Arrays.asList(new MediaType("application", "json",Charset.forName("GBK"))));
//headers.setAccept(Arrays.asList(new MediaType("application", "json",Charset.forName("utf-8"))));
headers.setAccept(Arrays.asList(new MediaType("application", "json",Charset.forName("GBK"))));
//headers.setAccept(Arrays.asList(new MediaType("application", "json")));
System.out.println(headers);
HttpEntity<String> requestEntity = new HttpEntity<String>("auth_token=你好",headers);
// ResponseEntity<String> exchange = restTemplate.exchange("http://127.0.0.1:8003/open/test_pa/hello/post", HttpMethod.POST, requestEntity, String.class);
ResponseEntity<String> exchange = restTemplate.exchange("http://10.20.18.55:8008/mhis-fwa-platform/public", HttpMethod.POST, requestEntity, String.class);
ResponseEntity<byte[]> exchange1 = restTemplate.exchange("http://10.20.18.55:8008/mhis-fwa-platform/public", HttpMethod.POST, requestEntity, byte[].class);
// ResponseEntity<String> exchange2 = restTemplate("http://10.20.18.55:8008/mhis-fwa-platform/public", HttpMethod.POST, requestEntity, String.class);
//ResponseEntity<Map> exchange = restTemplate.exchange("http://10.42.8.94:8003/open/mhis-fwa-platform/public", HttpMethod.POST, requestEntity, Map.class);
//ResponseEntity<String> exchange = restTemplate.exchange("http://10.42.8.94:8003/open/mhis-fwa-platform/public", HttpMethod.POST, requestEntity, String.class);
System.out.println(new String(exchange1.getBody(),"ISO-8859-1"));
System.out.println(new String(exchange1.getBody(),"GBK"));
System.out.println(new String(exchange1.getBody(),"UTF-8"));
//System.out.println(new String(exchange1.getBody()));
System.out.println(exchange1.getHeaders());
}
}