Skip to main content

UMS Adapter configuration for mail polling and attachment download

Hi,

Today we are going to configure UMS adapter in SOA to download mail attachment & push it on file/FTP location.


·         Click on Email Driver properties.


·       In EM FMW Control, open the User Messaging Service node in the navigator and select the usermessagingdriver-email for the relevant managed server. From the context menu, select Email Driver Properties. When there no configuration yet, you will create a new one. If you already configured the SOA Suite for outbound mail traffic, you can edit that configuration for the inbound direction.

·         Click on create
·         In the property overview, there are some properties to set:







Press the OK button at the top of the page to apply all configuration changes.

  • The Email Receiving protocol for GMail is IMAP.
  • The Incoming Mail Server is imap.gmail.com.
  • The port should be set to 993 and GMail wants to communicate over SSL, so the checkbox should be checked.
  • The Incoming MailIDs are the email addresses that correspond to the lust names under Incoming User IDs. For GMail these can both be the full GMail email-addresses.
  • There are several ways to configure the password. The least safe one is by selecting Use Cleartext Pasword and simply typing the password for the GMail account in the password field.
  • The password is then stored somewhere on the WebLogic server in readable form.


Load Certificate into Keystore:
  • Download SSL certificate of your Mail server, In case of Gmail download complete certificate chain.
  • Open Demo Trust.JKS file as this file is default mapped as trust store for our weblogic env.
  • Import SSL certificate chain using KEYTOOL command or any other UI tool.



  • The interaction between the UMS server and GMail’s IMAP API takes place over SSL. That means that the WebLogic managed server on which the UMS service runs has to have the SSL certificate for the IMAP server loaded in its local.
  • Do a full bounce of SOA env.


JDEV Configuration:
  • Create one SOA project
  • Drag UMS adapter in SOA composite






Get file name in BPEL:

substring-before (substring-after(concat(ora:getAttachmentProperty('Content-Type', 'inputVariable','body','/ns3:message/ns3:attachment[2]'), ';'), 'name=' ), ';')
attachment[2] is to get file name of attachment, In case you have multiple attachment in mail you can get them using index like 2,3..N.

Get attachment content and upload in file directory:

Create one file adapter.
Design invoke activity for same.
Get file attachment data as base64 and upload in file directory using attachment function.
ora:getAttachmentContent('inputVariable','body','/ns3:message/ns3:attachment[2]')



Test results:
  • Send a mail to configured email ID.




Other imp function about mail attachment processing:


ora:writeBinaryToFile()


There's inbuilt function ora:writeBinaryToFile() that automatically extracts the attachment from the Attachment href (in the binary format) and writes to the specified target file (hence you don’t need to use ora:getAttachmentContent() in front of it). Follow the below steps to write it to file using ora:writeBinaryToFile() .


Assign the following in the Source side. In BPEL source , comple Assign statement would look like as shown below.
<copy>
       <from>ora:writeBinaryToFile('inputVariable','body','/ns3:message/ns3:attachment[2]', '/u01/app/oracle/userdir/NewAttachment.xml')</from>
       <to>$CustomAttachmentVariable/ns2:attachment</to>
</copy>


How to retrieve name of the Email Attachment:


Once you have made Attachments to work in your BPEL process and able to parse them, it may be necessary to retrieve the actual name of the email attachment read. The best way to do that is using out-of-the-box function as given below

ora:getAttachmentProperty('Content-Disposition', 'inputVariable','body','/ns3:message/ns3:attachment[2]')

The above should return attachment; filename="test.txt"; however, nothing is as simple in this world and to make it true, it is a known BUG:19492062. Luckily, we have a patch 1941333.1available to apply and get going but it may be time consuming to request a patch, do the impact assessment and get it applied across all environments. Whilst that may be the ideal solution in the long term but to quickly test and retrieve the attachment name you can use property Content-Type as given under.
<assign name="AssignEmailAttachmentName">
  <copy>
    <from>substring-before (substring-after(concat(ora:getAttachmentProperty('Content-Type', 'inputVariable','body','/ns3:message/ns3:attachment[2]'), ';'), 'name=' ), ';')</from>
    <to>emailAttachmentName</to>
  </copy>
</assign>
ora:getAttachmentProperty() function on Content-Type returns text/plain; charset=UTF-8; name=test.txt; any additional text;
Substring-before() and substring-after() have been done to intelligently extract string after name=
emailAttachmentName- is a string type custom variable to store the attachment name













Comments

  1. Good post....thanks for sharing.. very useful for me i will bookmark this for my future needs. Thanks.
    Attache Handle Manufacturer in Delhi

    ReplyDelete

  2. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle ADF . Actually I was looking for the same information on internet for Oracle ADF and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle ADF . By attending Oracle ADF Training .

    ReplyDelete

  3. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA Training
    . Actually, I was looking for the same information on internet for Oracle SOA Interview Questions and Answers

    and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more about Oracle SOA Tutorial also.

    ReplyDelete

Post a Comment

Popular posts from this blog

Oracle SOA 12C rest adapter with Custom HTTP headers

Most existing web applications are connected through web services, which are commonly known as SOAP services. More and more users are relying on mobile devices for communication, and they’re looking for lighter ways to access enterprise information on the go. REST services are the answer for the mobile device platform, because they get rapid responses and fast access to data. Oracle SOA Suite 12 c  provides a complete set of service infrastructure components for designing, deploying, and managing composite applications. Oracle SOA Suite 12 c  enables services to be created, managed, and orchestrated into composite applications and business processes. Some time we have need to send HTTP headers in REST service, In OSB we use header component and add what ever is needed but in oracle SOA 12C it's little bit different. Let see how we can do it. Create one SOA Application. Create one SOA Sample project inside SOA Application. Go to composite and drag drop REST adapt

Dynamic Routing in OSB 12C

Dynamic Routing in OSB cab be used when the BusinessService endpoint required to be determine at runtime in message flow. Consider a scenario where OSB has to route the incoming requests to 2 different services based on the CustomerType element value sent in the payload. So create a XQuery resource with the following contents. Observe that we are using the absolute path of business service in configuration as required by dynamic routing. Following is the XML schema that we use:>>  Customer.xsd <?xml version="1.0" encoding="windows-1252" ?> <xsd:schema targetNamespace="http://xmlns.oracle.com/schema/Customer" xmlns:xsd="http://www.w3.org/2001/XMLSchema"             xmlns:ns1="http://xmlns.oracle.com/schema/Customer">   <xsd:complexType name="Customer">     <xsd:sequence>       <xsd:element name="CustomerId" type="xsd:string"/>       <xsd:elemen

Swagger API document from Any WADL & Schema in Oracle SOA

Hi everyone, Hope everyone is doing well these days, Recently i started a project work over how to generate swagger API document for your any REST API, In case if you don't know what is swagger please go and check " https://swagger.io/tools/swagger-editor/ ". It's a great and easy to use tool which will help to create user friendly, human readable form API documentation with extension for generating API client in different languages with capability of testing your API from same. What is swagger editor, Design, describe, and document your API on the first open source editor fully dedicated to OpenAPI-based APIs. The Swagger Editor is great for quickly getting started with the OpenAPI (formerly known as the Swagger Specification) specification, with support for Swagger 2.0 and OpenAPI 3.0.  What benefits you will get by using swagger, Runs Anywhere, The Editor works in any development environment, be it locally or in the web. Smart Feedback, Validate you