ตัวอย่างการใช้งาน Service Callout และ Publish (XQuery transformation)
Prepare database
EMPLOYEE
Column
|
Datatype
|
Nullable
|
EMP_ID
|
NUMBER(22)
|
False
|
EMP_FIRSTNAME
|
VARCHAR2(50)
|
False
|
EMP_SURNAME
|
VARCHAR2(50)
|
True
|
OU_ID
|
NUMBER(22)
|
False
|
BIRTH_DATE
|
DATE
|
True
|
NATIONAL_ID
|
CHAR(13)
|
False
|
EMPLOYEE_BAK
Column
|
Datatype
|
Nullable
|
ID
|
NUMBER(22)
|
True
|
FIRSTNAME
|
VARCHAR2(50)
|
True
|
SURNAME
|
VARCHAR2(50)
|
True
|
OU_ID
|
NUMBER(22)
|
True
|
BIRTH_DATE
|
DATE
|
True
|
NATIONAL_ID
|
CHAR(13)
|
True
|
insertEmployee
CREATE OR REPLACE PROCEDURE OSBDEMO.insertEmployee(
p_emp_firstname IN EMPLOYEE.EMP_FIRSTNAME%TYPE,
p_emp_surname IN EMPLOYEE.EMP_SURNAME%TYPE,
p_ou_id IN EMPLOYEE.OU_ID%TYPE,
p_birth_date IN EMPLOYEE.BIRTH_DATE%TYPE,
p_national_id IN EMPLOYEE.NATIONAL_ID%TYPE)
IS
BEGIN
INSERT INTO OSBDEMO.EMPLOYEE ("EMP_ID", "EMP_FIRSTNAME", "EMP_SURNAME", "OU_ID", "BIRTH_DATE", "NATIONAL_ID")
VALUES (EMP_SEQ.NEXTVAL, p_emp_firstname,p_emp_surname, p_ou_id, p_birth_date, p_national_id);
END;
|
Artifact files
Inbound
|
Files
|
Schema
|
xsd/CopyEmployeeService.xsd
|
WSDL
|
CopyEmployeeService.wsdl
|
Proxy Service
|
CopyEmployeeProxyService2.proxy
|
Outbound (AddNewEmployee)
|
Files
|
WSDL
|
NewEmployeeService.wsdl
|
JCA config files
|
NewEmployeeService_db.jca
|
Schema
|
xsd/NewEmployeeService_sp.xsd
|
Business Service
|
NewEmployeeService_db.biz
NewEmployeeService_db.wsdl
|
Outbound (QueryAllEmployee)
|
Files
|
WSDL
|
QueryEmployeeService1.wsdl
|
JCA config files
|
QueryEmployeeService1_db.jca
|
Schema
|
xsd/QueryEmployeeService1.xsd
|
Business Service
|
QueryEmployeeService1_db.biz
QueryEmployeeService1_db.wsdl
|
Outbound (ReplicaAllEmployee)
|
Files
|
WSDL
|
MergeEmployeeService1.wsdl
|
JCA config files
|
MergeEmployeeService1_db.jca
MergeEmployeeService1-or-mappings.xml
MergeEmployeeService1-properties.xml
|
Schema
|
MergeEmployeeService1_table.xsd
|
Business Service
|
MergeEmployeeService1_db.biz
MergeEmployeeService1_db.wsdl
|
XQuery transformation
From
|
To
|
Files
|
Inbound
|
AddNewEmployee
|
CopyEmployeeProxyService_To_NewEmployeeService.xq
|
Inbound
|
QueryAllEmployee
|
CopyEmployeeProxyService_To_QueryEmployeeService1.xq
|
QueryAllEmployee
|
ReplicaAllEmployee
|
QueryEmployeeService1_To_MergeEmployeeService1.xq
|
XQuery Transformation =>
Create new XQuery transformation
CopyEmployeeProxyService_To_NewEmployeeService.xq



(:: pragma bea:global-element-parameter parameter="$copyEmployeeRequest1" element="ns1:CopyEmployeeRequest" location="../xsd/CopyEmployeeService.xsd" ::)
(:: pragma bea:global-element-return element="ns0:InputParameters" location="../../Adapter/xsd/NewEmployeeService_sp.xsd" ::)
declare namespace ns1 = "http://www.soabpm-vm.com/SOATrainingSamples/TransactionalInsert/xsd/CopyEmployeeService";
declare namespace ns0 = "http://xmlns.oracle.com/pcbpel/adapter/db/sp/NewEmployeeService";
declare namespace xf = "http://tempuri.org/DatabaseTX1/Service/xq/CopyEmployeeProxyService_To_NewEmployeeService/";
declare function xf:CopyEmployeeProxyService_To_NewEmployeeService($copyEmployeeRequest1 as element(ns1:CopyEmployeeRequest))
as element(ns0:InputParameters) {
<ns0:InputParameters>
<ns0:P_EMP_FIRSTNAME>{ data($copyEmployeeRequest1/ns1:CopyEmployeeRequestInput[1]/ns1:EMP_FIRSTNAME) }</ns0:P_EMP_FIRSTNAME>
<ns0:P_EMP_SURNAME>{ data($copyEmployeeRequest1/ns1:CopyEmployeeRequestInput[1]/ns1:EMP_SURNAME) }</ns0:P_EMP_SURNAME>
<ns0:P_OU_ID>{ data($copyEmployeeRequest1/ns1:CopyEmployeeRequestInput[1]/ns1:OU_ID) }</ns0:P_OU_ID>
<ns0:P_BIRTH_DATE>{ data($copyEmployeeRequest1/ns1:CopyEmployeeRequestInput[1]/ns1:BIRTH_DATE) }</ns0:P_BIRTH_DATE>
<ns0:P_NATIONAL_ID>{ data($copyEmployeeRequest1/ns1:CopyEmployeeRequestInput[1]/ns1:NATIONAL_ID) }</ns0:P_NATIONAL_ID>
</ns0:InputParameters>
};
declare variable $copyEmployeeRequest1 as element(ns1:CopyEmployeeRequest) external;
xf:CopyEmployeeProxyService_To_NewEmployeeService($copyEmployeeRequest1)
|
CopyEmployeeProxyService_To_QueryEmployeeService1.xq


xquery version "1.0" encoding "Cp1252";
(:: pragma bea:global-element-parameter parameter="$copyEmployeeRequest1" element="ns0:CopyEmployeeRequest" location="../xsd/CopyEmployeeService.xsd" ::)
(:: pragma bea:global-element-return element="ns1:QueryEmployeeService1Input" location="../../Adapter/xsd/QueryEmployeeService1.xsd" ::)
declare namespace xf = "http://tempuri.org/DatabaseTX1/Service/xq/CopyEmployeeProxyService_To_QueryEmployeeService1/";
declare namespace ns1 = "http://xmlns.oracle.com/pcbpel/adapter/db/QueryEmployeeService1";
declare namespace ns0 = "http://www.soabpm-vm.com/SOATrainingSamples/TransactionalInsert/xsd/CopyEmployeeService";
declare function xf:CopyEmployeeProxyService_To_QueryEmployeeService1($copyEmployeeRequest1 as element(ns0:CopyEmployeeRequest))
as element(ns1:QueryEmployeeService1Input) {
<ns1:QueryEmployeeService1Input/>
};
declare variable $copyEmployeeRequest1 as element(ns0:CopyEmployeeRequest) external;
xf:CopyEmployeeProxyService_To_QueryEmployeeService1($copyEmployeeRequest1)
|
QueryEmployeeService1_To_MergeEmployeeService1.xq

ลากเส้นตามลำดับ 1-7 (parent หา child) เนื่องจาก OEPE จะสร้าง for loop ใน code
(:: pragma bea:global-element-parameter parameter="$queryEmployeeService1OutputCollection1" element="ns1:QueryEmployeeService1OutputCollection" location="../../Adapter/xsd/QueryEmployeeService1.xsd" ::)
(:: pragma bea:global-element-return element="ns0:EmployeeBakCollection" location="../../Adapter/xsd/MergeEmployeeService1_table.xsd" ::)
declare namespace ns1 = "http://xmlns.oracle.com/pcbpel/adapter/db/QueryEmployeeService1";
declare namespace ns0 = "http://xmlns.oracle.com/pcbpel/adapter/db/top/MergeEmployeeService1";
declare namespace xf = "http://tempuri.org/DatabaseTX1/Service/xq/QueryEmployeeService1_To_MergeEmployeeService1/";
declare function xf:QueryEmployeeService1_To_MergeEmployeeService1($queryEmployeeService1OutputCollection1 as element(ns1:QueryEmployeeService1OutputCollection))
as element(ns0:EmployeeBakCollection) {
<ns0:EmployeeBakCollection>
{
for $QueryEmployeeService1Output in $queryEmployeeService1OutputCollection1/ns1:QueryEmployeeService1Output
return
<ns0:EmployeeBak>
<ns0:id>{ data($QueryEmployeeService1Output/ns1:EMP_ID) }</ns0:id>
<ns0:firstname>{ data($QueryEmployeeService1Output/ns1:EMP_FIRSTNAME) }</ns0:firstname>
<ns0:surname>{ data($QueryEmployeeService1Output/ns1:EMP_SURNAME) }</ns0:surname>
<ns0:ouId>{ data($QueryEmployeeService1Output/ns1:OU_ID) }</ns0:ouId>
<ns0:birthDate>{ data($QueryEmployeeService1Output/ns1:BIRTH_DATE) }</ns0:birthDate>
<ns0:nationalId>{ data($QueryEmployeeService1Output/ns1:NATIONAL_ID) }</ns0:nationalId>
</ns0:EmployeeBak>
}
</ns0:EmployeeBakCollection>
};
declare variable $queryEmployeeService1OutputCollection1 as element(ns1:QueryEmployeeService1OutputCollection) external;
xf:QueryEmployeeService1_To_MergeEmployeeService1($queryEmployeeService1OutputCollection1)
|
สร้าง Proxy Service

ประกอบด้วย 3 stage 1) NewEmployee 2) Query และ 3) Replicate
Stage 1
Stage 2




Stage 3




================
Good Luck.
================
No comments:
Post a Comment