Monday, 16 September 2019

Send MIME emails (HTML Email body + Attachments) from OSB using UMS Adapter

Hi Guys,

Here I am trying to explain how to send MIME (Multipurpose Internet Mail Extensions) emails from Oracle Service Bus 12c using UMS adapter having HTML email body Content and one or more Attachments.

I am assuming you are able to send simple emails from OSB, this requires some configurations. There are many blogs available on this topic. You can refer below blogs if Needed for basic setup:



The main purpose of this blog is to highlight usage of MIME or multipart/mixed emails which can have email body with attachments.
A Sample emails like below:

STEPS to Achieve this in OSB:

This assumes, you have a working OSB project which is able to send emails. (You can Refer above blogs for this purpose)

Assuming you have transformed the message required for your scenario, which is available in below format before request reaches the Routing node in OSB Pipeline.

<tns:EmailPayload  xmlns:tns="">
<tns:Subject>POC| POC| NOTIFICATION | 2019-09-14T06:14:35.266-04:00</tns:Subject>
<table  border="1" bordercolor="grey">
<td  colspan="2" style="background-color:#33339F;color:white">
<td  style="background-color:#33339F;color:white">INTERFACE NAME</td>
<td  style="background-color:#33339F;color:white">ERROR DESCRIPTION</td>
<td>This is custom fault</td>

1. Below actions are required in OSB pipeline to achieve this. There may be other actions in your pipeline as well for purpose of audit/logging/invocations etc.

Transport Header Action:

Java Callout Action:

Content-type: text/html; charset="utf-8" 

Content-type: text/html; charset="utf-8" 
Content-Disposition: attachment; filename=payload.txt;


' )

Replace Action:

<ref:message xmlns:opaq="" 


Business Service tracing Logs for debugging:

[2019-09-16T06:44:18.466-04:00] [osb_server1] [NOTIFICATION] [OSB-398202] [oracle.osb.resources.service.service] [tid: [ACTIVE].ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 76bae70b-d533-4893-adda-a0d78240273b-0005e2b6,1:40787] [APP: Service Bus Routing] [FlowId: 0000Motf5J0Fw025zrH7iW1TU^G70004HD] [[
 [OSB Tracing] Outbound request was sent.

 Service Ref = DheerajOSB/BusinessServices/ref_UMS_Notification
 URI = jca://eis/ums/UMSAdapterOutbound
 Request metadata =
      <tran:headers xsi:type="jca:JCARequestHeadersXML" xmlns:jca="" xmlns:tran="" xmlns:xsi="">
        <jca:Content-Type>text/xml; charset=utf-8</jca:Content-Type>
        <jca:jca.ums.subject>POC | OSBSample2 | NOTIFICATION | 2019-09-16T06:44:18.236-04:00</jca:jca.ums.subject>
      <tran:encoding xmlns:tran="">utf-8</tran:encoding>
 Payload =
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv=""><soapenv:Body><ref:message xmlns:opaq="" xmlns:ref=""><opaq:opaqueElement>LS1NSU1FX0JvdW5kYXJ5IApDb250ZW50LXR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD0idXRmLTgi+Ci0tTUlNRV9Cb3VuZGFyeS0tIAoKCg==</opaq:opaqueElement></ref:message></soapenv:Body></soapenv:Envelope>

[2019-09-16T06:44:18.506-04:00] [osb_server1] [NOTIFICATION] [OSB-398203] [oracle.osb.resources.service.service] [tid: [ACTIVE].ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 76bae70b-d533-4893-adda-a0d78240273b-0005e2b6,1:40787:14] [APP: Service Bus JCA Transport Provider] [FlowId: 0000Motf5J0Fw025zrH7iW1TU^G70004HD] [[
 [OSB Tracing] Outbound response was received.

 Service Ref = DheerajOSB/BusinessServices/ref_UMS_Notification
 URI = jca://eis/ums/UMSAdapterOutbound
 Message ID = a008016.2736342f.5.16d25a4109a.N7a1b
 Response metadata =
   <tran:headers xsi:type="jca:JCAResponseHeadersXML" xmlns:jca="" xmlns:tran="" xmlns:xsi=""/>
   <tran:response-code xmlns:tran="">0</tran:response-code>
 Payload =


1 comment:

  1. Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles. OSB Online Training