从Rest服务调用中检索流数据

我正在创建一个将使用以下kotlin代码调用的webservice

 fun submitRequest(request: PKCS10CertificationRequest): String { // Post request to certificate signing server via http. val conn = URL("$server/api/certificate").openConnection() as HttpURLConnection conn.doOutput = true conn.requestMethod = "POST" conn.setRequestProperty("Content-Type", "application/octet-stream") conn.setRequestProperty("Client-Version", clientVersion) conn.outputStream.write(request.encoded) return when (conn.responseCode) { HTTP_OK -> IOUtils.toString(conn.inputStream, conn.charset) HTTP_FORBIDDEN -> throw IOException("Client version $clientVersion is forbidden from accessing permissioning server, please upgrade to newer version.") else -> throwUnexpectedResponseCode(conn) } } 

我使用jx-rs在java中编写web服务我的代码:

 @POST @Path("certificate") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces("text/html") public Response postCertificate(InputStream entity) throws IOException { PKCS10CertificationRequest p = new PKCS10CertificationRequest(IOUtils.toByteArray(entity)); p.getAttributes(); System.out.println(p); String output = dbService.createAndSaveRequest(); return Response.status(200).entity(output).build(); } 

有人可以帮助我阅读流,我已经尝试过它不正常工作,我无法从p对象检索数据