Thursday, September 24, 2020

Properties

  How to set custom  Header (hardcode in invoke activity) ?

Add into properties of invoke. (In source of BPEL)

<bpelx:toProperty name="rest.binding.http.state-cd">'99'</bpelx:toProperty>
</bpelx:toProperties>
 </invoke>

Note: In Composite.xml its optional to add

<property name="oracle.webservices.http.headers">auth-token,clientid,username,state-cd,client-secret,password  </property>
</binding.rest>
  </reference>
How to set custom Headers (defined in composite)?
Step-1: Add following property inside reference of composite.xml
    <property name="bpel.preference.auth-token">f0dba955227145a8b09a8</property>
     <property name="bpel.preference.state-cd">99</property>
    <property name="bpel.preference.username">user1</property>

Step-2: add assign activity for header
-> Add functions on each element of header
-> BPEL Xpath Extension Functions – getPreference
-> Ex: ora:getPreference("auth-token")
-> ora:getPreference("clientid")
-> ora:getPreference("username")

Step-3: add in properties of invoke
<bpelx:toProperties>
                <bpelx:toProperty name="rest.binding.http.auth-token">$TST_Header/ns4:auth-token</bpelx:toProperty>
        <bpelx:toProperty name="rest.binding.http.state-cd">$TST_Header/ns4:state-cd</bpelx:toProperty>
        <bpelx:toProperty name="rest.binding.http.username">$TST_Header/ns4:username</bpelx:toProperty>
      </bpelx:toProperties>
    </invoke>

How to decrypt json data?
Create 2 simple variable:
encmsg string type
decmsg string type

Use Java Embedding activity in bpel process.
Name: Java_Parse

Write following code:

String encryptMsg= (String)getVariableData("encMsg");   

            byte[] decode_data_array = org.apache.commons.codec.binary.Base64.decodeBase64(encryptMsg.getBytes());   
   
            String decryptMessage = new String(decode_data_array);   
            setVariableData("decMsg",decryptMessage);

Add into bpel process:
<bpelx:exec import="org.apache.commons.codec.binary.Base64"/>

How to add JAR?
As we r using java logic, to use this we need to import jar and if we want to use in other project we have to import as jar.
Download commons-codec-1.5.jar

http://www.java2s.com/Code/Jar/c/Downloadcommonscodec15jar.htm --- jar - unzip
step-1
   Placed in ur project
Unzip
Rite click on projrct -> projectProperties -> Libraries and classpath -> Add JAR

Step-2
Placed in lib folder
C:\JDeveloper\mywork\CustomJavaSOAProject\SOA\SCA-INF\lib

How to create jar file of java class?
 Create java class
  Deploy

Create configuration file based on jar
How to create configuration file for java project?

config file  contain:
<soa-xpath-functions xmlns="http://xmlns.oracle.com/soa/config/xpath"
                     xmlns:ir="http://www.oracle.com/XSL/Transform/java/com.abc.test.security.in.TestMessageDecrypt">
    <function name="ir:messageDecrypt">
        <className>com.abc.test.security.in.TestMessageDecrypt</className>
        <return type="string"/>
        <params>
        <param name="encryptStr" type="string"/>
        </params>
        <desc>To Decript the message</desc>
        <detail>To Decript the message</detail>
    </function>
</soa-xpath-functions>

Note: configuration file should be inside meta-inf folder

Deploy-> jar -> riteclick ->7-zip -> Open achieve

If meta-inf folder is not there, then

Archieve -> extract

created 2 java class
created jar for that
and created  config file for that

ext-soa-xpath-functions-config.xml

it should be inside meta-inf folder

projectproperty- deploymemt-useProjectSettings-TestMessageParserJAR

meta-inf from jar -> extract -> it will create folder by default then copy config file into that.

tool->prefrence-> soa-> deployed jar

No comments:

Post a Comment

SOA Overview Part-1

  Middleware It provides a mechanism for the process to interact with other processes running on multiple network machines. Advantages...