2
나머지 웹 서비스를 사용하기 위해 Grails Plugin rest = 0.7을 사용하고 있습니다.Grails에서 REST webservice를 사용하여 pdf 파일을 다운로드 할 수 없습니다.
서비스의 응답이 XML 일 때 모든 것이 잘 작동하지만 응답이 pdf와 같은 파일 형식 인 경우 요청을 전송할 때 다운로드를 시작해야하지만 다운로드가 전혀 시작되지 않습니다.
아래 코드는 grails 서비스에서 구현되었습니다.
String httpUrl = 'http://abc.com/myService'
String data = '<methodcall protocol="2" method="avalidmethodname"><cmdid/><data><project_id>1</project_id><user_id>2</user_id><operation>ABC</operation><filter><status_type_id>1</status_type_id><scope_bits>00</scope_bits></filter></data></methodcall>'
String respText = ''
HttpClient httpClient = new DefaultHttpClient()
HttpResponse response
try {
HttpPost httpPost = new HttpPost(httpUrl)
httpPost.setHeader("Content-Type", "text/xml")
HttpEntity reqEntity = new StringEntity(data, "UTF-8")
reqEntity.setContentType("text/xml")
reqEntity.setChunked(true)
httpPost.setEntity(reqEntity)
response = httpClient.execute(httpPost)
// HttpEntity resEntity = response.getEntity()
// respText = resEntity.getContent().text
}
finally {
httpClient.getConnectionManager().shutdown()
}
return response
// return respText
주석 처리 된 코드 줄은 xml 응답의 경우입니다.
이 문제를 해결하는 데 도움을주십시오, 내가 사용하고있는 접근법이 webservice의 파일 응답의 경우에 유효한지 확실하지 않습니다.