Monday, March 19, 2018

How to Update MDS Files using scripts in SOA 12C | AIAConfigurationProperties File

Below are the steps to update AIAConfigurationProperties.xml in SOA 12C. You can pretty much use the same steps to update any MDS files in SOA 12C.

1. Open Putty, Go to below location(location might differ based on your installation) /soa/oracle/oracle_common/common/bin

2. run wlst.sh like below.
./wlst.sh

3. It will be in offline mode, so do
connect()
Once it prompts for username/ password, please provide weblogic credentials, like below
t3://host:port
Example t3://123.12.12.12:7001

4. exportMetadata(application='soa-infra',server='SOAServer1',toLocation='/home/MDSArtifacts',docs='/**')
(This is a one time activity, to get the current structure of  MDS in your server location, You can choose any toLocation in above statement.)

5. Now go to below location to update the AIAConfig file.
(you can open in another session or open the file using Winscp)
/home/MDSArtifacts/soa/configuration/default and Change the AIAConfigurationProperties.xml

As you might be already aware, in SOA 12c AIAConfig file will be under "soa" folder instead "apps".

6. Change update the file as required.

7. importMetadata(application='soa-infra',server='SOAServer1',fromLocation='/home/MDSArtifacts',docs='/soa/configuration/default/AIAConfigurationProperties.xml')

8. Reload the configuration by go to SCE console.
http://host:SOAPort/sce

Example: http://123.12.12.12:8001/sce

How to Decompress the XML from Base 64 format in BPEL | GZIP | SOA

Below is the Java embedding code to decompress the base 64 format into a XML.

try                                                     
{     
//Base 64 Format to Bytes 
oracle.xml.parser.v2.XMLElement inputPayload = (oracle.xml.parser.v2.XMLElement)getVariableData("Invoke_Target_OutputVariable","Result","/response/paylaod");           
String inputstr = inputPayload.getTextContent();
byte[] valueDecoded = org.apache.commons.codec.binary.Base64.decodeBase64(inputstr.getBytes());
//Bytes to GZIP
java.util.zip.GZIPInputStream zis = new java.util.zip.GZIPInputStream((java.io.InputStream) new java.io.ByteArrayInputStream(valueDecoded));
//GZIP to XML
StringBuilder xmlStr = new StringBuilder();
byte[] buffer = new byte[1024];
int read = 0;
while (zis.available()==1) {
while ((read = zis.read(buffer, 0, 1024)) >= 0) {
xmlStr.append(new String(buffer, 0, read));
}
}
String xmlMsg = xmlStr.toString();
//Assign XML to a Variable in BPEL
setVariableData("Temp_EBM", xmlMsg); 
}                                                 
catch(Exception e)                                                 
{                                                 
e.printStackTrace();                                                 
}

To learn how to compress, please use below link.
How to compress xml using gzip in bpel

How to Compress the XML Using GZIP in BPEL | Bas64 | SOA

Below is the Java embedding code in BPEL which will compress the XML using GZIP and convert it into Bas64 format. Compression ratio will be around 85%.

try {               
//Retrieve XML and Convert it to String           
    oracle.xml.parser.v2.XMLElement inputPayload = (oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/inputXML"); 
    oracle.xml.parser.v2.XMLDocument xmlPayload = inputPayload.getDocument();             
    java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();             
    xmlPayload.print(outputStream);             
    String inputstr = outputStream.toString();

//Compress the string using Gzip and Convert it to byte[]     
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(inputstr.length());   
java.util.zip.GZIPOutputStream gzip = new java.util.zip.GZIPOutputStream(bos);         
gzip.write(inputstr.getBytes());         
gzip.close();         
byte[] compressed = bos.toByteArray();         
        bos.toByteArray();         
bos.close();         

//Convert the Gzip to Base64 Format           
  oracle.soa.common.util.Base64Encoder encoder = new oracle.soa.common.util.Base64Encoder();                   
  java.lang.String encodedString = null;                   
  encodedString = encoder.encode(compressed);             
   
//Assign it to Invoke variable           
  setVariableData("Invoke_TargetSystem_InputVariable", "Parameters", "/request/paylaod", encodedString);       
   
} catch (Exception e) {                   
  addAuditTrailEntry(e);                   
}

To learn how to decompress, please use below link.
How to decompress xml from base64|GZIP

Wednesday, March 7, 2018

How to import/export/deploy MDS from EM console - SOA 11g

Export MDS Artifacts from EM console

Open Em console
http://host:port/em

Right Click on Soa-infra and select Administration-> MDS Configuration


And then Click on Export button, to export all the metadata contents to your machine.


Import/Deploy MDS Artifacts 

Right Click on Soa-infra and select Administration-> MDS Configuration

Click on Choose file under import.

Point to be noted is the folder structure. The Root folder should start from apps. 

For example, if you want to import some files under ApplicationConnectorServiceLibrary then you should create the folder structure like apps\AIAMetaData\AIAComponents\ApplicationConnectorServiceLibrary\AIA\ProviderABCS\Sample.wsdl

Then Zip the apps folder and import it here in the EM console.