Wednesday 30 November 2016

Rejection Message handler in Oracle SOA 11g

Use Case- 
Reading student details from a csv based file if data is not correct than placing the incorrect data file to a different location.
To handle the rejected messages we will use Fault Handling Framework.

First Create a SOA Application StudentInfo and a SOA project ReadStudentInfo.
Create a Bpel Process ReadDetails  with Define Service Later template.




















Next Step is to create a Sample .txt file that we will use to configure the FileAdapter.
















Now add a file adapter and configure it to read files of this format.
Select the Read operation give the fie location from where you want to read the file and specify the file format for example here *.txt. Specify the polling frequency.
Next Step to select the Native Format Builder explained in detailed manner in my previous blog:- http://oraclesoasolution.blogspot.in/2016/11/generating-csv-file-with-header-name.html


 .











 














Wire the FileAdapter and Bpel process and create receive activity with create instance checked option in bpel  to receive input.











Create a folder in your local system where you want the rejected messages to come, say C:\temp\students\error .
Create a new file fault-policies.xml and add the following code in it.

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies>
<faultPolicy version="2.0.1" id="RejectedMessages">
<Conditions>
<!-- All the fault conditions are defined here -->
<faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
name="rjm:ReadInfo">
<condition>
<action ref="writeToFile"/>
</condition>
</faultName>
</Conditions>
<Actions>
<Action id="writeToFile">
<fileAction>
<location>c:/temp/students/error</location>
<fileName>stud_%TIMESTAMP%.txt</fileName>
</fileAction>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>                                                                 

Notice that the name of the fault attribute refers to the adapter name that we configured in the previous step.
 <faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages" name="rjm:ReadInfo ">

In the actions section, we have specified a file action. We can specify four types of actions here:-
  1. File action
  2. Java handler
  3. Queue
  4. Web service 
Now create another file called fault-bindings.xml and add following code

<faultPolicyBindings version="2.0.1"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<service faultPolicy="RejectedMessages">
 <name> ReadInfo </name>
</service>
 </faultPolicyBindings>

The fault policy given here, “RejectedMessages”, needs to match what we gave as Id in fault-policies file.
Make sure that the adapter is not polling recursively by checking the adapter .jca file.


  





 

   


Deploy the code
     Put a file named student.txt with incorrect format, such as below.








 
Check the folder specified there you will find the file with that data also check the em console there you will see the error message.
 








If we did not specify a location in the fileAction, then by default, the messages are stored in the directory:- <<domain_name>>/rej_msgs/<<wls_server_name>>/<<composite name>>

Generating .csv file with header Name using FileAdapter in Oracle SOA 11g

First create a csv file in excel and save it in csv format.


 


Create a SOA application -> SampleCSVApp and a SOA project inside it CSVTest
Drop a FileAdapter from Component Palette and give a name like WriteCSV select the write operation Type.
Next step select the output Directory and give a file name.



In next step  select the native format builder by clicking the icon next to search icon
















 Select delimited option



Now here in this step you will browse the .csv file that we have created earlier 

















Select the datatypes of the column and give element name




















































Check use the first record as the field names and select next now you will see a xsd is generated with specified type and name.

















You can test it by clicking on Test and finish.


















Now create a one way bpel process and in input parameter select the same sample xsd element.




























Now use a transform activity to send input data to file.














The generated file will not have header names details in it.if you want to add the header name details in generated csv file .for the the generated xsd file  need to be modified and these attributes need to be added into the xsd as shown below

            nxsd:hasHeader="true"
            nxsd:headerLines="1"
            nxsd:outboundHeader="Name,EmpID,DeptID ${eol}"
            nxsd:headerLinesTerminatedBy="${eol}"












Deploy it and test it....

Monday 28 November 2016

New Line Character in BPEL - SOA

New Line Character in BPEL - SOA :


My Requirement to create new line between two words.

Example :



Input    :  Krishna Moorthi
Output :  Krishna
              Moorthi

create BPEL variable varNewLine  and assign Values as "&#13;&#10;"

Now use "Krishna"+ $varNewLine  + "Moorthi".

:-) :-)

OBPM 11g Email Configuration

OBPM 11g Email Configuration 

Step 1 :

http://localhost:7001/em
User Messaging Service -- >usermessagingdriver-email -- >Email Driver properties




Step 2 :


OutgoingMailServer - The SMTP hostname
OutgoingMailServerPort - The SMTP port
OutgoingMailServerSecurity - The type of security (e.g. SSL)
OutgoingUsername - The mail user account
OutgoingPassword - The mail user password



















Example :

OutgoingMailServer - smtp.gmail.com
OutgoingMailServerPort - 465
OutgoingMailServerSecurity - SSl



Step 3:



SOA -->SOA-Infra- > SOA Administration --> workflow Notification


















choose Email and clip apply







Download Openssl client from following site

www.openssl.org


openssl s_client -connect host:port
where Gmail SMTP host:port is smtp.gmail.com:465
where Gmail IMAP host:port is imap.gmail.com:993


















Save the file for both smtp and imap .













keytool available in java/bin >


keytool -import -alias AliasName -keystore KeystoreLocation -file CertificateLocation
For example:
keytool -import -alias gmail-imap -keystore gmail-keystore.jks -file imap.txt
keytool -import -alias gmail-smtp -keystore gmail-keystore.jks -file smtp.txt




















paste the below code in setDomainEnv.bat


set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\SOA11g6\user_projects\domains\base_domain\servers\lib\gmail-keystore.jks -Djavax.net.ssl.trustStorePassword=Admin123