Monday, October 20, 2014

Working with Domain Value Maps (DVM) in SOA 11g

Hi, I want to Discuss About  Domain Value Maps(DVM) in Oracle SOA Suite 11g in this post

Domain Value Maps(DVM)  They enable you to map from one vocabulary used in a given domain to another vocabulary used in a different domain. For example, one domain may represent a city with a long name (Mumbai), while another domain may represent a city with a short name (MB). In such cases, you can directly map the values by using domain value maps. 
(or)
In Oracle SOA 11g When ever we integrate the two applications with different names and it gives same information. A general example one application contains a city name as Hyderabad and another application contains the same city name as Hyd, the both the applications are different domains. These type of situations we can use a domain value map between the two domains.

Domain value map values are static. You specify the domain value map values at design time using Oracle JDeveloper, and then at runtime, the domain value map columns are looked up for values.

Domain Value Map Features

Qualifier Support

Qualifiers qualify mappings. A mapping may not be valid unless qualified with additional information. For example, a domain value map containing a city code-to-city name mapping may have multiple mappings from KN to Kensington because Kensington is a city in both Canada and the USA. Therefore, this mapping requires a qualifier (USA or Canada) to qualify when the mapping becomes valid

Qualifier Support Example
Country (Qualifier)CityCodeCityName
USABOBoston
USABELG_NCBelgrade
USABELG_MN_StreamsBelgrade
USANPNorthport
USAKNKensington
CanadaKNKensington

Note: You can also specify multiple qualifiers for a domain value map
            Qualifier Order Support:- A qualifier order is used to find the best match during lookup at run time. Domain value maps support hierarchical lookup. If you specify a qualifier value during a lookup and no exact match is found, then the lookup mechanism tries to find a more generalized match by setting the higher order qualifiers to "". It proceeds until a match is found, or until a match is not found with all qualifiers set to "".
              One-to-Many Mapping Support:- You can map one value to a multiple values in a domain value map. For example, a domain value map for Payment Terms can contain mapping of payment terms to three values such as discount percentage, discount period, and total payment period.
Scenario:   
     In My example we use File Read and write Using DVM Logic 

After Completion of this scenario composite will look like this,


In the above Example Mediater Mediating All Incoming files to File Write Location based on below XSD,

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.example.org"
            targetNamespace="http://www.example.org"
            elementFormDefault="qualified">
  <xsd:element name="ListofOrder">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Order" >
    <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="OrderID" type="xsd:string" />
    <xsd:element name="basedata">
    <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="CityCode" type="xsd:string" />
      <xsd:element name="CityName" type="xsd:string" />
       <xsd:element name="State" type="xsd:string" />
        <xsd:element name="Country" type="xsd:string" />
    
    </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="PricingData" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="Freightamount" type="xsd:string" />
      <xsd:element name="PricingData" type="xsd:string" />
       <xsd:element name="Taxamount" type="xsd:string" />
    
    </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Step 1:  
Create .DVM FILE using  Right click on project -> Select SOA-> Transformation-> Domain Value Map . Give some name to domain value map file and give some name to the domain fields then click OK.

Step 2: Define File Name and Description for the DVM file you created.  Enter the Domain Name and Domain Value .Enter the Domain value to the particular domain name and click on OK



Step 3: Now we will get Domain value Map Editor

How to add columns to DVM
Click on Add Column 
Step 4: While you creating a Domain prompts you below window

The Create Domain Popup window  is displayed  
Enter the Name in the Name field
Select the True if you want to column as a Qualifier
Select Qualifier Order field enter a qualifier number (If you want enabled this field then select as true in Qualifier field)
Click on OK (As discussed in 
Domain Value Map Features)

Repeat same steps to create a Domain Country with Qualifier set to True
Step 5: Adding rows to DVM. Click on Add Domain Values


 Create Domain Value Map as below

Now DVM is used for Domain Value Mapping
1. Create the Project with Empty Composite 
2. Add File Adapter in Exposed Services (i.e used for Read file)
3. Add File Adapter in External Services (i.e used for Writing file)
4. The Two Adapter connect with the Mediator
Step-1:
Drag file Adapter to Exposed Services and do following steps










 Step-2:
Drag file Adapter to External References and do following steps








Step-3:Add the Mediator to the composite.xml and do wiring 


Double Click on Mediator

Click on transform using Icon
 



If you select the Advanced tab then you will get DVM Functions 
Now add lookupValue in the middle which element do you want lookup


When you double click on the DVM function Popup window will appear 


When you double click on the DVM function Popup window will appear 
Here Main step will raise 
Add dvmlocation, if you click on magnifying glass icon then you will add The domain value map URI.
Add sourceColumnName 
Add targetColumnName
Add defaultValue
Add qualifierColumnName 
Add qualifierValue



Specify values for the following fields in the Edit Function – lookupValue1M dialog:
  • In the dvmLocation field, enter the location URI of the domain value map file or clickBrowse to the right of the dvmLocation field to select a domain value map file. You can select an already deployed domain value map from the metadata service (MDS) and also from the shared location in MDS. This can be done by selecting the Resource Palette.
  • In the sourceColumnName field, enter the name of the domain value map column that is associated with the source element value, or click Browse to select a column name from the columns defined for the domain value map you previously selected.
  • In the sourceValue field, enter a value or press Ctrl-Space to use the XPath Building Assistant. Press the up and down arrow keys to locate an object in the list, and press Enterto select an item.
  • In the targetColumnName field, enter the name of the domain value map column that is associated with the target element value, or click Browse to select the name from the columns defined for the domain value map you previously selected.
  • In the QualifierCloumnName field,enter a value of the domain value map column that is associated with the qualifier  element value , or click Browse to select a column name from the columns defined for the domain value map you previously defied to be qualifier.
  •  In the QualifierValue nter a value or press Ctrl-Space to use the XPath Building Assistant. Press the up and down arrow keys to locate an object in the list, and press Enter to select an item.
Finally Transformation look like below.

Deploy the files in Server

Add xml to particular directory
If the value is correct the output XML file will be like this

If the value is not valid the output XML file will be like this







Configuring Database Adapter in Oracle SOA Suite 11g

This blog gives you a detailed approach to configure a DataSource, JNDI, DBAdapter, and its underlying technologies, facts and common issues.

Every single component used in a SOA Application has to be a service, and this applies to the database also. A database by itself cannot act as a service that can be exposed to the service.  Inorder to use the database in a SOA application, you need to expose it as a service in some way.

Oracle SOA Suite provides you this capability by using a JCA-build wrapper called the DBAdapter.

Using this adapter in your application is quite straight forward, provided it is configured correctly.
Many times, developers come across errors like

Please make sure that the JCA connection factory and any dependent connection factories have been configured with a sufficient limit for max connections. Please also make sure that the physical connection to the backend EIS is available and the backend itself is accepting connections.
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.

at oracle.integration.platform.blocks.adapter.fw.jca.cci.EndpointInteractionException.getFabricInvocationException(EndpointInteractionException.java:75)
...

 While working with the DBAdapters. This is due to incorrect setup of the adapter.
Datasource setup is a onetime step, and it is always good to know the underlying steps and technologies involved.

Before we go to the steps in configuring a DBAdapter, let’s have a look at the various concepts involved in this.

DataSource
 A datasource, as its name implies, is anything that acts as a source for data. Database is a source of data, and it has to be configured as a datasource to the SOA infrastrucure.
Datasource in specific to the Weblogic Server is the connection to the actual underlying data provider.

Connection Pool
WebLogic communicates with the database through a connection pool. The connection pool enables WebLogic to use a fixed number of connections to databases rather than incur the   overhead of constantly creating and disposing of connections.

A data source has a connection pool attached to it, which it uses for connecting to the actual data provider(Database in this case). While creating a datasource, you give a JNDI name, which is  used by the JNDI infrastructure to call the datasource.

JNDI
JNDI, the Java Naming and Directory Interface is a standard interface for the Java based application clients to access the underlying naming and directory services.
This forms a wrapper over the underlying naming and directory services like DNS, LDAP, etc. and lets the client access different services in a standard way.



JNDI is independent of any specific naming or directory service implementations, and allows any service provider implementations to be plugged into the JNDI framework using the standard  Service Provider Interface(SPI).

There are basically 3 steps inorder to setup and configure a DBAdapter in a SOA Application.
1.Configure a datasource for the underlying database, associate a JNDI name to it.
2.Configure an outbound connection pool, and link it with the datasource using the same JNDI name.
3.Use this JNDI name while configuring the DB Adapter.

Step 1 : Configure a Datasource for the underlying Database, associate a JNDI name to it
This step is done using the Weblogic Admin Console. Please make sure your database is up and running before this step.

Soa_domain --> Services --> Data Sources --> New --> Generic Data Source -->







Standard naming  convention for database sources would have a JNDI name prefixed with "jdbc/". You will use this name later to associate a connection pool to this datasource.
Select the appropriate driver


Give the underlying Database details, test the connection in the next screen(not shown here)


  
Select the server that is running the SOA infrastructure. This makes this datasource to run on that particular server, making this available to all the apps running on that server



Click on finish. After this, you should see this newly configured datasource in the Data Sources summary screen.

Now that the datasource is setup, and a JNDI name associated to it,
you need to create a connection pool for this datasource, in other words connections to this database.

Step 2 : Configure an outbound connection pool, link it to the datasource using the JNDI name
In Weblogic Admin Console,
soa_domain --> Deployments --> dbAdapter --> Configuration --> Outbound Connection Pools --> New





  
In the above screen, you are giving a new JNDI name, and this will be used in the SOA Suite's DBAdapter configuration wizard to obtain reference to this connection pool.
Now, you can see the newly configured JNDI name in the list of Outbound Connection Pools.
This new connection pool has to be linked to the datasource that you've created before.


There might be a bit confusion in the JNDI names. Here is how it is.
Both the datasource and Connection Pool has their specific JNDI Names

Datasource myDataSource has a JNDI Name
jdbc/myDataSource
Connection Pool has a JNDI Name
myConnPoolForDB, and this connection pool will use the name jdbc/myDataSource as its xaDataSourceName, and hence the linking to the datasource is done

After this setup, you need to redeploy the dbAdapter
Select the DBAdapter in deployments, Update-->Redeploy

Step 3 : Use this JNDI name while configuring the DB Adapter

While setting up the DBAdapter in the SOA Suite, in the configuration wizard, use the same JNDI Name



I Hope it is clear now what all goes into a dbAdapter setup.


Saturday, October 18, 2014

Working with Oracle MDS Repository (MetaData Services)


With the release of FMW 11g, the Oracle MDS Repository is now the central place for storing configuration files, personalization elements, page customizations, pages etc. for WebCenter, IDM and SOA Suite. Understanding and working with this repository is essential for custom application developers and implementers.

Oracle provides some basic tools for managing the repository, such as import/export and a JDeveloper browser plugin. Unfortunately, there is no tool currently for managing the files within the repository, so there really is no possibility to change the files at run-time without exporting and then reimporting the repository.

I will explain in this blog post how you can connect to a MDS repository and how you can work with the files stored there.

The MDS is basically an XML store with transaction capabilities, versioning, merging and a persistence framework optimized to work with XML nodes and attributes. It is somehow similar to an ORM, but for XML entities. The persistence framework has two adapters that can persist the store to a database or to a folder on disk. The database store has more advanced features is the recommended way of working with MDS. The file store is useful for at development time, because one can change the files manually.

The same as an ORM needs a configuration file to know the environment (e.g. hibernate.cfg.xml), the MDS uses its own config file named adf-config.xml. You can find this file automatically generated by JDeveloper in any SOA FMW project, with a default configuration.

The file has several configuration sections, but one is of particular interest, and it's called
adf-mds-config:
<adf-mds-config>
  <mds-config>
    <type-config>
      <type-definitions>
        <classpath>/com/tutorial/model/schema/beanType.xsd</classpath>
        ......
      </type-definitions>
    </type-config>
  </mds-config>
  <persistence-config>
    <metadata-namespaces>
      <namespace metadata-store-usage="MetadataStore" path="/custom/" />
      ......
    </metadata-namespaces>
    <metadata-store-usages>
      <metadata-store-usage default-cust-store="true" deploy-target="true" id="MetadataStore">
         <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
           <property name="jdbc-userid" value="DEV_MDS"/>
           <property name="jdbc-password" value="dev"/>
           <property name="jdbc-url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
           <property name="partition-name" value="p1"/>
           <property name="repository-name" value="mds-SpacesDS"/>
         </metadata-store>
      </metadata-store-usage>
    </metadata-store-usages>
  </persistence-config>
</adf-mds-config>

In the above configuration, the most interesting elements are: type-definitions, namespace andmetadata-store:
·                      type-definitions: here you can define custom XSD nodes that describe custom entities. The easiest way to generate XSD definitions is with the help of JAXB: you can define you data model as serializable POJOs  (same as JPA entities) and then use Oracle's MDSBeanGenTool (located in the mdstools.jar file) java utility to generate the schema definition.
·                      namespace: here you must define the virtual paths within the MDS repository, so the persistence framework will know where to store and find the files
·                      metadata-store: this node configures the persistence adaper. It can be either DBMetadataStore, ClassPathMetadataStore, FileMetadataStore or ServletContextMetadataStore.
Once you have these in place, you are ready to connect to the metadata store:
MDSConfig config = new MDSConfig(new File(path to adf-config.xml));
MDSInstance mdsInstance = MDSInstance.getOrCreateInstance("test-instance", config);
MDSSession mdsSession = mdsInstance.createSession(new SessionOptions(null, null, new CustConfig(new CustClassListMapping[0])), null);
The mdsSession variable holds the session instance for the MDS repository. A MDSSession is similar to the Hibernate Session object. It will handle all persistence operations and holds a transactional context.
You can now query the repository to find the desired items. For example, to find all files in repository you would write:
NameQueryImpl query = new NameQueryImpl(mdsSession, ConditionFactory.createNameCondition("/", "%", true));
Iterator<QueryResult> result = query.execute();
while(result.hasNext()) {
    QueryResult qr = result.next();
    // ...do your magic here...
}
Using the above query, you would only retrieve the names of the items inside the repository. To get the actual instance of an MDS object ( MetadataObject ), you have to write:
MOReference ref = mdsSession.getMOReference(path inside the repository);
MetadataObject mo = mdsSession.getMetadataObject(ref);
Once you have the MetadataObject instance, you can retrieve the XML document behind withmo.getDocument(); Having the DOM XML Document instance, you can alter the XML file and save it hack to the repository by issuing mdsSession.flushChanges();

Using the information briefly described here and with a little bit of SWING knowledge, you can easily write an MDS browser and XML editor to change what you want inside the repository.

Friday, October 17, 2014

Interview Questions on SOA and OSB


1) BPEL/OSB – File Adapter – Polling in Cluster – Need to conf in order to read only one file at a time (create only one instance in SOA)
we need to singleton property!
Singleton Services : are services which must run only on one server at given time. In OSB cluster most of services run on all servers which are part of cluster however some services must run on only one server at a time . Singleton Services for OSB include
a) File, FTP and E-Mail Pollers for Proxy Services
b) SLA Manager
c) JMS Server
d) ALSB domain Singleton Marker Application
2) Schema – Difference between Include and Import in XSD
The fundamental difference between include and import is that you must use import to refer to declarations or definitions that are in a different target namespace and you must use include to refer to declarations or definitions that are (or will be) in the same target namespace.
3) BPEL – Correlation Set – can have different data types for each correlation elements?
Elements can be different names and in different structures in the two messages, but they must contain the same value if correlation is to work.
https://blogs.oracle.com/reynolds/entry/bpel_correlation
4) OSB- How to make the business service to propagate the error to proxy service
When the value of the qualityOfService element is best-effort for a publish action, all errors are ignored. However, when the value of the qualityOfService element is best-effort for a route node action or a Service callout action, any error will raise an exception.
Exactly once reliability means that messages are delivered from inbound to outbound exactly once, assuming a terminating error does not occur before the outbound message send is initiated. Exactly once means reliability is optimized.
Best effort means that there is no reliable messaging and there is no elimination of duplicate messages—however, performance is optimized.
  • Service callout action — always best-effort, but can be changed if required.
  • Publish action — defaults to best-effort, modifiable
  • Route node is best-effort for the following inbound transports:
    • HTTP
    • JMS/nonXA
    • Non-Transactional Tuxedo
  • Route node is exactly-once for the following inbound transports:e-mail
    • FTP
    • File
    • JMS/XA
    • SFTP
    • Transactional Tuxedo
5) WebLogic- Connection pooling means what. Why we need it?
WebLogic communicates with the database through a connection pool. The connection pool enables WebLogic to use a fixed number of connections to databases rather than incur the overhead of constantly creating and disposing of connections. Because of this, you must establish a data connection pool that accesses your database.
In Oracle words… A connection pool contains a group of JDBC connections that are created when the connection pool is registered, usually when starting up WebLogic Server. Your application borrows a connection from the connection pool, uses it, then returns it to the connection pool by closing it.
6) WebService – Difference btw SOAP and Rest?
7) OSB/BPEL – How to make HTTP call? Not SOAP over HTTP
8) General / BPEL – Diff btw Synch and Asynch invocation?
9) BPEL – Non-blocking Invoke means what?
Flow in BPEL (or at least Oracle BPEL PM) allows for parallel branches of activities. When executed, the branches in the Flow get their turn to execute the next step. Steps are not truly executed at the same time – which may be a blessing in disguise in situations where activities in various branches access the same variables. Even synchronous calls with nonBlockingInvoke set to true block other activities from being processed.
10) Transaction handling in OSB

Thursday, September 11, 2014

OSB 11g BEA-380000 , Not Implemented Error

When trying to invoke external Business Service from OSB Business Service Test Console getting following Error.

<con:fault xmlns:con="http://www.bea.com/wli/sb/context"> 
<con:errorCode>BEA-380000</con:errorCode> 
<con:reason>Not Implemented</con:reason> 
<con:location> 
<con:node>RouteNode1</con:node> 
<con:path>response-pipeline</con:path> 
</con:location> 
</con:fault> 

 Root Cause: In Business Service Advanced Configuration "Use Chunked Streaming Mode" was enabled.

 Resolution: Disable "Use Chunked Streaming Mode" as show below.