OSB Deployment scripts 11.1.1.7 using configtool


These instructions are only valid for OSB Release 11.1.1.7 onwards.

 

How to export desired projects using the configjar utility

 

The configjar tool is located in the OSB installation directory under

C:\oracle\Middleware11117\Oracle_OSB1\tools\configjar

[Check the path relative to your install]

Run the setenv.cmd

And execute the

C:\oracle\Middleware11117\Oracle_OSB1\tools\configjar\configjar.bat -settingsfile C:\OSB_Deployment\OSBPS6_MavenConfigTool\nysolutions_export_projects.xml

 

Where the nysolutions_export_projects.xml file contains the names of the projects and the configuration files and the desired output filename.

 

 

 

The nysolutions_export_projects.xml I used for this post was

 

 

 

    <source>
        <project dir="C:\Users\nitina\osbworkspace\Contracts"/>
        <project dir="C:\Users\nitina\osbworkspace\NYSService1"/>
        <project dir="C:\Users\nitina\osbworkspace\NYSService2"/>
        <project dir="C:\Users\nitina\osbworkspace\NYSService3"/>
        <system  dir="C:\Users\nitina\osbworkspace\nys-conf"/>
    </source>
    <configjar jar="C:\OSB_Deployment\OSBPS6_MavenConfigTool\export\NYSsbconfig.jar">
         <projectLevel includeSystem="true"/>
    </configjar>
    
</configjarSettings>

 

 

 

 

Complete list of options and commands are available in oracle documentation at http://docs.oracle.com/cd/E28280_01/dev.1111/e15866/app_export.htm#BABDJJIA

 

Export Settings File Schema Definition

Below is the schema definition for the export settings XML file. Some of the text below has been wrapped for readability.

<?xml version="1.0"?>
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:tns="http://www.bea.com/alsb/tools/configjar/config">
<xs:element name="configjarSettings" type="tns:configjarSettings"/>
<xs:complexType name="configjarSettings">
   <xs:sequence>
      <xs:element name="source" type="tns:source" />
      <xs:element name="configjar" type="tns:configjar" maxOccurs="unbounded"/>
   </xs:sequence>
</xs:complexType>
<xs:complexType name="source">
   <xs:sequence>
      <xs:choice minOccurs="1" maxOccurs="unbounded">
         <xs:element name="project">
            <xs:complexType>
               <xs:attribute name="dir" type="xs:string" use="required"/>
            </xs:complexType>
         </xs:element>
         <xs:element name="system">
            <xs:complexType>
               <xs:attribute name="dir" type="xs:string" use="required"/>
            </xs:complexType>
         </xs:element>
      </xs:choice>
      <xs:element name="extensionMapping" minOccurs="0">
         <xs:complexType>
            <xs:sequence>
               <xs:element name="mapping" minOccurs="0" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:attribute name="type" type="xs:string" use="required"/>
                  <xs:attribute name="extensions" type="xs:string"
                                use="required"/>
                  </xs:complexType>
               </xs:element>
            </xs:sequence>
         </xs:complexType>
      </xs:element>
     <xs:element name="fileset" type="tns:contentSet" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="configjar">
  <xs:sequence>
      <xs:choice minOccurs="1" maxOccurs="1">
         <xs:element name="projectLevel" type="tns:projectLevel"/>
         <xs:element name="resourceLevel" type="tns:resourceLevel"/>
      </xs:choice>
  </xs:sequence>
  <xs:attribute name="jar" type="xs:string" use="required"/>
  <xs:attribute name="overwrite" type="xs:boolean" use="optional"
 default="true"/>
</xs:complexType>
<xs:complexType name="projectLevel">
   <xs:sequence>
      <xs:element name="project" type="xs:string" minOccurs="0"
                  maxOccurs="unbounded"/>
   </xs:sequence>
   <xs:attribute name="includeSystem" type="xs:boolean" use="optional"
               default="false"/>
</xs:complexType>
<xs:complexType name="resourceLevel">
   <xs:sequence>
      <xs:element name="resources" type="tns:contentSet" minOccurs="0"/>
   </xs:sequence>
   <xs:attribute name="includeDependencies" type="xs:boolean" use="optional"
                 default="true"/>
</xs:complexType>
<xs:complexType name="contentSet">
   <xs:sequence>
      <xs:element name="include" type="tns:contentSetPattern" minOccurs="0"
                  maxOccurs="unbounded"/>
      <xs:element name="exclude" type="tns:contentSetPattern" minOccurs="0"
                  maxOccurs="unbounded"/>
   </xs:sequence>
</xs:complexType>
<xs:complexType name="contentSetPattern">
  <xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>

 

 

Sample configSettings.xml generated using eclipse

 

<?xml version="1.0" encoding="UTF-8"?>
  <tns:source>
    <tns:project dir=""/>
    <tns:extensionMapping>
      <tns:mapping extensions="" type=""/>
    </tns:extensionMapping>
    <tns:fileset>
      <tns:include name=""/>
      <tns:exclude name=""/>
    </tns:fileset>
  </tns:source>
  <tns:configjar jar="" overwrite="true">
    <tns:projectLevel includeSystem="false">
      <tns:project>tns:project</tns:project>
    </tns:projectLevel>
  </tns:configjar>
</tns:configjarSettings>

 

 

Step 2

 

Create a ALSBCustomizationFile.xml which contains all the config settings.

 

Step 3

 

Run the deployment scripts to deploy the NYSsbconfig.jar file generated above…

Update the wlst with environment specific values deployToServer.py

java weblogic.WLST deployToServer.py

 

Where the deployToServer.py file is

from java.util import HashMap
from java.util import HashSet
from java.util import ArrayList
from java.io import FileInputStream
from com.bea.wli.sb.util import Refs
from com.bea.wli.config.customization import Customization
from com.bea.wli.sb.management.importexport import ALSBImportOperation
import sys
#=======================================================================================
# Entry function to deploy project configuration and resources
#        into a ALSB domain
#=======================================================================================
def importToALSBDomain():
    try:
        SessionMBean = None
        print 'Attempting to import :', importJar, "on ALSB Admin Server listening on :", adminUrl
        theBytes = readBinaryFile(importJar)
        print 'Read file', importJar
        sessionName = createSessionName()
        print 'Created session', sessionName
        SessionMBean = getSessionManagementMBean(sessionName)
        print 'SessionMBean started session'
        ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found", ALSBConfigurationMBean
        ALSBConfigurationMBean.uploadJarFile(theBytes)
        print 'Jar Uploaded'
        if project == "None":
            print 'No project specified, additive deployment performed'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            alsbImportPlan.setPreserveExistingEnvValues(true)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
            SessionMBean.activateSession(sessionName, "Complete import without customization using wlst")
        else:
            print 'ALSB project', project, 'will get overlaid'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            operationMap=HashMap()
            operationMap = alsbImportPlan.getOperations()
            print
            print 'Default importPlan'
            printOpMap(operationMap)
            set = operationMap.entrySet()
            alsbImportPlan.setPreserveExistingEnvValues(true)
            #boolean
            abort = false
            #list of created ref
            createdRef = ArrayList()
            for entry in set:
                ref = entry.getKey()
                op = entry.getValue()
                #set different logic based on the resource type
                type = ref.getTypeId
                if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
                    if op.getOperation() == ALSBImportOperation.Operation.Create:
                        print 'Unable to import a service account or a service provider on a target system', ref
                        abort = true
#                elif op.getOperation() == ALSBImportOperation.Operation.Create:
                else:
                    #keep the list of created resources
                    print 'ref: ',ref
                    createdRef.add(ref)
            if abort == true :
                print 'This jar must be imported manually to resolve the service account and service provider dependencies'
                SessionMBean.discardSession(sessionName)
                raise
            print
            print 'Modified importPlan'
            printOpMap(operationMap)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
            printDiagMap(importResult.getImportDiagnostics())
            if importResult.getFailed().isEmpty() == false:
                print 'One or more resources could not be imported properly'
                raise
            #customize if a customization file is specified
            #affects only the created resources
            if customFile != "None" :
                print 'Loading customization File', customFile
                print 'Customization applied to the created resources only', createdRef
                iStream = FileInputStream(customFile)
                customizationList = Customization.fromXML(iStream)
                filteredCustomizationList = ArrayList()
                setRef = HashSet(createdRef)
                # apply a filter to all the customizations to narrow the target to the created resources
                for customization in customizationList:
                    print customization
                    newcustomization = customization.clone(setRef)
                    filteredCustomizationList.add(newcustomization)
                ALSBConfigurationMBean.customize(filteredCustomizationList)
            SessionMBean.activateSession(sessionName, "Complete import with customization using wlst")
        print "Deployment of : " + importJar + " successful"
    except:
        print "Unexpected error:", sys.exc_info()[0]
        if SessionMBean != None:
            SessionMBean.discardSession(sessionName)
        raise
#=======================================================================================
# Utility function to print the list of operations
#=======================================================================================
def printOpMap(map):
    set = map.entrySet()
    for entry in set:
        op = entry.getValue()
        print op.getOperation(),
        ref = entry.getKey()
        print ref
    print
#=======================================================================================
# Utility function to print the diagnostics
#=======================================================================================
def printDiagMap(map):
    set = map.entrySet()
    for entry in set:
        diag = entry.getValue().toString()
        print diag
    print
#=======================================================================================
# Utility function to read a binary file
#=======================================================================================
def readBinaryFile(fileName):
    file = open(fileName, 'rb')
    bytes = file.read()
    return bytes
#=======================================================================================
# Utility function to create an arbitrary session name
#=======================================================================================
def createSessionName():
    sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
    return sessionName
#=======================================================================================
# Utility function to load a session MBeans
#=======================================================================================
def getSessionManagementMBean(sessionName):
    SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
    SessionMBean.createSession(sessionName)
    return SessionMBean
# IMPORT script init
try:
    # import the service bus configuration
    adminUser    = "weblogic"
    adminPassword= "weblogic1"
    adminUrl     = "t3://soabpm-vm:7001"
    importJar    = "export/NYSsbconfig.jar"
    customFile   = "ALSBCustomizationFile.xml"
    passphrase   = "osb"
    project      = "NYSService1"
    connect(adminUser,adminPassword,adminUrl)
    domainRuntime()
    importToALSBDomain()
except:
    print "Unexpected error: ", sys.exc_info()[0]
    dumpStack()
    raise

 

That’s it all done…you can then check on the sbconsole that the changes have all been deployed.

Oracle Service Bus   View Configuration Changes

 

OSB access to salesforce.com by Steffen Miller


Nits:

OSB access to salesforce.com by Steffen Miller

Originally posted on SOA Community Blog:

Some time ago I had a request to connect a file with salesforce.com. The tool of choice was Oracle Service Bus, first without any special adapter. So I had to investigate into the salesforce.com way of using web services and how I can approach this challenge.

First of all we need an account with salesforce.com. With this account we can access the Web Services API through Profile -> Setup -> API. Here we need to download the Enterprise WSDL.

You can find more details to this here salesforce.com Documentation.

Now we import the WSDL into the Oracle Service Bus. As written in the docs Before invoking any other calls, a client application must first invoke the login() call to establish a session with the login server, set the returned server URL as the target server for subsequent API requests, and set the returned session ID in the SOAP header…

View original 154 more words