Thursday, November 29, 2012

Remote archiving with FTP Adapter (JCA)

The file archiving location can be local or remote. To enable the remote archiving in the FTP adapter add the property  UseRemoteArchive with value as true to the jca file.

Apart from the above change ensure the LogicalArchiveDirectory/PhysicalArchiveDirectory is existing on the FTP server and the folders have write permission enabled



<adapter-config name="ReadOperation" adapter="Ftp Adapter" wsdlLocation="ReadOperation.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
 
  <connection-factory location="eis/ftp/TestFTP" UIincludeWildcard="Process*.txt" adapterRef=""/>
  <endpoint-activation portType="Get_ptt" operation="Get">
    <activation-spec className="oracle.tip.adapter.ftp.inbound.FTPActivationSpec">
      <property name="FileType" value="ascii"/>
      <property name="UseHeaders" value="false"/>
      <property name="AsAttachment" value="true"/>
      <property name="LogicalDirectory" value="inbound"/>
      <property name="UseRemoteArchive" value="true"/>
      <property name="Recursive" value="true"/>
      <property name="LogicalArchiveDirectory" value="archive"/>
      <property name="DeleteFile" value="true"/>
      <property name="IncludeFiles" value="Process.*\.txt"/>
      <property name="PollingFrequency" value="30"/>
      <property name="MinimumAge" value="0"/>
         </activation-spec>
  </endpoint-activation>

</adapter-config>

Cannot call Connection.rollback in distributed transaction. Transaction Manager will commit the resource manager when the distributed transaction is committed

If we take care the configuration details for the data source and connection pool, often transaction roll back exceptions can be avoided

For e.g the below error happened due to the incorrect configuration of d atasource

Internal Exception: java.sql.SQLException: Cannot call Connection.rollback in distributed transaction.  Transaction Manager will commit the resource manager when the distributed transaction is committed

In such situations verify the connection pool and check the type of datasource whether it is XA or non-XA.

If a non-XA data source is used in the connection pool, ensure you unchecked the 'Supports Global Transactions' option in the data source configuration





Wednesday, November 28, 2012

ORA-28001: the password has expired

There is an expiry date for the passwords we set for user account in oracle. Once the password expired the SOA infra will fail to load.

We can check the account status using

select USERNAME,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where USERNAME  like '%DEV%'

If any of the user account_status is expired, using the following query we can see the values for PASSWORD_LIFE_TIME and PASSWORD_GRACE_TIME

SELECT * FROM dba_profiles WHERE profile = 'DEFAULT' AND resource_type = 'PASSWORD'




Set these values to unlimited using the query


ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

ALTER PROFILE DEFAULT LIMIT PASSWORD_GRACE_TIME  UNLIMITED;



After this for every user name set the new password as follows

 alter user <username> identified by <password>;
 for eg.
 alter user DEV1_ESS identified by manager;

Now execute the query once again to see the account status
select USERNAME,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where USERNAME  like '%DEV%'




Friday, November 16, 2012

Testing a secured proxy service from OSB test console

In the previous blogs I had mentioned how to secure a proxy service using the username token policy. In this article I am going to explain how to test a secured service from the osb test console.

Step1:  In the OSB console using the security configuration create a new user account as follows.
                                                    username - test_user
                                                    password - welcome1


Step2 : Now a key store has to be configured in the em console. Prior to that create a key store (testks.jks) as follows


 Step 3: In the emconsole goto the domain and on the right click menu goto Security->Security Provider Configuration



 
  Step 4: Configure the above created key store as follows

 provide the password as welcome1 for every highlighted item

Save and restart the server. The restart is mandatory to effect the changes done.

Step5 : Create a credential key. In the em console goto the domain->rightclick->Security->Credentials
Step6 : Create a Security Map called oracle.wsm.security , if it not existing

Under this map create a new security key as follows


Now we are ready to test the OSB service from the test console. Open the test console
In the override attribute section provide the security key as test_user and then click the execute button.

Now we can see a SOAP Header is attached to the request and the service executed successfully.




Monday, November 12, 2012

List all the deployed composites

It will be handy if we have a script to list all the deployed composites belong to a partition. Here is a sample

Step1:

Create a property file as follows

=============Env.properties====================


url=t3://localhost:7001
server=localhost
port=8001
username=weblogic
password=weblogic1
PARTITIONS=default,masterdata,marketing


============end of Env.properties==================

Step 2 :

Create the following python script

=================ListDeployedComposites.py=========

from java.io import FileInputStream

try:
propInputStream = FileInputStream("D:\\tech\\wlst\\Env.properties")
configProps = Properties()
configProps.load(propInputStream)
except NameError, e:
print 'EXCEPTION OCCURED'
print 'Please check there is: ', sys.exc_info()[0], sys.exc_info()[1]
else:
print 'properties loaded properly'
print 'configProps',configProps
url = configProps.get("url")
print 'url=', url
server = configProps.get("server")
print 'server=', server
port = configProps.get("port")
print 'port=', port
username = configProps.get("username")
print 'username=', username
password = configProps.get("password")
print 'password = ', password

partitions = configProps.get("PARTITIONS")
print 'partitions = ', partitions


print '========================'
partitionList = partitions.split(",")
count = 0
for i in partitionList:
try:
sca_listCompositesInPartition(server,port,username,password,partitionList[count])
except NameError, e:
print 'EXCEPTION OCCURED'
print "Please check there is: ", sys.exc_info()[0], sys.exc_info()[1]
count = count+1

============= end of ListDeployedComposites.py==========

Step 3:
Start the wlst command as follows
D:\Oracle\Middleware\Oracle_SOA1\common\bin>wlst.cmd
Run the script from wlst prompt as follows
wls:/offline> execfile('D:\\tech\wlst\\ListDeployedComposites.py')

Result:

Following 21 composites are currently deployed to the platform, in partition: default.

1. AIAB2BInterface[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-06-08T09:03:08.211Z
2. ProductionRecipeResponseEBS[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:59:04.233Z
3. SyncProductionRecipeListEbizProvABCSImpl[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T
4. SyncSpecPLM4PAdapter[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:54:10.927Z
5. SyncRecipeListEbizAdapter[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:59:49.244Z
6. SyncItemListEbizProvABCSImpl[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T10:03:57.380
7. ItemResponseEBSV2[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:57:59.963Z
8. TransformAppContextEbizService[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T10:00:21.9
9. SyncItemListEbizAdapter[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:59:28.608Z
10. ProductionRecipeEBS[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:58:45.184Z
11. AgToAGPollingTest[1.0], partition=default, mode=active, state=off, isDefault=true, deployedTime=2012-08-09T11:48:04.849Z
12. SimpleApproval[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-05-21T15:51:27.432+05:30
13. AIAErrorTaskAdministrationProcess[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-06-08T08:53:
14. AIAB2BErrorHandlerInterface[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-06-08T09:04:31.440
15. SampleCursorRef[1.0], partition=default, mode=retired, state=on, isDefault=true, deployedTime=2012-11-02T16:00:17.268+05:30
16. AIAReadJMSNotificationProcess[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-06-08T09:00:29.4
17. FirstBPEL[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-11-09T21:26:47.672+05:30
18. ReloadProcess[1.0], partition=default, mode=retired, state=on, isDefault=true, deployedTime=2012-06-08T09:02:14.366Z
19. AIAAsyncErrorHandlingBPELProcess[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-06-08T09:01:2
20. QueryResponsibilityEbizAdapter[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T09:52:36.
21. SyncSpecPLM4PReqABCSImpl[1.0], partition=default, mode=active, state=on, isDefault=true, deployedTime=2012-10-10T10:02:53.116Z





start/stop/activate/retire composites using wlst

Here is a script for doing the state change for a deployed composite. This is a generic python script which will cater the requirement for start/stop/retire/activate any number of composites at a time

Step1 :
Create a property file, specify the server connection details, the list of composites and the action required on them

========= composite.properties ==================

url=t3://localhost:7001
host=localhost
port=8001
username=weblogic
password=weblogic1

COMPOSITES=default/SampleCursorRef/1.0,default/ReloadProcess/1.0
operation=retire

========== end of composite.properties =============

Step 2 :
Create the following python script

=================StateChange.py===============
from java.io import FileInputStream
propInputStream = FileInputStream("D:\\tech\\wlst\\composite.properties")
configProps = Properties()
configProps.load(propInputStream)
url = configProps.get("url")
print 'url=', url
host = configProps.get("host")
print 'host=', host
port = configProps.get("port")
print 'port=', port
username = configProps.get("username")
print 'username=', username
password = configProps.get("password")
print 'password = ', password
operation = configProps.get("operation")
print 'operation = ', operation

print '========================'
print 'host=', host
COMPOSITES = configProps.get("COMPOSITES")
print 'COMPOSITES = ', COMPOSITES
print 'host=', host
compositeList=COMPOSITES.split(',')
print compositeList[1]
count = 0
for i in compositeList:
   compositeProps = compositeList[count].split("/")
   partition = compositeProps[0]
   compoisteName = compositeProps[1]
   version = compositeProps[2]
   print 'partition ..',partition
   print 'newPartition..',newPartition
   print 'compoisteName ..',compoisteName
   print 'version ..',version
   print '========================'
   
   print 'trying to  ',operation ,'the', compoisteName
   try:
if operation=='start':
sca_startComposite(host, port, username, password, compoisteName, version)
elif operation=='stop':
sca_stopComposite(host, port, username, password, compoisteName, version)
elif operation=='activate':
sca_activateComposite(host, port, username, password, compoisteName, version)
elif operation=='retire':
sca_retireComposite(host, port, username, password, compoisteName, version)
else:
   print '=======DO NOTHING ========='
   except NameError, e:
print 'EXCEPTION OCCURED'
print "Please check there is: ", sys.exc_info()[0], sys.exc_info()[1]
   else:
print 'Completed the action on ',compoisteName
   count = count+1
=================end of StateChange.py============

Step3: Open a command promt and start the wslt command from D:\Oracle\Middleware\Oracle_SOA1\common\bin as follows  

D:\Oracle\Middleware\Oracle_SOA1\common\bin>wlst.cmd

This will start the wslt engine . Now execute the python script from the wlst prompt as follows
wls:/offline> execfile('D:\\tech\wlst\\StateChange.py')

To do start/stop/activate change the value for operation in the composite.properties file

Sample result
===================== 
trying to   retire the ReloadProcess
host = localhost
port = 8001
user = weblogic
partition = default
compositeName = ReloadProcess
revision = 1.0
label =  None
compositeDN =default/ReloadProcess!1.0
Connecting to: service:jmx:t3://localhost:8001/jndi/weblo
Composite (default/ReloadProcess!1.0) is successfully ret
Completed the action on  ReloadProcess
=======================================


Friday, November 9, 2012

Securing OSB proxy service

Security is an important aspect in the webservice domain. Let us see how to secure an OSB proxy service using OWSM

Create a OWSM enabled osb domain


Create a proxy service. Add the security policy as shown below

Enable the Header Processing as below

Save and Activate the changes in the osb console.

Now test the service from Test Console without passing the SOAP Header

It will throw an error as shown below

The service cannot be invoked without passing user credentials as part of SOAP Header.


Now lets see how to invoke this secured service from BPEL 

Create a partner link for the above OSB service in the BPEL.

In the composite.xml design view select the partnerlink

Right click on the partner link and select the Configure WS Policies option

Choose the wss_username_token_client_policy for the Security field

In the property inspector window, go to binding property section and click on the add button.


Add two new properties for username and password with appropriate values for the properties

Now the composite.xml will appear like as shown below. 



Deploy and test the BPEL. Now this BPEL will successfully invoke the secured OSB proxy service