Thursday, October 3, 2019

12c SOA - Invoke get rest soa service from SOA composite using REST adapter

Here i will show you how to invoke get rest soa service from another SOA composite using REST adapter.In my previous post, i have created the following expose get rest service. In this blog, i will use this service WADL.
Service WADL:
http://hostname:8001/soa-infra/resources/POC/GetRestCustomerProject!1.0/GetCustomerService/application.wadl
Implementation:
Drag a rest adapter in the external references swim lane and provide Name, Type as Reference and checked the Reference will be invoked by components using WSDL interface option
 Click on Configuration shortcut plus sign to add the wadl service.
 Put the WADL in the selection and press enter key
 Parsing WADL
 It has parsed the WADL and fetched all the required resource path and operation details.
 Check for Localize external references.
 Rest adpater is ready to be invoked.
 Create a Synchronous BPEL
 Wire the rest adapter
 In the BPEL, Assign the input and output to/from to rest adpater.
 Test from em console.


Tuesday, October 1, 2019

12c SOA - Expose Post Rest SOA service using REST adapter and test from SoapUI and PostMaster

Create a XSD to expose rest service. Here I have created a synchronous request-response interaction service.
XSD used:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cust.abc"
            targetNamespace="http://www.cust.abc" elementFormDefault="qualified">
  <xsd:element name="CustomersReq">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Customer" maxOccurs="unbounded">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="ID" type="xsd:string"/>
              <xsd:element name="Name" type="xsd:string"/>
              <xsd:element name="Address" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
   <xsd:element name="CustomersRes">
    <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Outcome" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Drag a rest adapter in the left exposing swim lane. Provide the Name, Type as Service and checked in the service will invoke components using wsdl interfaces option.
Provide the Description and resource path name and click on the plus sign to add the operation, HTTP verb and other details.
Provide the operation name, created resource path, HTTP verb as POST and Request and response schema elements.
Request schema element is selected
Response schema element is selected and you can select response payload format as selected  JSON, XML, URL encoded etc.
 Create a BPEL and map the response.
Testing:
Format of the URL for testing:
Take the .wadl file from em console and remove the application.wadl words and add the resource path name.
Here,
WADL:https://uadcc-elmweb02:7002/soa-infra/resources/POC/LoopInBPELProject!1.0/RestService/application.wadl
Resource path:abc
so the url will be :

https://uadcc-elmweb02:7002/soa-infra/resources/POC/LoopInBPELProject!1.0/RestService/abc

Test from SOAP UI:
Payload:
<CustomersReq xmlns="http://www.cust.abc">
   <Customer>
      <ID>ID10</ID>
      <Name>Name11</Name>
      <Address>Address12</Address>
   </Customer>

</CustomersReq>

 Test from Post Master:

12c SOA - Expose Get Rest SOA service and test from browser, SoapUi and PostMaster

Create a XSD to expose rest service. Here i have created a synchronous request-response interaction service.
XSD used:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cust.abc"
            targetNamespace="http://www.cust.abc" elementFormDefault="qualified">
  <xsd:element name="CustomersReq">
    <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="ID" type="xsd:string"/>
              <xsd:element name="Name" type="xsd:string"/>
              <xsd:element name="Address" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
  </xsd:element>
   <xsd:element name="CustomersRes">
    <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Outcome" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Drag a rest adapter in the left exposing swim lane. Provide the Name, Type as Service and checked in the service will invoke components using wsdl interfaces option.
Provide the Description and resource path name and click on the plus sign to add the operation, HTTP verb and other details.
 Provide the resource path name
Provide the operation name, created resource path, HTTP verb as GET and Request and response schema elements.
Request schema element is selected
Response schema element is selected and you can select response payload format as selected  JSON, XML, URL encoded etc.
Create a BPEL and wire them
 In the BPEL, take a assign activity and map


Testing:
Format of the URL for testing:
Take the .wadl file from em console and remove the application.wadl words and add the resource path name.
Here,
WADL:https://hostname:7002/soa-infra/resources/POC/GetRestCustomerProject!1.0/GetCustomerService/application.wadl
Resource path:Cust
so the url will be :
https://hostname:7002/soa-infra/resources/POC/GetRestCustomerProject!1.0/GetCustomerService/Cust

Test from SOAP UI:
Use the above URL and add the request parameters.
Test from Post Master:
Use the above URL and add the request parameters.

Test from Browser appending the request parameters:
http://hostname:8001/soa-infra/resources/POC/GetRestCustomerProject!1.0/GetCustomerService/Cust?ID=123&Name=Name14&Address=asda


Monday, September 30, 2019

Database - schedule using DBMS JOB

DBMS JOB is a job scheduler package which schedules and manages jobs in the job queue.
Use case:
Creating a job(execute hourly) which calls a package and procedure to update the polling_status field of the table from 1 to 2, then these table records become candidates for the SOA db polling and further processing. also, update the job execution from hourly to daily once.

To check the existing jobs:
Select * from user_jobs;
Create the required table, package and procedure.
Query to create table:
 CREATE TABLE customers
( customer_id number(10) NOT NULL,
  customer_name varchar2(50) NOT NULL,
  city varchar2(50),
  polling_status number(2),
  eligble_for_credits varchar2(10),
  processing_status varchar2(50)
);
Package Specification:
create or replace PACKAGE "CUSTOMEREVENTLOG"
AS
PROCEDURE UPDATE_POLLING_STATUS;       
END CUSTOMEREVENTLOG;
Package body:
create or replace PACKAGE BODY "CUSTOMEREVENTLOG"
AS
PROCEDURE UPDATE_POLLING_STATUS
AS
BEGIN
  UPDATE customers
  SET POLLING_STATUS = '2'
  WHERE POLLING_STATUS = '1';
END  UPDATE_POLLING_STATUS;
END CUSTOMEREVENTLOG;

Query to create JOB:
To submit a job to the job queue, use the following syntax:
DBMS_JOB.SUBMIT(
   job       OUT    BINARY_INTEGER,
   what      IN     VARCHAR2,
   next_date IN     DATE DEFAULT SYSDATE,
   interval  IN     VARCHAR2 DEFAULT 'NULL',
   no_parse  IN     BOOLEAN DEFAULT FALSE,
   instance  IN     BINARY_INTEGER DEFAULT ANY_INSTANCE,
   force     IN     BOOLEAN DEFAULT FALSE);

*JOB: This is the identifier assigned to the job you created. You must use this job number whenever you want to alter or remove the job.
*WHAT: This is the PL/SQL code you want to have executed. The WHAT parameter must end with a semi-colon.
*NEXT_DATE: The next date when the job will be run. The default value is SYSDATE.
*INTERVAL: The date function that calculates the next time to execute the job. The default value is NULL. INTERVAL must evaluate to a future point in time or NULL. This parameter is a VARCHAR2 and must be enclosed in single quotes.
*NO_PARSE: This is a flag. If NO_PARSE is set to FALSE (the default), Oracle parses the procedure associated with the job. If NO_PARSE is set to TRUE, Oracle parses the procedure associated with the job the first time that the job is executed. If, for example, you want to submit a job before you have created the tables associated with the job, set NO_PARSE to TRUE.
*Instance and Force: Use the parameters instance and force to control job and instance affinity. The default value of instance is 0 (zero) to indicate that any instance can execute the job. To run the job on a certain instance, specify the instance value. Oracle displays error ORA-23319 if the instance value is a negative number or NULL.The force parameter defaults to false. If force is TRUE, any positive integer is acceptable as the job instance. If force is FALSE, the specified instance must be running, or Oracle displays error number ORA-23428.

Created Job:
DECLARE
  v_numjob NUMBER := 111;
BEGIN
 DBMS_JOB.SUBMIT(v_numjob,'CUSTOMEREVENTLOG.UPDATE_POLLING_STATUS();',sysdate,'sysdate+1/24');
END;
/
Job execute Hourly
Wait 1 hour and check the result:
DBMS job runs and it updated the polling status from 1 to 2.


Enable/disable oracle job using job id:
Disable:
begin
  dbms_job.broken(101, true);
  commit;
end;
/
Enable:
begin
  dbms_job.broken(101, false);
  commit;
end;
/
**Broken =N means start and Broken =Y means stop job

Job Intervals examples
Execute daily          'SYSDATE + 1'
Execute once per week  'SYSDATE + 7'
Execute hourly         'SYSDATE + 1/24'
Execute every 10 min.  'SYSDATE + 10/1440'
Execute every 30 sec.  'SYSDATE + 30/86400'

DBMS_JOB.CHANGE
To alter user-definable parameters associated with a job, use the following syntax:

DBMS_JOB.CHANGE(  JOB IN BINARY_INTEGER,
   what                  IN VARCHAR2 DEFAULT NULL,
   next_date             IN DATE DEFAULT NULL,
   interval              IN VARCHAR2 DEFAULT NULL,
   instance              IN BINARY_INTEGER DEFAULT NULL,
   force                 IN BOOLEAN DEFAULT FALSE );

Example:  To execute daily
DECLARE
BEGIN
DBMS_JOB.CHANGE(101,'CUSTOMEREVENTLOG.UPDATE_POLLING_STATUS();',sysdate,'sysdate+1');
COMMIT;
END;
/
For more details click here Oracle-Help-Center.
You can also schedule using DBMS_SCHEDULER. Fore more details click here DBMS_SCHEDULER.

Friday, September 27, 2019

SOA 12c - Create Integrated weblogic server default domain

To create the default domain, go to Window⇾Application Servers
 Right click on IntegratedWebLogicServer and click on Create Default Domain.
 Enter the domain password and accept defaults.
Domain is building now.
Start the server

Open the http://localhost:7101/console.

12c SOA - How to test Xquery from Jdeveloper

Step1: Open the Xquery in source mode and right click and click Run Xquery option.
Step2: For source variables which called the List of variables to bind, have to provide the xml inputs to test.
Step3: Here Choose Generate XML by Schema option and select Set XML Occurrence to 1 then select Save Generated XML to file and choose the input file.
 Step4: Click Add to sequence and OK.
 Step5: Give a target file name where u can see the output and click the Run button.
 Bang! You can see the output.

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...