Untitled
unknown
java
a year ago
2.1 kB
7
Indexable
private GenericResponse sendEmail(Mail mail, String template) { try { OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(5, TimeUnit.MINUTES) .writeTimeout(5, TimeUnit.MINUTES) .readTimeout(5, TimeUnit.MINUTES) .build(); log.info("sendEmail SEND_EMAIL_FROM: {}", SEND_EMAIL_FROM); MediaType mediaType = MediaType.parse("text/xml"); RequestBody body = RequestBody.create(mediaType, "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:skk=\"http://10.3.6.246:5555/skkmigas.ws.inbound.common:wsCommon\">\r\n <soapenv:Header/>\r\n <soapenv:Body>\r\n <skk:sendNotificationViaEmail>\r\n <to>support.esdc@skkmigas.go.id</to>\r\n <cc></cc>\r\n <bcc></bcc>\r\n <subject>tes notif</subject>\r\n <bodyEmail>test notification</bodyEmail>\r\n <from>notifikasi.esdc@skkmigas.go.id</from>\r\n </skk:sendNotificationViaEmail>\r\n </soapenv:Body>\r\n</soapenv:Envelope>"); // log.info("Request Soap", soap); log.info("Request Body", body); log.info("sendEmail", SEND_EMAIL_URL); Request request = new Request.Builder() .url(SEND_EMAIL_URL) .post(body) .addHeader("SOAPAction", "\"#sendNotificationViaEmail\"") .addHeader("content-type", "text/xml") .build(); log.info("sendEmail request: ", request); Response response = client.newCall(request).execute(); log.info("sendEmail response: ", response); return objectMapper.readValue(response.body().string(), GenericResponse.class); } catch (IOException e) { log.error("failed to send email with subject: {} to: {} with exception: {}", mail.getSubject(), mail.getTo(), e.getMessage(), e); throw new RuntimeException(e); } }
Editor is loading...
Leave a Comment