Showing posts with label OSB 12c. Show all posts
Showing posts with label OSB 12c. Show all posts

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:

1.  https://blog.sysco.no/osb/messaging/UMS_Adapter_send_email_OSB_12C/

2.  http://blog.sysco.no/osb/messaging/UMS_Adapter_send_html_content_email_OSB_12C/



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="http://www.dheerajOSB.com">
<tns:To/>
<tns:Subject>POC| POC| NOTIFICATION | 2019-09-14T06:14:35.266-04:00</tns:Subject>
<MailBody>
<html>
<body>
<table  border="1" bordercolor="grey">
<tr>
<td  colspan="2" style="background-color:#33339F;color:white">
<Center>
<b>NOTIFICATION DETAILS</b>
</Center>
</td>
</tr>
<tr>
<td  style="background-color:#33339F;color:white">INTERFACE NAME</td>
<td/>
</tr>
<tr>
<td  style="background-color:#33339F;color:white">ERROR DESCRIPTION</td>
<td>This is custom fault</td>
</tr>
</table>
</body>
</html>
</MailBody>
</tns:EmailPayload>



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:





fn:concat('--MIME_Boundary 
Content-type: text/html; charset="utf-8" 

',fn-bea:serialize($varUMSPayload//*:MailBody/*),'
--MIME_Boundary 
Content-type: text/html; charset="utf-8" 
Content-Disposition: attachment; filename=payload.txt;

',fn-bea:serialize($body//*:XMLPayload),'
--MIME_Boundary-- 


' )



Replace Action:





<ref:message xmlns:opaq="http://xmlns.oracle.com/pcbpel/adapter/opaque/" 
xmlns:ref="http://platform.integration.oracle/blocks/adapter/fw/metadata/ref_UMS_Notification">
    <opaq:opaqueElement>{$varBase64}</opaq:opaqueElement>

   </ref:message>





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 =
    <xml-fragment>
      <tran:headers xsi:type="jca:JCARequestHeadersXML" xmlns:jca="http://www.bea.com/wli/sb/transports/jca" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <jca:SOAPAction>"SendNotification"</jca:SOAPAction>
        <jca:Content-Type>text/xml; charset=utf-8</jca:Content-Type>
        <jca:jca.ums.to>dheexxxxxxhra@gmail.com</jca:jca.ums.to>
        <jca:jca.ums.subject>POC | OSBSample2 | NOTIFICATION | 2019-09-16T06:44:18.236-04:00</jca:jca.ums.subject>
        <jca:jca.ums.msg.content-type>multipart/mixed;boundary="MIME_Boundary"</jca:jca.ums.msg.content-type>
        <jca:jca.ums.msg.content-transfer-encoding>7bit</jca:jca.ums.msg.content-transfer-encoding>
        <jca:jca.ums.part.content-transfer-encoding>7bit</jca:jca.ums.part.content-transfer-encoding>
      </tran:headers>
      <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
    </xml-fragment>
 Payload =
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ref:message xmlns:opaq="http://xmlns.oracle.com/pcbpel/adapter/opaque/" xmlns:ref="http://platform.integration.oracle/blocks/adapter/fw/metadata/ref_UMS_Notification"><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 =
 <xml-fragment>
   <tran:headers xsi:type="jca:JCAResponseHeadersXML" xmlns:jca="http://www.bea.com/wli/sb/transports/jca" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
   <tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
 </xml-fragment>
 Payload =



]]

Thursday 13 July 2017

CSV to XML or Native to XML Transformation using MFL

Hi Guys,

Recently one of associate asked me about the MFL, so here I am writing this post on the usage of the MFL.
What I have experienced so far is, there are very few SOA experts who uses the Message Format Language or MFL.
There are others, who underestimates the MFL capability as compared to Oracle Technology adapters.

Lets get started..

Use case :
Reading a .csv file from file location, transforming to XML, and writing the XML file to another location.
Sample Input CSV Message -

CustomerID;Firstname;Lastname;Age
1212;Dheeraj;Mishra;25
3242;Ajay Kumar;Singh;43

Background -
The MFL can be used to transform a Native format to XML and vice versa. The biggest advantage MFL provides is, It can be done in OSB message flow. So you have option to log or audit both the formats as well as you can use it anywhere in Message flow as per your need.
Whereas Oracle technology adapters can only be used as a start point or end point of service.

Another advantage, MFL requires only one artifact (MFL transform file, .mfl file) for message transformation and no extra configuration is needed. Whereas Oracle Technology adapters will generate multiple artifacts like .wsdl file, .xsd file, .jca file etc.
Due to this Oracle Technology adapters can make the service complex when you have to cater for multiple formats conversion.

Implementation:

Step 1 - Create Proxy to read .csv file.









 Step 2 - Create a Pipeline (Not applicable in 11g)



Step 3 - Add pipeline in Message flow


Step 4 - Now create a MFL transform file. 



New MFL will look like below- 



Step 5 - Add GROUP by right click on message icon in MFL. This is needed only if your Message or File has repeated records.
There are few properties on this page.
tick OPTIONAL if file can have only one record.
tick UNLIMITED if file can have more than one record.
Enter DELIMITER, usually \n for next line. Sometimes, it could be anything else like ; or " or | etc.
Tick DELIMITER IS OPTIONAL if this is possible to be used as delimiter for the last field in a record. As in our example, Last field uses \n as delimiter



Step 6 - Now add fields names as child elements in order of occurrence under Group.
Mention there Delimiters. Here delimiter is ;



Notice Last field has '\n' as delimiter



Step 7 - Test you MFL in Jdevloper itself



Step 8 - Now go back to Message flow, Add MFL transform Action. Specify the properties as shown.
Here MFL output is assigned to VarXML variable




Step 9 - Add replace action to put XML in Body content



Step 10  - Create Business Service to write XMl file.






Step 11 - Add Route, Browse Business Service






Thats it guys. You have completed the Service.
Now go on deploy it to server, and Test the Service

Here's the Sample output file

<?xml version="1.0" encoding="UTF-8"?>
<CSVToXML>
  <Customer>
    <customerId>CustomerID</customerId>
    <firstName>Firstname</firstName>
    <lastName>Lastname</lastName>
    <age>Age</age>
  </Customer>
  <Customer>
    <customerId>1212</customerId>
    <firstName>Dheeraj</firstName>
    <lastName>Mishra</lastName>
    <age>25</age>
  </Customer>
  <Customer>
    <customerId>3242</customerId>
    <firstName>Ajay Kumar</firstName>
    <lastName>Singh</lastName>
    <age>43</age>
  </Customer>
</CSVToXML>



Download the sample osb jar file from below link
https://drive.google.com/open?id=0BxHj0h0tnxxObDkzT2FCNUN6aEE




Friday 9 December 2016

OSB-382032: The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope

The error could be as seen below :

<soap:Text  xml:lang="en">
OSB-382032: The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
</soap:Text>
</soap:Reason>
<soap:Detail>
<con:stack-trace  xmlns:con="http://www.bea.com/wli/sb/context">
com.bea.wli.sb.service.handlerchain.HandlerException: The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
 at com.bea.wli.sb.service.handlerchain.handlers.ComputeOperation$1.getPayload(ComputeOperation.java:204)
 at com.bea.wli.sb.services.bindinglayer.BindingOperationMapper$QNameMapper.computeOperationName(BindingOperationMapper.java:564)
 at com.bea.wli.sb.service.handlerchain.handlers.ComputeOperation.dispatch(ComputeOperation.java:93)


Analysis:
This issue comes when you are invoking a SOAP 1.2 web service.
The request you sent, to service must have namespace declaration with
http://www.w3.org/2003/05/soap-envelope

I see 3 differences in SOAP 1.1 & SOAP 1.2 :
  • SOAP 1.2 uses "application/soap+xml" as Content-Type and SOAP 1.1 uses "text/xml".
  • SOAP 1.2 does not use SOAPAction header line.
  • SOAP 1.2 uses "http://www.w3.org/2003/05/soap-envelope" as the envolope namespace and SOAP 1.1 uses "http://schemas.xmlsoap.org/soap/envelope/".

Solution :
Make sure the payload you are sending to Target SOAP 1.2 service is having correct namespace declaration.
Your payload should be something like below :

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">

<soapenv:Header  xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
</soapenv:Header>
<soapenv:Body  xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<get:string  xmlns:get="http://xmlns.oracle.com/OSB_App_Jaguar/Santa/GetSantaDetails"></get:string>
</soapenv:Body>
</soapenv:Envelope>

Saturday 5 March 2016

OSB 12c - For Each action

Hey guys !

In this Post I am going through the For Each functionality in OSB 12c.


Use Case 

Simple Integration  Scenarios, Where Source system payload has Repeated Nodes, Target System expects one node at a time.



Design


Step 1 : 

Create a OSB Project, Add a Pipeline. Inside Pipeline Add a For Each Action.





Step 2:

Provide the required data in For Each Properties. Shown below



This is all we need to Implement For Each. 
However we will have to further process the Data, This could depend on your Requirement.
For the Demo Purpose, I am Sending this data to a Business Service using Publish Action.


Step 3:

Add a Publish Action inside For Each. Add a Assign action to see the Payload of the For Each iteration in Testing. Screens Below





Step 4:

Export and Deploy your code to Server.



Testing







Request Payload

<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
  <Message>
        <MessageID>1</MessageID>
        <OrderReport>
            <OrderID>102-4552-913811</OrderID>           
            <Item>
                <OrderItemCode>09588730573218</OrderItemCode>
                <SKU>05988-2066</SKU>                
             </Item>
        </OrderReport>
  </Message>
  <Message>
        <MessageID>2</MessageID>
        <OrderReport>
            <OrderID>102-4556812-97811</OrderID>           
            <Item>
                <OrderItemCode>09588730573218</OrderItemCode>
                <SKU>05988-20166</SKU>                
             </Item>
        </OrderReport>
  </Message>
  <Message>
        <MessageID>3</MessageID>
        <OrderReport>
            <OrderID>102-4556812-91371</OrderID>           
            <Item>
                <OrderItemCode>09588730573218</OrderItemCode>
                <SKU>05988-266</SKU>                
             </Item>
        </OrderReport>
  </Message>
</Envelope>


For Each output for Last Iteration

<Message>
<MessageID>3</MessageID>
<OrderReport>
<OrderID>102-4556812-91371</OrderID>
<Item>
<OrderItemCode>09588730573218</OrderItemCode>
<SKU>05988-266</SKU>
</Item>
</OrderReport>
</Message>



Thats All Folks !






Here are some other posts, which may interests you

1. Fusion Middleware 12c – SAP Adapter Configuration

http://osb-dheeraj.blogspot.in/2016/02/fusion-middleware-12c-sap-adapter.html

2. Oracle Integration Cloud Service (ICS)

http://osb-dheeraj.blogspot.in/2016/02/oracle-integration-cloud-service-ics.html


3. SOA Interview Questions : Service Oriented Architecture Interview Questions Part 1

http://osb-dheeraj.blogspot.in/2016/02/soa-interview-questions-service.html



http://osb-dheeraj.blogspot.in/2016/02/osb-12c-domain-value-map-dvm.html

Saturday 27 February 2016

OSB 12c - Domain Value map (DVM)


Hey guys !

Here I am going through the Domain Value map (DVM) functionality in OSB 12c.
In the 12c versions of OSB, Support for the DVM is included, Hence lets discuss the use case and Steps to implement DVM.

Use Case 

Simple Integration  Scenarios, Where Source system, Which sends data to Target System needs domain conversion of values.

A very typical example is Country name to Country Code conversion using DVM, i.e. Source system sends Country name and Target system expects Country code.

Design


Step 1 :

Open Jdevloper 12c (Service Bus console can also be used), Create a Service Bus Project.
I have given name to project as 'SBProject_DVM'

Step 2:

Create Source and target Schemas or WSDL (This is not a essential Step). For better demonstration, I Have used WSDL.



Step 3:

Create a Domain value map (CountryName_Code.dvm) and Add the Domain Name and Values. Atleast 2 rows needs be added.




Step 4:

Create a XSLT mapper (CountryNameToCode.xsl), Choose Source and Target to this mapper from your WSDL.



Step 5 :

User mapper to drag and Drop mapping element, Shown below




Step 6:

Go to XSLT source view and Edit the code as below 




Add this snippet 

<CountryCode>          
            <xsl:value-of select="DVMFunctions:lookupValue (&quot;SBProject_DVM/CountryName_Code&quot;, &quot;Name&quot;, string(/ns0:process/ns0:CountryName), &quot;Code&quot;, &quot;Unknown&quot; )"/>
 </CountryCode>



Now if you go to Design view, the below design will be visible





Step 7:

Create a new Pipeline Based on your WSDL and go to design view.
Add Pipeline pair to it, 
Inside Request Pipeline add a Stage. Inside stage add a 'Replace' action.
Inside Response Pipeline add a Reply action with Success.




Step 8:

Lets go to Replace action and use the Earlier created XSLT mapper to do the DVM  task.




In the input Field add the Variable which contains input element, as below





Step 9:

Save your changes and Export is to deploy to Test Server or Deploy directly from Jdeveloper.





Testing 

Step 1:

Open the Pipeline, click on test button, this will open in new window







Step 2:

Edit the request payload and click on Execute button to test it.








Voila !
You have successfully created DVM using OSB 12c


You can download the sbconfig jar of this project from
https://drive.google.com/file/d/0BxHj0h0tnxxOWWVYVXVvTGtWUGs/view?usp=sharing





Here are some other posts, which may interests you

1. Fusion Middleware 12c – SAP Adapter Configuration

http://osb-dheeraj.blogspot.in/2016/02/fusion-middleware-12c-sap-adapter.html

2. Oracle Integration Cloud Service (ICS)

http://osb-dheeraj.blogspot.in/2016/02/oracle-integration-cloud-service-ics.html


3. SOA Interview Questions : Service Oriented Architecture Interview Questions Part 1

http://osb-dheeraj.blogspot.in/2016/02/soa-interview-questions-service.html

Wednesday 17 February 2016

Oracle SOA Suite 12c - OSB Domain Configuration part 2

This post is in continuation with previous post, you can find part 1 at :

http://osb-dheeraj.blogspot.in/2016/02/oracle-soa-suite-12c-osb-domain.html


Lets continue with domain creation steps



Step 10:
The Wizard will test each connection, if you have given correct information, then all connection will show success as below, Then Click Next




Step 11:
Click Next on the Screen,




Step 12:
On this screen select the elements, which you want to configure for your domain. For example select Admin server and Manage Server then click on Next, as shown




Step 13:
Provide Server port Number, Host Address, and SSL port, You can keep the default setting as well. Then Click Next




Step 14:
For Managed Server, Provide Name, Port, SSL Port, or keep the default settings.




Step 15:
Since we have only one Managed server, hence we do not need cluster, Click Next




Step 16:
Click next for Coherence and Coherence Cluster Screen. Click on + button to add Machine, Provide details of your machine




Step 17:
Then look the Summary of your configuration and Click Create





Step 18:
It will take some time to create the domain. The last will be the confirmation screen.


Voila ! you have successfully created your OSB 12c Domain.





In case you want to go through the steps for SOA domain, refer my previouspost here:

Oracle SOA Suite 12c - SOA Domain Configuration

http://osb-dheeraj.blogspot.in/2016/02/oracle-soa-suite-12c-soa-domain.html