我想从我的程序中调用一个webservice,它接受字符串数据并返回inputstream
。但是当我编写了客户端代码时,我发现响应类型HttpMessageConverter
和内容类型class java.io.InputStream
找不到合适的application/octet-stream
。所以请帮帮我。
这是我的客户代码
public InputStream zipFolderWithSubsequestFolder(String folderToBeZipped, String transactionId) {
LOGGER.debug("DataShareServiceClient :: zipFolder() : Calling zipFolderWithSubsequestFolder Service -> folderToBeZipped: "
+ folderToBeZipped);
String header = getServiceName();
// RestTemplate restTemplate = new RestTemplate();
url = url + "/" + "rest" + "/"
+ "DataShareService" + "/"
+ "zipFolderWithSubsequestFolder";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
HttpEntity<String> requestEntity = new HttpEntity<String>(folderToBeZipped, headers);
InputStream response = restTemplate.postForObject(url, requestEntity, InputStream.class);
// Make the HTTP POST request, marshaling the request to JSON, and the response to a String
//ResponseEntity<InputStream> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, InputStream.class);
//InputStream result = response.getBody();
return response;
}