Posts Tagged 'OSB'



SOA 12c–Creating ESS Job metadata (JDeveloper)

In the previous post, We have seen how to use EM Console to create the Job metadata. This did not provide the much information about development and deployment details of ESS application. So in this post, we will use JDeveloper to create ESS Job metadata to call the Service Bus proxy services however the steps remain same for BPEL services too.

Before proceeding with actual creation of job metadata, we will know the terms Hosting and Client Applications.

Hosting Application

ESS Jobs always execute in context of hosting application. When we configure domain for ESS, we get EssNativeHostingApp which is pre-deployed native hosting application that is well suited for custom remote jobs like EJB and web service jobs. However, we can’t execute custom Java jobs.

Client Application

Client applications are typically J2EE application used to submit jobs, query job status and optionally perform updates to ESS metadata. We cannot add ESS job metadata (using MAR archive) directly to the pre-deployed native hosting application and have to deploy through a client application or using metadata API.

More information can be found in ESS documentation here

Creating ESS Application

Select File –> New –> Applications –> Custom Application as shown below.

essappl

Enter Application Name.

essappl1

Choose the Project Features as shown below and click Next.

essproj

essproj1

Choose the EJB Version and select Generate ejb-jar.xml as shown below.

essproj2

Enter a meaningful value for Application Id.

essproj3

Click Finish and verify that following files got generated in project.

essappl2

Creating Job Metadata – Job Definition

Create Job Definition following the screenshots below. Select File-> New –> Enterprise Scheduler Metadata –> Job Definition.

jobdefn

Enter Job name. Since we are going to call a OSB Synchronous service select the corresponding Job type as shown below. Make sure that location includes essmeta directory.

osbtype

Note that MW_HOME env variable has to be set as shown below to be able to see and select Job Type.

envvar

Click Web service icon to select the WSDL.

osbjobdefn

Select Service Bus as web service type and click search icon.

wsdlsel

Enter Service Bus Proxy Service WSDL as shown below and click OK. Make sure that you give the URL of concrete WSDL.

wsdlurl

Verify that Service and Port Type are automatically populated. Select the operation and parameterize payload using ESS_REQ as shown below. This context is used to access ESS Parameters defined for Job. Hence we need to create CustomerId parameter. Click OK.

wsdlsel1

Verify that System Properties are populated as shown below.

jobdefnafterwsdl

Click + in Application Defined Properties section and add CustomerId parameter as shown below and click OK.

argument1

Since our job should run in context of the pre-deployed hosting application EssNativeHostingApp, add parameter SYS_effectiveApplciation in System Properties section as shown below.

sysprop

weblogic-application.xml

Make sure you only have the following library references in this file.

<listener>
   <listener-class>oracle.mds.lcm.weblogic.WLLifecycleListener</listener-class>
</listener>

<library-ref> 
   <library-name>oracle.ess.thin.client</library-name>
</library-ref>
 

ejb-jar.xml

Add following contents in this file (See the Observations section below).

<enterprise-beans>
    <session>
        <description>Runtime Session Bean</description>
        <ejb-name>RuntimeServiceBean</ejb-name>
        <ejb-class>oracle.as.scheduler.ejb.RuntimeServiceBean</ejb-class>
    </session>
    <session>
        <description>Metadata Session Bean</description>
        <ejb-name>MetadataServiceBean</ejb-name>
        <ejb-class>oracle.as.scheduler.ejb.MetadataServiceBean</ejb-class>
    </session>
    <session>
        <description>Async Request Bean</description>
        <ejb-name>AsyncRequestBean</ejb-name>
        <ejb-class>oracle.as.scheduler.ejb.AsyncRequestBean</ejb-class>
    </session>
</enterprise-beans>

adf-config.xml

If the EAR file generated from this application is to be deployed, certain MDS partition entries must be specified in this file, so add the following contents. The data source referenced here is automatically created when we configure the domain to include ESS. The namespace mentioned over here (highlighted below) should match the package structure we used for creating job definition.

<adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">
    <mds-config version="11.1.1.000" xmlns="
http://xmlns.oracle.com/mds/config">
        <persistence-config>
            <metadata-namespaces>
                <namespace path="/oracle/apps/ess/custom/osb" metadata-store-usage="ess_custom_metadata"/>
            </metadata-namespaces>
            <metadata-store-usages>
                <metadata-store-usage id="ess_custom_metadata" deploy-target="true" default-cust-store="false">
                    <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
                        <property name="jndi-datasource" value="jdbc/mds-ESS_MDS_DS"/>
                        <property name="repository-name" value="mds-ESS_MDS_DS"/>
                        <property name="partition-name" value="essUserMetadata"/>
                    </metadata-store>
                </metadata-store-usage>
            </metadata-store-usages>
        </persistence-config>
    </mds-config>
</adf-mds-config>

Deployment

We have to create the following deployment profiles to be able to deploy:

  • Project level EJB JAR deployment profile.
  • Application level MAR deployment profile.
  • Application level EAR deployment profile

EJB JAR Deployment Profile

Use the following screen shots to create project level EJB JAR profile.

ejbjar1

ejbjar2

ejbsource

ejbjar3

ejbjar4

MAR Deployment Profile

Use the following screen shots to create application level MAR profile.

mar1

marcontent

maressmeta

maressmeta1

maressmeta2

EAR Deployment Profile

Use the following screen shots to create application level EAR profile.

earprofile

earprofile1

earmanifest

earlib

Deployment

Deploy the EAR file of ESS application as shown in following screenshots.

deployess1

deployess2

deployess3

deployess4

deployess5

Here, essUserMetadata is partition used by EssNativeHostingApp. We can observe deployment log as shown below.

deploylog

Submitting the request

In EM Console, navigate to Scheduling Services –> ESSAPP-> Job Requests –> Submit Job Request. Select application as EssNativeHostingApp and choose the job definition as below and select OK.

jobdefnsub

jobdefnsub1

Once the job run is successful, you can see the status as shown below.

reqsuccess

The sample application can be downloaded from here.

Observations

  • Though we add only ESS Job Support and ESS Client Support features during application creation, we see ESS Host Support as well in Project feature section as shown below.

projfeatures

  • Unable to see the Job definitions in ESS while submitting requests, when used package structure (which is effectively a namespace) that does not contain /oracle/apps/ess. Section 1.2.10 of this documentation clearly mentioning that the  job definition must be created in  the namespace /oracle/apps/ess/custom.
  • Unable to refer the WSDL from SOA_MDS or File System in the Web Service chooser during Job definition creation and is resulting into the following error as shown below.

mdswsdl

mdswsdl1

  • The data source mds-ESS_MDS_DS is to be  targeted to AdminServer as shown below, so that we will be able to select data source during deployment.

    essds

  • Initially thought, there is no need of ejb-jar.xml in this ESS application as it’s used predominantly to specify Application Name. But was getting following error during deployment when this file is not present in application or the file has empty contents. So at minimum, this file should have the contents as mentioned above.

         <May 19, 2015 8:47:48 PM IST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "Ear_EssSampleAppl" due  to error weblogic.management.DeploymentException: Error parsing META-INF/application.xml weblogic.management.DeploymentException: Error parsing META-INF/application.xml

SOA 12c–Creating ESS Job metadata (EM Console)

In this post, We will use the EM Console to create ESS Job metadata  to call the Service Bus proxy services however the steps remain same for calling BPEL service too.

Configuration

During domain creation, we should select the following options to create ESS Managed Server and EM Plugin for ESS. EM Plugin for ESS enable us to monitor and manage submitted ESS jobs.

essemplugin

You should see the EM Console as shown below on successful domain creation and starting the Admin and ESS servers. Observe that Scheduling Services is shown having ESSAPP.

emwithessapp

If you don’t select EM plugin for ESS option during domain creation, your EM console will look like below with no Scheduling Services.

emwithoutess

You can do ESS health check using >:>/ess">>:>/ess">>:>/ess">http://<<hostname>>:<<port>>/ess which brings up the following screen.

esshealth

Click Check Health for this ESS Server which submits a sample job and give us back the status of ESS server as shown below.

esshealth1

You can verify status of this sample job from Search Job Requests as shown below. The navigation to this page is given later in this post.

esshealthcheck

You can find more information inn ESS documentation here.

Creating Job Definition

First, we need to create Job Metadata so that we can execute the ESS job or schedule as and when required. Job Definition contains all required metadata to run the job. We can use JDevloper or EM Console to create job definition. In this post, we will demonstrate usin EM Console.

Right click on ESSAPP and select Job Definitions as shown below.

emjobdefn

Click Create to proceed with creation of new ESS Job Definition.

emjobdefncreate

Provide Job name and other information as shown below. We need to select Job Type as SyncWebserviceJobType as we want to call a service bus Proxy Service. Click Select Web Service to select the WSDL of service.

emsyncws

Provide WSDL URL and choose Web Service Type as Service Bus. Click OK.

emjobdefnwsdl

Observe that the services listed in WSDL are shown. Select the Port Type and Operation as required which shows up the sample payload as shown below. Since we want to allow user to enter Customer ID, we have to parameterize payload using ESS_REQ token which is used to access request arguments. So in our case, we need to define an argument with name CustomerId.

empayload

Click OK and observe lot of System Properties are populated automatically as shown below.

emsysprop

To define argument for ESS job, click + icon in Application Defined Properties section to bring up following Popup. Given name as CustomerId and Type as String as shown below and click OK.

emargs

Now observe that a new Job Definition is created as shown below.

emjobcreate

Submitting Job

We can manually submit ESS job or use a schedule to run it programmatically. For now, let us proceed with manual submission so right click ESSAPP and choose Submit Job Request as shown below.

emsubmit

Choose Job Definition by clicking search icon as shown below.

submit0

submit2

Click OK and enter value for CustomerID Job Parameter as shown below.

submit1

Click OK to submit ESS job and observe the status and log as shown below. Since it’s a simple service call, the ESS job did not take much time.

emreqsuccess

You can open log file shown above and verify the output as expected.  Since it’s a sync call, we have received service response and same is logged.

emreqlog

To manage the submitted jobs, we can navigate to the Search Job Requests page using navigation shown below.

emjobsearch

Here, you can search for submitted jobs using different search criteria and also can do Cancel, Hold and Resume of job depending on current status of Job.

emreqsuccess1

Note: The use case considered here does not actually qualify as ESS job and not of batch job nature and used just for demonstration purpose. ESS is more suitable for batch jobs as you can schedule and run asynchronously in it’s own JVM.

Service Bus 12c– Outbound SSL

In the last 2 posts, we have seen how to configure Service Bus to use 1-Way SSL and 2-Way SSL. In both of these scenarios, our Service Bus managed server is acting as Server but our server can also become a Client when talking to external services using the Business Services having SSL enabled. So we will discuss about Outbound SSL in this post.

1-Way SSL

Before getting into the required OSB setup, enable our SOAP UI mock service to use SSL. Go to File –> Preferences –> SSL Settings and set properties as shown below.

soapuissl

Access your mock service as shown below to confirm that SSL is enabled.

mockssl

Now update the business service endpoint URI with this URL in the Service Bus Console as shown below.

bsendpoint

Now test your business service and you can observe following error in server logs. This is because you have not yet updated the OSB server trust store with the certificate of SOAP UI mock service.

sslerror

sslbserror

So now export the Public Certificate from the keystore used for mock service and import into OSB trust store using following commands.

keytool –exportcert -alias localclient -keystore clientkeystore.jks -file localclient.cer

keytool -importcert -alias localclient -keystore osbkeystore.jks -file localclient.cer

Now test your Business Service to see the response as given below.

bstestsucc

2-Way SSL

In case of 2-way SSL, our Proxy Service acts as client and need to send the corresponding Public Certificate when server requests(in our case, it’s SOAP UI Mock Service).

In Service Bus, the resource Service Key Provider is used to retrieve the required PKI credentials that  includes Private key paired with a certificate. Proxy services use this key-pair to authenticate when acting as a client during an outbound SSL i.e. during routing a message to HTTPS business service or proxy service requiring Client Certificate authentication. You can find more information in Service Bus documentation here.

Service Key Provider makes use of PKI credential mapper  to retrieve the PKI credentials which has to be created first.

PKI Credential Mapper

In WLS admin console, navigate to Security Realms –> myrealm –> Providers –> Credential Mapping. Click New.

pkiprovider1_thumb2_thumb_thumb_thum

Give name and select Type as PKICredentialMapper and Click OK.

pkiprovider2_thumb2_thumb_thumb_thum

Verify that new credential mapping provider is created.

pkiprovider4_thumb3_thumb_thumb_thum

Now click SSLPKIProvider and navigate to Provider Specific tab. Mention the Keystore and Pass Phrase specific to OSB managed server and click Save.

pkiprovider3_thumb3_thumb_thumb_thum

Service Key Provider

We will directly use the sbconsole for creating the Service Key Provider and to make other required changes for Business and Proxy Services.

Create a OSB session and select Service Key Provider from drop down menu as shown below once you select the Service Bus Project.

skp1_thumb[2]

Provide the name and click Create.

skp2_thumb[2]

Now the Service Provider Definition look like as below. Since we are using this for SSL purpose click search icon for SSL Client Authentication Key.

skp4_thumb[3]

Choose the Key Alias as shown below and provide the password.

skp5_thumb[3]

Click OK to bring up following screen and Save your changes done for Service Key Provider. Do activate Service Bus session.

skp6_thumb[3]

Soap UI Settings

Before proceeding with Proxy and Business service changes, you have to enable the SOAP UI mock service to request for Client Certificate.

To do this, navigate to File –> Preferences –> SSL Settings and choose Client Authentication as shown below.

soapuiclient_thumb[2]

Now test your Proxy Service to observe the following errors in response tab, jetty log and Service Bus logs respectively. This happens as we have not yet imported OSB server Public Certificate into clientkeystore.jks and also did not configure our Proxy/Business Service to send the client Certificate.

soapuibadcert_thumb[2]

soapuibadcert1_thumb[2]

osberror_thumb[2]

Export OSB server public certificate and import into clientkeystore.jks using following commands.

keytool -exportcert -alias localosb –keystore osbkeystore.jks –file osbcert.cer

keytool -importcert -alias localosb -keystore clientkeystore.jks –file osbcert.cer

keystoreimport_thumb[2]

With this, we are done with the SOAP UI settings and let us proceed  with the changes required for Proxy and Business Services.

Proxy and Business Service changes

Open business service and navigate to Transport Detail tab. Select Client Certificate as shown below for Authentication and save changes.

bsclientcert_thumb[3]

Open proxy service and navigate to Security –> Security Settings tab. Click search icon for Service Key Provider.

proxyskp_thumb[3]

Click Search and select the one that we have created earlier as shown below and click OK.

psskp1_thumb[3]

Now Security tab should show your selection as below.

psskp2_thumb[2]

Remember that you have to create OSB session before making changes and need to activate it once your changes are done.

You should see successful response as shown below, if you test your proxy service now.

success_thumb[3]

Please note that above logs are generated when following JVM options are set in setDomainEnv.cmd file for EXTRA_JAVA_PROPERTIES.

           -Dssl.debug=true -Dweblogic.StdoutDebugEnabled=true

Service Bus 12c– Two way SSL

In this post, we will see how to enable two-way SSL in Service Bus 12c. The steps mentioned here have to be performed in addition to steps mentioned in the previous post.

Navigate to Servers –> osb_server1 –> SSL in WLS Admin Console. Expand Advanced section and set Two Way Client Cert Behavior as shown below. This would enforce WLS to request the Client certificate during SSL handshake and will result into an error if the client certificate is not present in trust store.

2ssl

Now create a keystore clientkeystore1.jks using following command and will  be used in SOAP UI.

keytool -genkeypair -keyalg RSA -alias localclient1 -keystore clientkeystore1.jks -storepass cljks123 -validity 360 -keysize 2048

Set global SSL Settings in SOAP UI as shown below by navigating to File –> Preferences. Specify the above created keystore and  password.

soapui

Restart OSB managed server. Now if you test your Proxy Service from SOAP UI, you would see an error like below in the server log as the trust store does not have the client certificate.

sslerror

So export and import corresponding Client Certificate into the OSB trust store using following commands.

keytool -exportcert -alias localclient1 -keystore clientkeystore1.jks -file localclient1.cer

keytool -importcert -alias localclient1 -keystore osbkeystore.jks -file localclient1.cer

clientstore

Now test your Proxy Service from SOAP UI and you would see the response as expected without any error. And now the server log will be shown like below.

sslsuccess

Please note that above logs are generated when following JVM options are set in setDomainEnv.cmd file for EXTRA_JAVA_PROPERTIES.

           -Dssl.debug=true -Dweblogic.StdoutDebugEnabled=true

Service Bus 12c– One way SSL

In this post, we will see how to configure Service Bus to use One way SSL.

Here, we are not discussing about the SSL concepts and people who want to go through quick introduction of SSL can go through this.

In Summary, following are the steps to be followed:

  • Generate Custom Identity and Trust stores.
  • Enable SSL port.
  • Setting up the keystores.
  • Configure private keys for SSL

Please note that, JSSE (Java Secure Socket Extension)  is the only supported SSL implementation. The Certicom-based SSL implementation is removed and is no longer supported in WebLogic Server.

Create a folder keystores %FMW_HOME% to store all of your keystores used and issue the following command to generate a keystore for Admin server use as shown below.

keytool -genkeypair -keyalg RSA -alias localadmin -keystore adminkeystore.jks -storepass adjks123 -validity 360 -keysize 2048

createks

This creates keystore adminkeystore.jks having both public and the private keys with alias localadmin. You can observe the contents of keystore using the following command.

keytool -list -v -keystore adminkeystore.jks

jkscontents

Similarly, create other keystores to use for OSB and SOA managed servers and also a keystore to use for the client as shown below.

keystores

Enable SSL port by navigating to Environment –> Severs-> Admin Sever –> General.

sslenable

By Default, WLS uses the Demo Identity and Trust keystores and you can find them in %DOMAIN_HOME/security and %WLS_HOME%/server/lib. Oracle strictly recommends to use the Custom keystores at least for the Production environments. Hence we will use the custom keystores in this post.

Go to Keystores tab and click Change.

demoks

Select Custom Identity and Custom  Trust as shown below and click Save.

customks

Modify Custom Identity and Trust stores as shown below and here you also need to give keystore password. Click Save.

customks1

Go to SSL tab and give the Private key alias as shown below.

sslsetup

Go to Advanced settings and set Hostname verification to None and also set Two way Client Cert Behavior to Clients Certs not Required as we are doing setup for 1-way SSL. This setting will enforce WLS server not to request client certificates.

sslsetup1

Modify EXTRA_JAVA_PROPERTIES  in setDomainEnv.cmd to use following parameters and restart the admin server. This is required as to instruct WLS server to load trusted certificates.

-Dweblogic.security.SSL.trustedCAkeystore=C:\Oracle\Middleware\FMW1213New \keystores\adminkeystore.jks -Djavax.net.ssl.trustStorePassword=adjks123

Now you should be able to access WLS admin console using following URL and this confirm the SSL is configured on your admin server.

http://localhost:7002/console

You can refer to WLS documentation here for more information on this.

The following error is observed when we use a keystore as Trust store with zero trust certificates.

<[Thread[DynamicJSSEListenThread[DefaultSecure3]],9,WebLogicServer]weblogic.security.SSL.jsseadapter: TRUSTSTORE_MANAGER: No certs to
copy.>
<[Thread[DynamicJSSEListenThread[DefaultSecure3]],9,WebLogicServer]weblogic.security.SSL.jsseadapter: TRUSTSTORE_MANAGER: No trusted
CAs available to populate trust anchors.>
<[Thread[DynamicJSSEListenThread[DefaultSecure3]],9,WebLogicServer]weblogic.security.SSL.jsseadapter: TRUSTSTORE_MANAGER: Error initi
alizing trust manager factory: the trustAnchors parameter must be non-empty.
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
at weblogic.security.SSL.jsseadapter.JaTrustManager.<init>(JaTrustManager.java:57)
at weblogic.security.SSL.jsseadapter.JaSSLContextImpl.initializeContext(JaSSLContextImpl.java:654)

To debug SSL, modify EXTRA_JAVA_PROPERTIES  in setDomainEnv.cmd to include the following parameters.

-Dssl.debug=true -Dweblogic.StdoutDebugEnabled=true

To enable javax.net debugging include the following parameter.

-Djavax.net.debug=all

To eliminate this error, you can install any trust certificate into localadmin.jks or use cacerts keystore (available in %WLS_HOME%/server/lib) as Trust store. Here i have exported Public Certificate from clientkeystore.jks and got that imported into localadmin.jks.

Use the following command to export:

            keytool -exportcert -alias localclient -keystore clientkeystore.jks -file localclient.cer

Use the following command to import:

             keytool -importcert -alias localclient -keystore adminkeystore.jks -file localclient.cer

Now verify the contents of your keystore as below.

              keytool -list -v -keystore adminkeystore.jks

localcer

Similarly, configure OSB managed server using keystore osbkeystore.jks and use 7005 as the SSL port. Restart the OSB server after your changes.

osbsslport

osbsslks

osbsslks1

To enable your proxy services to be accessed only by SSL, you have to enable HTTPS option as below.

osbsslps

Now if you try to access your Proxy Service WSDL from browser, it will be automatically uses SSL as shown below.

osbwsdl

Most of the people uses SOAP UI to test their webservices. If you try to access this WSDL, you will be able to access from SOAP UI even without adding the required certificates to trust store. This is because SOAP UI trusts all by default as per this forum post.

To confirm the enablement of SSL on the Proxy Service, let us try to create a Webservice Proxy in JDeveloper that prompts to accept/trust the certificate.

jdevcert

Observation:

When you enable SSL debugging, you might observe the following exception in server log though your 1-way SSL works as expected. As per Oracle Support note 1606295.1, this is not a harmful exception.

<1425221899641> <BEA-000000> <Exception processing certificates: peer not authenticated javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
at weblogic.servlet.provider.WlsSecurityProvider.getSSLAttributes(WlsSecurityProvider.java:222)
at weblogic.servlet.internal.VirtualConnection.initSSLAttributes(VirtualConnection.java:165)
at weblogic.servlet.internal.VirtualConnection.init(VirtualConnection.java:75)
at weblogic.servlet.internal.ServletRequestImpl.initFromRequestParser(ServletRequestImpl.java:312)
at weblogic.servlet.internal.HttpConnectionHandler.dispatch(HttpConnectionHandler.java:577)
at weblogic.servlet.internal.MuxableSocketHTTP.dispatch(MuxableSocketHTTP.java:131)
at weblogic.socket.JSSEFilterImpl.dispatch(JSSEFilterImpl.java:216)
at weblogic.socket.MuxableSocketDiscriminator.dispatch(MuxableSocketDiscriminator.java:186)
at weblogic.socket.JSSEFilterImpl.dispatch(JSSEFilterImpl.java:216)
at weblogic.socket.SocketMuxer.readReadySocketOnce(SocketMuxer.java:970)
at weblogic.socket.SocketMuxer.readReadySocket(SocketMuxer.java:907)
at weblogic.socket.NIOSocketMuxer.process(NIOSocketMuxer.java:495)
at weblogic.socket.NIOSocketMuxer.processSockets(NIOSocketMuxer.java:461)
at weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:30)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:43)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:147)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:119)

SOA 12c – Using Maven for Service Bus deployment

In this post, we will see creation of Service Bus application and projects using maven archetypes. And we will use local Maven Repository for demonstration.

Generate Service Bus Application and Project as shown below.

mvn archetype:generate -DarchetypeGroupId=com.oracle.servicebus.archetype -DarchetypeArtifactId=oracle-servicebus-application -DarchetypeVersion=12.1.3-0-0 -DgroupId=org.my.test -DartifactId=test-servicebus-application -DprojectName=test-servicebus-project -Dversion=1.0-SNAPSHOT

Import this maven project in JDeveloper using the steps mentioned below. Select File –> Import and select Maven Project option and click OK.

import1

osbimport

osbappl

osbimported

Open application level POM file in Application Resources directory as shown below and observe the details.

osbapplpom

osbapplpom1

Open project level POM file and observe the details.

osbprojpom

Open System level POM file and observe the details.

osbsyspom

Add plugin and other server details in project level POM files (both System and Service Bus Project) as shown below. Remember using the Admin Server port as the server url.

<build>
<plugins>
<plugin>
<groupId>com.oracle.servicebus.plugin</groupId>
<artifactId>oracle-servicebus-plugin</artifactId>
<version>12.1.3-0-0</version>
<configuration>
<oracleServerUrl>
http://localhost:7001</oracleServerUrl>
<oracleUsername>weblogic</oracleUsername>
<oraclePassword>weblogic1</oraclePassword>
</configuration>
</plugin>
</plugins>
</build>

You can generate the sbar file for your Service Bus Projects using mvn package (from directory of Service Bus Application) and can be found in <<project>>/.data/ maven.

sbuspackage

Deploy your Service Bus projects using mvn pre-integration-test (from Service Bus application directory).

sbuspinttest

You can execute Service Bus Plugin goals in following manner from directory containing project POM file.

mvn com.oracle.servicebus.plugin:oracle-servicebus-plugin:package

mvn com.oracle.servicebus.plugin:oracle-servicebus-plugin:deploy**

You can observe goal prefix as servicebus, when you describe Service Bus Plugin as shown below.

osbgoalprefix

so you can execute all goals simply using this goal prefix as below.

mvn servicebus:package

mvn servicebus:deploy**

 

**Currently facing issue with deploy goal.

 

Notes:

  • Use double quotes in the maven commands like below if you are seeing the error mentioned in think link.

mvn install:install-file “-DpomFile=oracle-maven-sync-12.1.3.pom” “-Dfile=oracle-maven-sync-12.1.3.jar” “-DoracleHome=C:/Oracle/Middleware/FMW1213New”

  • Seems to be OSB maven functionality is broken in 12.2.1. Refer to following blog talking about this.

https://rhpatrickblog.wordpress.com/2015/11/11/restoring-osb-12-2-1-maven-functionality/

http://www.avioconsulting.com/blog/osb-12212-maven-fixes

SOA 12c–EDN with Service Bus

In this post, I just want to present an idea on how to make Service Bus work with EDN in SOA Suite 12c. For demonstration purpose, I will consider Durable Subscriber functionality introduced in 12c.

You can download the SOA and Service Bus projects here and here.

My setup includes 2 business events Create Order and Update Order and have the following durable subscribers created because of SOA Composites. Refer to these articles for more information on EDN. Note that, Client ID is different as mentioned below based on the consistency level used for the event subscription.

       For Guaranteed   -> edn_wljsm_localtx_client

       For OneandOnlyOne   -> edn_wljsm_xa_client

Main idea is to create a durable subscriber for our Proxy Service similar to the ones shown below. So note down Client ID and Message Selector shown below and use it in our Proxy Service configuration. Here we are subscribing our Proxy Service to Create Order business event.

soasubscr1

soasubscrmsgslet

Now create Proxy Service and set Endpoint URI in Transport tab as shown below. EDN uses EDN Topic for storing and delivering the EDN messages to subscribers.

topicps1

Give the Message Selector and Client ID noted in previous step in Transport Details tab as shown below and select Durable Subscription option.

topicps2

Deploy you Service Bus project and observe that another durable subscriber has been created for Proxy Service as shown below.

osbdura1

To make sure that things are working as expected, push the message read by Proxy service to other JMS queue. Here I created queue named CustomJmsQ and following screenshot shows no messages are pushed yet.

customqmsg

Raise the Create Order business event from SOA Composite. And you can observe that message payload have been inserted into JMS queue.

custommsgaftrtest

evntpayloadjms

Shut down OSB managed server and observe status of  durable subscriber. As shown below the Active status is shown as false indicating that Proxy service is not longer ready to accept messages.

osbinactive

Again raise the Create Order business event. And now you can observe that message is shown in Current Count means not yet delivered to Proxy Service.

pendingmsg

pendingmsg1

Now restart your OSB managed server navigate to CustomJmsQ. Now you can observe 2 messages in this queue including the latest one as shown below.

osbsrvrrestart1

osbsrvrrestart2

Now Un-deploy Service Bus project. And you can observe that corresponding durable subscriber is deleted too.

Remember the following:

  • EDN bus comes with SOA server, so you may not be able to use EDN in OSB only deployments.
  • Since there is no native support for business events in service bus, we will not be able to set any consistency levels and even the retry would not happen similar to SOA composites.
  • Here we directly gave Endpoint URI of Proxy Service to point to EDNTopic residing different server. Ideally, you may have to go for foreign server.
  • Finally, I have not verified the same with client edn_wlsjms_xa_client. Please let me know in comments when you try.

Service Bus 12c- Mixing URI Parameters and Payload in REST Service

Typically, a PUT request URI looks like below accepting the actual payload in HTTP body.

http://host:port/employeesApi/Employees/{employeeId}

In Service Bus12c, We cannot mix URI parameters with representation of the resource, when we want to define a resource in this way.

put

If we run Proxy Service with this setup, we will get an error as shown below.

put1

put2

put3

Instead, you can use the expression as shown below.

put4

You can access this using the following expression from your message flow.

$inbound/ctx:transport/ctx:request/tp:user-metadata[@name=”empid”]/@value

If you log $body and above expression, you would see the log messages as shown below.

put5

put6

As explained in this link, you may have to populate these URI parameters in outbound variable.

Service Bus 12c – REST enabled Business Services

In this post, you will learn to create REST enabled business services. We will create business service to call the Proxy Service created in previous post.

You can create Business Services directly using WADL if it’s available, or using REST binding wizard similar to Proxy Services. As mentioned earlier, REST Business services convert payload from SOAP to REST i.e. the internal interface is still based on WSDL, while the external business and proxy services expose REST endpoints.

Using WADL:

Drag REST binding into External Services swim lane in Service Bus overview editor as shown below.

restcmp_thumb2

bizrest1

Give name as EmployeeBS and Base URI and choose the option as shown below in Operation binding.

bizrest2

Select the WADL as shown below. You can also observe that you can choose resource from several places including MDS.

bizrest3

Click OK and verify that Operation Bindings are populated as shown below.

bizrest4

Click OK to finish the Business service creation.

Using REST Binding:

The steps for creating REST binding for business service are similar to Proxy Service. So follow the steps mentioned in section Creating REST Binding of previous post except giving the base URI.

Testing:

Run the business service and you will observe both SOAP and REST interfaces as shown below along with available operations.

testbiz

testbiz1

/Employees Resource:

GET:

getxml

getxml1

getjson1

getjson2

POST:

postxml1

postxml2

postjson1

postjson2

PUT:

putxml

putxml2

putjson1

putjson2

/Employees/{employeeId} Resource:

GET:

getxml2

getxml3

getjson3

getjson4

DELETE:

deletexml

deletexml.1jpg

deletejson

deletejson2

Similarly, you can run SOAP interface of business service by choosing operation and observe the output.

Service Bus 12c – REST enabled Proxy Services

Note: This post is based on SOA 12.1.3 release.

In this post, you will learn to expose Proxy Services as REST services. We will use Employees table and come up with REST API that can be used to perform CRUD operations.

This post assumes knowledge of DB connection pool setup and Pipelines.

Creating Business Service

Create the business service using DB Adapter with the help of following steps.

dbadapter1

dbadapter2

dbadapter3

dbadapter4

dbadapter5

dbadapter6

dbadapter7

dbadapter8

dbadapter9

dbadapter10

dbadapter11

dbadapter12

dbadapter13jpg

dbadapter14

Click Finish and verify that business service has been created as shown below.

filexp

Refactor all the artifacts to BusinessService directory.

filexp1

Now you can test business service alone to make sure that all operations are working fine as expected. You can refer to this post for detailed steps.

Creating REST Binding

We want our REST resource to support the following operations:

Resource

HTTP Verb

Resource URIs

Desription

Employees GET /Employees Get all employees
GET /Employees/{employeeId} Get an employee represented by Employee ID.
POST /Employees Create new employee
PUT /Employees Update new employee
DELETE /Employees/{employeeId} Delete an employee represented by Employee ID.

In Service Bus 12c, REST proxy services convert REST native payload to SOAP before invoking a pipeline or split-join, while REST business services convert payload from SOAP to REST. That means, the internal interface is still based on WSDL, while the external business and proxy services expose REST endpoints. This will be evident in later steps as service bus creates both WADL and WSDL files and each resource is mapped to different operations defined in WSDL.

Drag REST binding into Proxy Services swim lane in Service Bus overview editor as shown below.

restcmp

proxy1

This brings up Create REST binding window. Give the name as shown below.

restbind1

Click + icon for Resources to add new resource and click OK.

restbind2

Similarly add another resource /Employees/{employeeId}. Now your resources should look like below.

restbind3

Now you have to create the corresponding Operation Bindings which in turn creates WSDL with these operations.

Operation Bindings for resource /Employees:

Use the following steps to create GET mapping.

restbind4

get1

get2

Here we are selecting both XML and JSON as we want our API to support both content types. Click on highlighted icon to define schema on fly representing the output payload. Enter file name and give directory name as ProxyService as shown below.

xsd1

Click Next and choose file type as JSON.

xsd2

Click Next and give Target namespace and Root element as shown below and you can use the following JSON payload sample.

{
“Employee” : [{
“employeeId”: “100”,
“firstName”: “fname”,
“lastName”: “lname”,
“email”: “fn@gmail.com”,
“phoneNumber”: “9848012345”,
“jobId”: “100”,
“salary”: “100”,
“commissionPct”: “100”,
“managerId”: “100”,
“departmentId”: “100”
},
{
“employeeId”: “101”,
“firstName”: “fname1”,
“lastName”: “lname1”,
“email”: “fn1@gmail.com”,
“phoneNumber”: “9848012345”,
“jobId”: “100”,
“salary”: “100”,
“commissionPct”: “100”,
“managerId”: “101”,
“departmentId”: “101”
}]
}

xsd3

Click Next and verify the schema that gets generated.

xsd4

Click Next and Finish and verify that schema URL is populated in Response tab.

restbind5

Click OK and verify Operation Bindings are populated as shown below.

restbind6

Use the following steps to create POST mapping by reusing existing schema.

post1

post2

post3

post4

post2

post5

Similarly, finish mapping for PUT and use operation name as updateEmployee. Now your Create REST binding window should look like below.

3ops

Click OK. You will observe that Proxy Service, WADL and WSDL have been  created as expected.

filexp2

You will also observe errors, as XSD file is created in ProxyService folder whereas WADL and WSDL got created in Resources folder. So open WADL and WSDL files and modify the XSD reference as shown below to resolve errors.

wadl

wsdl

Operation Bindings for resource /Employees/{employeeId}:

You should reuse the schema created in above steps for this resource as well.

Now in Service Bus overview editor, right click EmployeeService and select Edit REST as shown below.

editrest

Use the following steps to create GET mapping.

rsrcget5

empkey1

You can leave schema for request as it is so that it will be defaulted by the wizard.

rsrcget3

post2

rsrcget4

Click OK and your Update Service window should look like below.

rest1

Similarly finish DELETE method by using operation name as deleteEmployee and now your Update Service window should look like below.

allbinds

Click OK and observe the WADL and WSDL files that got updated with your new operation bindings. If you observe that WADL is not updated just do refresh as shown below.

refresh

WADL:

wadl1

WSDL:

wsdl1

 

With this, you have finished the REST interface that is exposed to consumers.

Creating Pipeline:

Create new pipeline EmployeePipeline using EmployeeService.wsdl as shown below.

pipeline1

pipeline2

Connect EmployeeServcie proxy service with EmployeePipeline in Service Bus overview editor as shown below.

soverview1

We will not discuss much about finishing the message flow in pipeline as it’s nothing different from regular scenario. You can find the Service Bus project here i.e. used for demonstration purpose in this post.

Testing:

In test console, you can observe that Accept http header shows both application/xml and application/json i.e. now your REST service supports both xml and json data formats.

GET With application/xml:

gettetsing1

gettetsing2

GET With application/json:

gettetsing3

gettetsing4

POST With application/xml:

posttest1

posttest2

POST With application/json:

posttest3

posttest4

You can observe that both records have been inserted as expected.

posttest5

PUT With application/xml:

puttest1

puttest2

PUT With application/json:

puttest3

puttest4

You can observe that both records have been updated as expected.

puttest5

Resource /Employees/{employeeId}:

GET With application/xml:

getkeytest1

getkeytest2

GET With application/json:

getkeytest3

getkeytest4

DELETE With application/xml:

deltest1

deltest2

DELETE With application/json:

deltest3

deltest4

You can observe that both records have been deleted as expected.

deltest5

If you want to expose SOAP interface as well, then you just need to create another Proxy Service and join EmployeePipeline as shown below.

soaprest

Notes:

  • We did not talk about fault handling specific details here.
  • It’s always recommended not to do blind GET as we may see performance issues when large number of records are there.
  • As an exercise, you can come up with resource emulating QBE on db.

References:

https://docs.oracle.com/middleware/1213/osb/develop/GUID-C346DF7D-041D-4E10-BE1C-451F50719106.htm#OSBDV88210


Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 196 other subscribers

Enter your email address to follow this blog and receive notifications of new posts by email.