我正在创建一个spring应用程序来访问返回TIFF图像的远程API。 api期望在标题中发送一些参数。我正在尝试使用我发现的示例中的以下代码..但是当我返回ResponseEntity响应时,它的长度为0,而byte []的响应为null。
{Content-Length = [0],Content-Type = [application / octet-stream],Server = [Microsoft-IIS / 7.5],X-Powered-By = [ASP.NET],Date = [Wed] ,2015年8月19日15:14:17 GMT]}
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
messageConverters.add(new ByteArrayHttpMessageConverter());
RestTemplate restTemplate = new RestTemplate(messageConverters);
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/octet-stream");
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://webservices.imagestorehouse.com/GetData.svc/getDocs")
.queryParam("token", "a80d4978c12549dbafcd1922c1efdaa5")
.queryParam("company_id", "SW1112b")
.queryParam("document", "1" )
.queryParam("field_1", "2627594")
.queryParam("field_4", "028000");
HttpEntity<String> entity = new HttpEntity<String>(headers);
//ResponseEntity<byte[]> respond = restTemplate.execute(builder.build().encode().toUri(), HttpMethod.GET, entity, byte[].class);
byte[] respond = restTemplate.getForObject(builder.build().encode().toUri(), byte[].class);
答案 0 :(得分:0)
您需要在响应标头中添加更多参数。
C�IL BEAG
CUIL BEAG