Thursday, January 26, 2012

Storing and retrieving shared resources like xsd, wsdl, dvm etc in SOA MDS

Its a common idea to share reusable artifacts across composites in Oracle SOA Suite 11g. SOA MDS provides us with the option and has its own advantages.

1. For deploying any shared resource in SOA MDS, we need to create a generic project in Oracle JDeveloper and create necessary folders under it and store the dvm file.
In our example, DTEMS is the project created and the hierarchy of folders is
TestingDvm -> dvm ->idName.dvm (this folder structure will not be visible in JDeveloper, but only in the project workspace).

2. Now, in JDeveloper right click the project (here DTEMS), go to Project Properties -> Deployment.
Click New, select Archive Type as JAR File, name the jar and click OK.
Now in JAR Options, uncheck “Include Manifest File




From Project Output -> Contributors deselect all.
Go to Filters and check the folder under which the dvm files are located (TestingDvm here) and click OK
Now, the archive is created named “DvmArchive


3. Now, we need to create a SOA Bundle for packaging the created JAR and deploy it in server.
For that, go to Application Properties of the application under which the project is created and then go to Deployments.

Select Archive Type as SOA Bundle, name the bundle and click OK
In the next screen, go to Dependencies, check the archive (containing the jar) created before (DvmArchive) and click OK
Now, the SOA Bundle named “dvmSOABundle” is created.

4. Now we need to Deploy this SOA bundle to the server.


5. Now, to see the deployed shared resources , we need to create a SOA-MDS connection (DB based connection)


6. Now you can see the resources in the desired folder structure under the /apps directory as below


7. And we are done; the resource can be accessed in the project as ---
              "oramds:/apps/TestingDvm/dvm/idName.dvm"


Sunday, January 08, 2012

Export/Import OSB Projects using WLST with Apache Ant - OSB 11g

In this post, we are going to export and import (deploy) OSB projects. Oracle has provided some standardized Python (infact Jython - the java version of Python) scripts which will be processed by  WebLogic Scripting Tool (WLST). So, lets go straight into "how-to" of doing things.

We are going wrap the WLST scripts from ANT tasks using weblogic server provided <wlst> tag for Ant. And our WLST is going to process the import (import.py) and export (export.py) scripts.

1. Set JAVA_HOME
JAVA_HOME= <location of java home>
export JAVA_HOME
echo $JAVA_HOME

2. Set CLASSPATH. CLASSPATH variable should contain weblogic.jar, alsb.jar and com.bea.common.configfwk_1.3.0.0.jar .
FMW_HOME=/u01/app/oracle/product/fmw
CLASSPATH=$FMW_HOME/wlserver_10.3/server/lib/weblogic.jar:$FMW_HOME/Oracle_OSB1/lib/alsb.jar:$FMW_HOME/Oracle_OSB1/modules/com.bea.common.configfwk_1.3.0.0.jar
export CLASSPATH
echo $CLASSPATH

[Note: mutiple paths are seperated by colon(:) in Unix]

3. Now, place the 4 files (build.xml, build.properties, export.py and import.py) in a specific location in the server, say /tmp/OSBScripts.

Few considerations for build.properties
     a. fmw.home=/u01/app/oracle/product/fmw
                           here, mention the path of FMW home

     b. wls.username= weblogic
         wls.password=abc123
                         here, specify the username and password used to connect to server

     c. wls.server  = t3://lpdwa1109.trcw.us.aexp.com:7002
                         here,
                               - t3 protocol is used
                               - port should be the admin server port

     d. export.project=DummyTest
                        here, mention the name of the project that needs to be exported.

     e. export.jar=/tmp/debadri/sbconfig_DummyTest.jar
                        here, specific the jar file name and the location where the project will be exported.

     f. export.customFile=/tmp/debadri/bamdatecheck.xml
                       here, mention the location and name of customization file, if any

     g. import.jar= /tmp/debadri/sbconfig_DummyTest.jar
                       here, mention the name and location of the JAR file which needs to be imported.

     h. import.customFile = None
                      here, name and location of customization file to be applied to the imported jar if any.

Few considerations for build.xml
      a.  <property name="domain.export.script" value=" /tmp/OSBScripts/export.py"/>
      b.  <property name="domain.import.script" value=" /tmp/OSBScripts/import.py" />
                        Always better to specify the full path of export.py and import.py.
      c. We are going to specify the script to execute in the "fileName" property of <wlst>

Here's the oracle doc link to get an insight into using other attributes of <wlst> in running WLST from Ant for WLS 10.3.5

4. Run ant targets from the location where build.xml is placed.

>/tmp/OSBScripts $ <FMW_HOME>/modules/org.apache.ant_1.7.1/bin/ant exportFromOSB
OR
>/tmp/OSBScripts $  <FMW_HOME>/modules/org.apache.ant_1.7.1/bin/ant importToOSB


Here, exportFromOSB - Ant target that exports OSB project from server
          importToOSB -   Ant target that deploys OSB project from local system to the server


[Note: The wlst task is predefined in the version of Ant shipped with WebLogic Server. If you want to use the task with your own Ant installation, add the following task definition in your build file: 
<taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask"/>]

All the files (build files and Jython scripts) referred in this link can be found here

______________
thanks, D


Sunday, January 01, 2012

Working with SOAP Attachment using Java Callout in OSB 11g


Our use case is to receive an attachment (zip/pdf/doc) which comes as a part of SOAP request and place it in a particular directory.

First, we are going to have a java class which writes the attachment content into a file. As our main purpose is to show how to handle attachment, we are keeping the java code simple. 

WRITING A POJO

1. We will write a java class (BinaryCtxWriter.java), which has a static method accepting a string and a byte array as input params. The method’s purpose is to write the contents of the attached file into a particular directory.

2. Export the class as a JAR (BinaryCtxWriter.jar).

OSB STANDPOINT

1. Create an OSB project and copy BinaryCtxWriter.jar in here.

2. First we need to create a WSDL(PSInterface.wsdl) for the proxy service which will accept an attachment. 
Here, it should be noticed that the request message has 2 parts. One for the message body and the other for attachment.  To handle multiple parts in a message structure, we will be using RPC style SOAP binding. The operation input has a MIME binding.

3. Create a proxy service based on this WSDL. The OSB message flow looks like this



4. For every attachment, OSB keeps the attachment in memory and gives us a reference handler to that location. The context variable "attachments" get populated once any attachment is received. Under "attachments", each "attachment" element contains an individual attachment.
This reference can be accessed as 

                           $attachments/ctx:attachment/ctx:body/ctx:binary-content

In the assign action, we assign the expression $attachments/ctx:attachment/ctx:body/ctx:binary-content 
to a variable. (say “attachmentData”) .


5. Now, we make a Java Callout to the static method that we exposed in the BinaryCtxWriter.jar. 
Assign, the expression $body/soap:submitAttachment/submitAttachment/fileName/text() to the java string argument.
Assign the variable $attachmentData to the byte[] argument.

6. In the response pipeline, we are having the proxy to reply with ‘OK’.
   This is done by replacing the body variable with

<ns0:submitAttachmentResponse xmlns:ns0="http://www.debadri.com/SOAPAttachment/"> 
<submitAttachmentResponse> 
<response>OK</response> 
</submitAttachmentResponse>
</ns0:submitAttachmentResponse>

7. Next, we explicitly delete the "attachments" variable. This is done so as to prevent the client of the proxy service from receiving the attachment again as a part of SOAP message.
In the delete action, in the Variable section mention "attachments"


8. Deploy the OSB application (sbconfig_HandlingSOAPAttachment.jar)

Note: To test this we can use soapUI, Java client or any other WS client. Strangely, testing with OSB test console somehow doesn't function.



All the source code files referred in this post can be downloaded from here


________________
thanks, D