Tuesday, January 26, 2016

oracle.mds.exception.MDSException: MDS-01373: unable to retrieve password.



While trying to compile one of my bpel project, i got below error message.



[scac] MDS-01370: MetadataStore configuration for metadata-store-usage "mstore-usage_2" is invalid.
[scac] MDS-00011: unable to create configuration object or MDSInstance due to invalid configuration information: oracle.mds.exception.MDSException: MDS-01373: unable to retrieve password.
[scac] : oracle.mds.config.MDSConfigurationException: MDS-01330: unable to load MDS configuration document
[scac] MDS-01329: unable to load element "persistence-config"
[scac] MDS-01370: MetadataStore configuration for metadata-store-usage "mstore-usage_2" is invalid.
[scac] MDS-00011: unable to create configuration object or MDSInstance due to invalid configuration information: oracle.mds.exception.MDSException: MDS-01373: unable to retrieve password.
[scac] : MDS-01330: unable to load MDS configuration document
[scac] MDS-01329: unable to load element "persistence-config"
[scac] MDS-01370: MetadataStore configuration for metadata-store-usage "mstore-usage_2" is invalid.
[scac] MDS-00011: unable to create configuration object or MDSInstance due to invalid configuration information: oracle.mds.exception.MDSException: MDS-01373: unable to retrieve password.


In order to resolve this issue.

Go to your adf-config.xml file, you can locate it in Jdeveloper



Open the file and add the property name

jdbc-password



Save the changes are rebuilt your code.


Tuesday, January 19, 2016

Create schema for a CSV file with different set of records in multiple lines


We face this issue in most of the integration project.

We get Order information in CSV file which can have header,details , shipping etc information in different line in different format.

Developer often face issues in creating a schema for this kind of file.

In this exercise we will try to create a schema for such kind of CSV file and will then try to process it using soa suite file adapter.

I have following set of CSV file

0,4321432143214321,0316,VISA
Rahi,Arpit,Varthur Hobli,Bangalore,KA,12345,5127691108
Rahi,Arpit,Varthur Hobli,Bangalore,KA,12345,5127691108
Standard,ar@test.com
32779,5,4.72,hard drive,Ramson,2008,hard drive Ramson
30421,16,10.72,RAM,Intel,2005,RAM Intel
32861,11,60.72,Chain,alloy,1829,Ring chain alloy

which needs to be processed.

Here if you can review the file closely you can find that there are four distinct records. So while creating the schema for the csv file you have to ensure that your schema should be able to process this file and it will also take care of the repeating elements.

We will see how we can do this.

We will create a file adapter and will use Define native schema format wizard to create a schema for our schema

I will directly jump to native schema builder.

As soon as you will click on this a gui will come up



say next and update the schema name



Say next and select the default option of delimited file as it is a CSV file



select your csv file and validate it is loaded properly



Say next and choose multiple records are of different type otherwise it will process all the record as a single type.



Say next and give some name to the schema



Say next and validate the delimiter and the end of line



Say next and you will observer it is automatically creating a record for you. However the strange part is that it has created 6 record type instead of 7

In my original csv file i have 7 lines however the record created is 6

The reason being second and third record start with same value and in condition value we should have a unique value.

we will just go ahead with the default configuration by Jdeveloper and later we will change it to see how we can modify this or how we can generalize it for other records as well.

you can go to next page, select the individual record and update the names to some logical name



Again say next, it will generate a default schema for you



Say next and finish the wizard.

create a bpel process to receive the file and deploy the process.


Test the service and you will see a successful instance getting created And you will find the correct payload as you were expecting

<Receive1_Read_InputVariable>
-<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="body">
-<Root-Element xmlns="http://TargetNamespace.com/fileService">
-<RECORD1>
<C2>4321432143214321</C2>
<C3>0316</C3>
<C4>VISA</C4>
</RECORD1>
-<RECORD2>
<C2>Arpit</C2>
<C3>Varthur Hobli</C3>
<C4>Bangalore</C4>
<C5>KA</C5>
<C6>12345</C6>
<C7>5127691108</C7>
</RECORD2>
-<RECORD2>
<C2>Arpit</C2>
<C3>Varthur Hobli</C3>
<C4>Bangalore</C4>
<C5>KA</C5>
<C6>12345</C6>
<C7>5127691108</C7>
</RECORD2>
-<RECORD3>
<C2>ar@test.com</C2>
</RECORD3>
-<RECORD4>
<C2>5</C2>
<C3>4.72</C3>
<C4>hard drive</C4>
<C5>Ramson</C5>
<C6>2008</C6>
<C7>hard drive Ramson</C7>
</RECORD4>
-<RECORD5>
<C2>16</C2>
<C3>10.72</C3>
<C4>RAM</C4>
<C5>Intel</C5>
<C6>2005</C6>
<C7>RAM Intel</C7>
</RECORD5>
-<RECORD6>
<C2>11</C2>
<C3>60.72</C3>
<C4>Chain</C4>
<C5>alloy</C5>
<C6>1829</C6>
<C7>Ring chain alloy</C7>
</RECORD6>
</Root-Element>
</part>
</Receive1_Read_InputVariable>


however there is lot of things that we need to understand here. We can observer that the first value in every record is missing.

We will try to analyse it with the schema that got generated by default

<?xml version = '1.0' encoding = 'UTF-8'?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd" xmlns:tns="http://TargetNamespace.com/fileService" targetNamespace="http://TargetNamespace.com/fileService" elementFormDefault="qualified" attributeFormDefault="unqualified" nxsd:version="NXSD" nxsd:stream="chars" nxsd:encoding="US-ASCII">


<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:choice minOccurs="1" maxOccurs="unbounded" nxsd:choiceCondition="terminated" nxsd:terminatedBy=",">
<xsd:element name="RECORD1" nxsd:conditionValue="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD2" nxsd:conditionValue="Rahi">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C6" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C7" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD3" nxsd:conditionValue="Standard">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD4" nxsd:conditionValue="32779">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C3" type="xsd:decimal" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C6" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C7" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD5" nxsd:conditionValue="30421">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C3" type="xsd:decimal" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C6" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C7" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD6" nxsd:conditionValue="32861">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C3" type="xsd:decimal" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C6" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="""/>
<xsd:element name="C7" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>


You can observe here that for every record element there is a conditional value which is nothing but the first column of the record.
So ideally we were expecting all the records but some how we got the record will one less value.

We will now try to see what all changes we can do to get all the records.

Monday, January 18, 2016

Generate unique id for multiple order lines


More than often we come across a requirement that a unique order line should only be processed.

That essentially mean you can have multiple parameters in your order line and you want to pick record with a unique combination of some attribute in your order line data. this will be more clear with an example and then subsequent solution for the issue.

This we will achieve using two XSLT function

XSLT key function which returns a node-set from the document, using the index specified by an element.

XSLT generate-id() Function which returns a string value that uniquely identifies a specified node.

If the node-set specified is empty, an empty string is returned. If you omit the node-set parameter, it defaults to the current node.

You can get more idea on the same from w3 schools

http://www.w3schools.com/xsl/func_generateid.asp
http://www.w3schools.com/xsl/func_key.asp

Now we will see in this example how we can use these two function to process unique order line.

First you should define a key, i.e. let suppose you want to process an order with a unique combination of account number and po number. In that case you will first define a key as below



Here xpath for parameter can be the path in your xml where account number and po number can be traversed

e.g if you have following xpath valid

/PO/ListofPO/AccontNumber
/PO/ListofPO/PoNumber

so your match parameter will be /PO/ListofPO

Obviously the namespace has to be there.

Now you got an idea on how to generate a key for a combination of parameter.

Lets generate a unique if for this key

/PO/ListofPO/PODetails[generate-id()=generate-id(key('Order',concat(ns0:AccountNumber,",",ns0:PoNumber))[1])]

Now what this mean is the processing will happend for the PODetails which has a unique combination of AccountNumber and PoNumber


oracle.j2ee.ws.client.jaxws.JRFSOAPFaultException


This is a very common issue when you try to access Siebel or Magento web services from Oracle SOA Suite.

The reason for this error is that in SOA when the external magento or siebel web services are called.

SOA adds additional header information which these backend system do not process.

wsa:TO
wsa:Action
ReplyTo
FaultTo

In order to resolve this issue, all you need to do is to remove the additional header information from the SOA

Use the following property in the composite.xml for the component which is getting called

oracle.soa.ws.outbound.omitWSA = true

This will suppress all the header information for the outgoing call from SOA.


I used this property for the component under binding information in my composite.xml

Redeployed the process and i was able to resolve the issue.


You might also face similar kind of issue while getting the response back.


If you want to suppress the header information from response you will have to use following property in composite.xml

oracle.soa.addressing.response.enabled = false



For each activity in BPEL 2.0


With BPEL 2.0 a lot of new changes has come.

Earlier if you had to implement a loop you will use flowN or while loop, however with BPEL 2.0 we now have a for each activity and it is very easy to use.

Let suppose you have a xml schema

<xsd:element name="CompleteOrder">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="OrderNumber" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Order" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


You want to call an adapter for every order.

you can do this very easily using a for each activity.

Drag and drop a for each activity in the process.

Specify the counter name and copy it as this is the counter variable name that needs to be used inside a process to loop for element



Now go to counter Value tab and specify the initial counter as 1

Again for Final value get the count of OrderNumber as shown in the diagram.

As you can see from the schmea OrderNumber is the repeating element so count() is used to get the final number.



NOw we are almost done ,

Only thing required is to use the counter variable during your assign activity .


you have to use it in the same as you used to do in case of a loop.

For the repeating node you have to use following syntax

RepeatingNode[$ForeachCounter]


As you can see ForeachCounter is the same variable we have defined in the very first step.

So a normal assign will have and entry like this.




your assign should be within the scope of for each



Group and Summarize data in XSLT


I was trying to process an order data which has multiple item. My requirement was to group and summarize the data.

I have following input

<soas:Items>
<soas:Item >
<soas:SKU>32779</soas:SKU>
<soas:Quantity>5</soas:Quantity>
<soas:UnitPrice>10</soas:UnitPrice>
</soas:Item>
<soas:Item >
<soas:SKU>30421</soas:SKU>
<soas:Quantity>2</soas:Quantity>
<soas:UnitPrice>10</soas:UnitPrice>
</soas:Item>
<soas:Item >
<soas:SKU>32861</soas:SKU>
<soas:Quantity>1</soas:Quantity>
<soas:UnitPrice>60</soas:UnitPrice>
</soas:Item>
<soas:Items>


I want the summary of all item amount that is summation for price*quanity of all the items

Summary = (Price*Quantity+Price*Quantity+Price*Quantity)=130

I tried to implement it in XSLT 2.0 but that didn't work for me.

I tried it in XSLT 1.1 using XSLT call template and this worked for me.

I tried to capture the value in Amount element, I used the following code

<tns:Amount>
<xsl:call-template name="sum">
<xsl:with-param name="nodes" select="/ns0:Order/ns0:Items/ns0:Item"/>
</xsl:call-template>
</tns:Amount>


<xsl:template name="sum">
<xsl:param name="nodes"/>
<xsl:param name="sum" select="0"/>
<xsl:variable name="current" select="$nodes[1]"/>
<xsl:if test="$current">
<xsl:call-template name="sum">
<xsl:with-param name="nodes" select="$nodes[position() > 1]"/>
<xsl:with-param name="sum" select="$sum + $current/ns0:UnitPrice * $current/ns0:Quantity"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($current)">
<xsl:value-of select="$sum"/>
</xsl:if>
</xsl:template>