Difference between revisions of "GVExample CCardPay"

From GreenVulcano Wiki
Jump to: navigation, search
Line 1: Line 1:
 
==Description==
 
==Description==
  
This service has the scope of showing how {{GVESB}} uses [[Data Handler]] for querying a DB and implements a [[Web Services]].
+
This service has the scope of showing how {{GVESB}} uses [[DataHandler]] for querying a DB and implements a [[Web Services]].
  
 
CCardPay Service executes the following operations:
 
CCardPay Service executes the following operations:
 
# Receives a request [[Web Services|Web Service]] from client, with a credit card number to be controlled.
 
# Receives a request [[Web Services|Web Service]] from client, with a credit card number to be controlled.
# If this card is locally managed, reads the data using [[Data Handler]].  
+
# If this card is locally managed, reads the data using [[DataHandler]].  
 
# If this card is managed by an external system, forwards a Web Service request to that system.
 
# If this card is managed by an external system, forwards a Web Service request to that system.
 
# Returns the response to the client
 
# Returns the response to the client
Line 34: Line 34:
 
| name || DataHandler
 
| name || DataHandler
 
|-
 
|-
| DBOBuilder || name="CREDIT::CCardPay" <br/> jdbc-connection-name="ds.test_gv" <br/>  
+
| [[dh-call]]/DBOBuilder || name="CREDIT::CCardPay" <br/> jdbc-connection-name="ds.test_gv" <br/>  
 
DHVariables:
 
DHVariables:
 
: name="decimal-separator" value="."
 
: name="decimal-separator" value="."
Line 40: Line 40:
 
: name="format" value="#0.00"
 
: name="format" value="#0.00"
 
|-
 
|-
| DBOBuilder/ DBOSelect || name="CCardPay"  <br/> transformation="CCardPay"  <br/> type="dbo" <br/>statement id="1" <br/>
+
| [[dh-call]]/DBOBuilder/DBOUpdate || name="CCardPay"  <br/> transformation="CCardPay"  <br/> type="dbo" <br/>statement id="0" <br/>
type="select" <br/>  
+
type="update" <br/>  
 
  update CREDIT_CARD  set CREDIT= CREDIT - ?
 
  update CREDIT_CARD  set CREDIT= CREDIT - ?
 
  where CNUMBER=?
 
  where CNUMBER=?
Line 48: Line 48:
 
|}
 
|}
  
The operation defined in the DataHandler makes use of the ''data-transformation'' module for the data transformations that allow to have data in XML format. So, you need to define the following parameters into the [[GVDataTransformation]] section:
+
The operation defined in the DataHandler makes use of the ''data-transformation'' module for the data transformations that allows to have data in XML format. So, you need to define the following parameters into the [[GVDataTransformation]] section:
 
{|class="gvtable"
 
{|class="gvtable"
 
! Element !! Attributes
 
! Element !! Attributes
Line 54: Line 54:
 
| [[GVDataTransformation#DataSourceSet|DataSourceSet]]/[[GVDataTransformation#LocalFSDataSource|LocalFSDataSource]] || formatHandled="xsl" name="XSLDataSource" <br/> repositoryHome=<nowiki>"${{gv.app.home}}/gvdte/datasource/xsl"</nowiki> <br/> type="datasource"  
 
| [[GVDataTransformation#DataSourceSet|DataSourceSet]]/[[GVDataTransformation#LocalFSDataSource|LocalFSDataSource]] || formatHandled="xsl" name="XSLDataSource" <br/> repositoryHome=<nowiki>"${{gv.app.home}}/gvdte/datasource/xsl"</nowiki> <br/> type="datasource"  
 
|-
 
|-
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="CCardQuery" DataSourceSet="Default"  <br/> XSLMapName="DataHandler/CREDIT/[[CCardQuery.xsl]]"<br/> type="transformation"
+
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="CCardPay" DataSourceSet="Default"  <br/> XSLMapName="DataHandler/CREDIT/[[CCardPay.xsl]]"<br/> type="transformation"
 
|-
 
|-
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalInput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalInput.xsl]]"  <br/> type="transformation"
+
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="PayExternalInput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[PayExternalInput.xsl]]"  <br/> type="transformation"
 
|-
 
|-
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalOutput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalOutput.xsl]]" <br/> type="transformation"
+
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="PayExternalOutput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[PayExternalOutput.xsl]]" <br/> type="transformation"
 
|}
 
|}
  
Now control that the [[ws-call]] element attributes and subelements defined into [[System]] CREDIT_EXTERNAL -> [[Channel]] CHANNEL_CREDIT_EXT will be setted as:
+
Now define a [[ws-call]] operation into [[System]] CREDIT_EXTERNAL -> [[Channel]] CHANNEL_CREDIT_EXT. Its attributes and sub-elements defined will be setted as:
 
* [[ws-call]]:
 
* [[ws-call]]:
 
{|class="gvtable"
 
{|class="gvtable"
 
! Attribute !! Value  
 
! Attribute !! Value  
 
|-
 
|-
| Name || QueryExternal
+
| Name || PayExternal
 
|-
 
|-
| [[Ws-call#AxisWebServiceInvoker|AxisWebServiceInvoker]] || operation="Query" <br/> ref-dp="EXTERNAL::QueryWSDataProvider"<br/> returnType="body-element"<br/> type="invoker" <br/> WSDLInfo:
+
| [[Ws-call#AxisWebServiceInvoker|ws-call/AxisWebServiceInvoker]] || operation="Pay" <br/> ref-dp="EXTERNAL::PayWSDataProvider"<br/> returnType="body-element"<br/> type="invoker" <br/> WSDLInfo:
 
: type="wsdlinfo"
 
: type="wsdlinfo"
 
: wsdl="file://<nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl/[[ExternalCreditService.wsdl]]"
 
: wsdl="file://<nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl/[[ExternalCreditService.wsdl]]"
Line 75: Line 75:
 
===Flow implementation===
 
===Flow implementation===
  
[[File:GVExamplesCCardQueryFlow.jpg|thumb|CCardQuery flow]] In order to define the CCardQuery service [[Flow]] design it as shown in the picture:
+
[[File:GVExamplesCCardPayFlow.jpg|thumb|CCardPay flow]] In order to define the CCardPay service [[Flow]] design it as shown in the picture:
  
  
The service receives a Web Service request from a client with a credit card number. If this card is managed locally, reads its data using Data Handler, otherwise forwards the request to an external system using Web Service.
+
The service receives a Web Service request from a client with a credit card number. If this card is managed locally, reads its data using [[DataHandler]], otherwise forwards the request to an external system using [[Web Services]].
  
  
Line 101: Line 101:
 
: value="sql{{ds.test_gv::select decode(count(*), 1, 'true', 'false') from credit_card where number=ognl{{#object.getProperty('CNUMBER')}}}}"
 
: value="sql{{ds.test_gv::select decode(count(*), 1, 'true', 'false') from credit_card where number=ognl{{#object.getProperty('CNUMBER')}}}}"
 
|-
 
|-
| GVRouting || condition="isInternalCCard" <br/>next-node-id="search_internal"
+
| [[GVNodeCheck]] || default-id="pay_external"<br/> id="check_internal"<br/> input="input" <br/>on-exception-id="end"  
 
|-
 
|-
| [[GVOperationNode]] || dump-in-out="false"  <br/>id="search_internal" <br/>id-system="CREDIT" <br/>input="input" <br/>next-node-id="end" <br/>op-type="call" <br/>operation-name="DataHandler" <br/>output="output"
+
| [[GVNodeCheck]]/GVRouting || condition="isInternalCCard" <br/>next-node-id="search_internal"
 
|-
 
|-
| [[GVOperationNode]] || dump-in-out="false"  <br/> id="search_external"  <br/>id-system="CREDIT_EXTERNAL"  <br/> input="input"  <br/>next-node-id="end"  <br/>op-type="call"  <br/>operation-name="QueryExternal"  <br/>InputServices:
+
| [[GVOperationNode]] || dump-in-out="false"  <br/>id="pay_internal" <br/>id-system="CREDIT" <br/>input="input" <br/>next-node-id="end" <br/>op-type="call" <br/>operation-name="DataHandler" <br/>output="output"
 +
|-
 +
| [[GVOperationNode]] || dump-in-out="false"  <br/> id="pay_external"  <br/>id-system="CREDIT_EXTERNAL"  <br/> input="input"  <br/>next-node-id="end"  <br/>op-type="call"  <br/>operation-name="PayExternal"  <br/>InputServices:
 
: gvdte-service
 
: gvdte-service
 
: crtical="yes", internal="yes"
 
: crtical="yes", internal="yes"
 
: remove-fields="yes" type="service"
 
: remove-fields="yes" type="service"
 
: map-name-param:name="map-name" type="param"
 
: map-name-param:name="map-name" type="param"
: value="QueryExternalInput”
+
: value="PayExternalInput”
: name="QueryExternalInput
+
: name="PayExternalInput
 
OutputServices:
 
OutputServices:
 
: gvdte-service:
 
: gvdte-service:
Line 118: Line 120:
 
: map-name-param:
 
: map-name-param:
 
: name="map-name" type="param"
 
: name="map-name" type="param"
: value="QueryExternalOutput"
+
: value="PayExternalOutput"
: name="QueryExternalOutput"
+
: name="PayExternalOutput"
 
|-
 
|-
 
| [[GVEndNode]] || end-business-process="yes"  <br/>id="end"  <br/>op-type="end"  <br/>output="output"
 
| [[GVEndNode]] || end-business-process="yes"  <br/>id="end"  <br/>op-type="end"  <br/>output="output"
Line 131: Line 133:
 
# [[Starting|Start {{GVESB}}]]
 
# [[Starting|Start {{GVESB}}]]
 
# [[GV_Console#Access|Access to the {{GVCONSOLE}}]].  
 
# [[GV_Console#Access|Access to the {{GVCONSOLE}}]].  
# In the Deploy New Service section click Sfoglia... (Browse) and select the file where you have saved the {{VULCON}} configuration.
+
# In the Deploy New Service section click Sfoglia... (Browse) and select the file where you have saved the {{L_VULCON}} configuration.
 
# Click Submit.
 
# Click Submit.
  
 
The section [[Deploy_Service|Deploy Services]] will be open. In this section you can select the services you want to deploy.
 
The section [[Deploy_Service|Deploy Services]] will be open. In this section you can select the services you want to deploy.
# Clicking on service CCardQuery a new view will be open containing the files GVCore.xml present in local and in server.
+
# Clicking on service CCardPay a new view will be open containing the files GVCore.xml present in local and in server.
 
# Click Deploy. Now you can save the document and write some notes about it.
 
# Click Deploy. Now you can save the document and write some notes about it.
 
# Save the Document. Saving you return to the [[Deploy Service]] section.
 
# Save the Document. Saving you return to the [[Deploy Service]] section.
  
[[File:GVConsoleUtilityReload1.jpg|thumb|{{GVCONSOLE}} Utility section]]Now pass to the {{GVCONSOLE}} section [[Utility]].  
+
[[File:GVConsoleUtilityReload1.jpg|thumb|{{GVCONSOLE}} Utility section]]Now pass to the {{L_GVCONSOLE}} section [[Utility]].  
 
# Click on [[Reload_Configuration|Reload configuration]]
 
# Click on [[Reload_Configuration|Reload configuration]]
 
# Select GVCore.xml and GVAdapters.xml and then Reload. A new windows will be open to confirm the operation
 
# Select GVCore.xml and GVAdapters.xml and then Reload. A new windows will be open to confirm the operation
 
# Click OK.
 
# Click OK.
  
[[File:GVConsoleTesting.jpg|thumb|{{GVCONSOLE}} Testing section]]Go to the {{GVCONSOLE}} section [[Testing]]. In this section you can finally test your new services:
+
[[File:GVConsoleTesting.jpg|thumb|{{GVCONSOLE}} Testing section]]Go to the {{L_GVCONSOLE}} section [[Testing]]. In this section you can finally test your new services:
# Into the Service voice select CCardQuery
+
# Into the Service voice select CCardPay
 
# Into the System voice select CREDIT_EXTERNAL
 
# Into the System voice select CREDIT_EXTERNAL
 
# Select the Payload on input containing the credit card number you want to test
 
# Select the Payload on input containing the credit card number you want to test
Line 158: Line 160:
 
Standard Field:
 
Standard Field:
 
system  = CREDIT_EXTERNAL
 
system  = CREDIT_EXTERNAL
service  = CCardQuery
+
service  = CCardPay
 
id      = 7F0001014F3B87B900021429
 
id      = 7F0001014F3B87B900021429
 
retCode  = 0
 
retCode  = 0

Revision as of 09:57, 2 March 2012

Description

This service has the scope of showing how GreenVulcano® ESB uses DataHandler for querying a DB and implements a Web Services.

CCardPay Service executes the following operations:

  1. Receives a request Web Service from client, with a credit card number to be controlled.
  2. If this card is locally managed, reads the data using DataHandler.
  3. If this card is managed by an external system, forwards a Web Service request to that system.
  4. Returns the response to the client

VulCon Configuration

To configure CCardPay service follow these steps:

  1. Define Systems, Channels and Operations
  2. Define the Services
  3. Implement the flows.

Defining Systems, Channels and Operations

In order to define a System, go to VulCon core view and insert the System CREDIT. Inside of it create the Channel CHANNEL_CREDIT_WS in order to create an "internal" Participant. We also create the System CREDIT_EXTERNAL with the Channel CHANNEL_CREDIT_EXT corresponding to an "external" Participant.

Note that the easiest way to configure a Web service with VulCon® is using the Wizard. We start from a Web Service WSDL, that describes a withdrawal operation on a credit card.

From the Core view of VulCon®, right clicking the Services element, launch the Wizard Call Web Service and, after selecting the WSDL file -in this example we use ExternalCreditService.wsdl present in folder ${{gv.app.home}}/xmlconfig/wsdl-, choose the parameters to create the GreenVulcano® ESB service.

A two new Services, Pay and Query, and two ws-call operations, pay and query will be created into the System CREDIT, channel CREDIT_EXTERNAL. We changed those names to CCardPay and CCardQuery for the services, PayExternal and QueryExternal for the ws-call operations respectively. Now you can modify your workflow.

From the VulCon® Core view, element System "CREDIT" -> Channel "CHANNEL_CREDIT_WS", insert a dh-call operation and set its attributes and sub-elements as follow:

Attribute Value
name DataHandler
dh-call/DBOBuilder name="CREDIT::CCardPay"
jdbc-connection-name="ds.test_gv"

DHVariables:

name="decimal-separator" value="."
name="grouping-separator" value=","
name="format" value="#0.00"
dh-call/DBOBuilder/DBOUpdate name="CCardPay"
transformation="CCardPay"
type="dbo"
statement id="0"

type="update"

update CREDIT_CARD  set CREDIT= CREDIT - ?
where CNUMBER=?
   and ENABLED='Y'
   and CREDIT >= ?

The operation defined in the DataHandler makes use of the data-transformation module for the data transformations that allows to have data in XML format. So, you need to define the following parameters into the GVDataTransformation section:

Element Attributes
DataSourceSet/LocalFSDataSource formatHandled="xsl" name="XSLDataSource"
repositoryHome="${{gv.app.home}}/gvdte/datasource/xsl"
type="datasource"
XSLTransformation name="CCardPay" DataSourceSet="Default"
XSLMapName="DataHandler/CREDIT/CCardPay.xsl"
type="transformation"
XSLTransformation name="PayExternalInput" DataSourceSet="Default"
XSLMapName=" CREDIT_EXTERNAL/PayExternalInput.xsl"
type="transformation"
XSLTransformation name="PayExternalOutput" DataSourceSet="Default"
XSLMapName=" CREDIT_EXTERNAL/PayExternalOutput.xsl"
type="transformation"

Now define a ws-call operation into System CREDIT_EXTERNAL -> Channel CHANNEL_CREDIT_EXT. Its attributes and sub-elements defined will be setted as:

Attribute Value
Name PayExternal
ws-call/AxisWebServiceInvoker operation="Pay"
ref-dp="EXTERNAL::PayWSDataProvider"
returnType="body-element"
type="invoker"
WSDLInfo:
type="wsdlinfo"
wsdl="file://${{gv.app.home}}/xmlconfig/wsdl/ExternalCreditService.wsdl"

Flow implementation

CCardPay flow

In order to define the CCardPay service Flow design it as shown in the picture:


The service receives a Web Service request from a client with a credit card number. If this card is managed locally, reads its data using DataHandler, otherwise forwards the request to an external system using Web Services.


The following table shows the parameters to be defined for each Flow node:

Attribute Value
first-node Prepare
Conditions/GVBufferCondition condition="isInternalCCard"
Property:
name="IS_INTERNAL" operator="equal"
type="gvbuffer-field"
value="true"
value-type="text"
ChangeGVBufferNode dump-in-out="true"
id="prepare"
input="input"
next-node-id="check_internal"
clear-data="false"
PropertyDef:
name="CNUMBER"
value="js{{gvesb::var doc=XMLUtils.parseDOM_S(new java.lang.String(object.getObject()),false,true); XMLConfig.get(doc,'//cred:cnumber')}}"

PropertyDef:

name="IS_INTERNAL"
value="sql{{ds.test_gv::select decode(count(*), 1, 'true', 'false') from credit_card where number=ognl{{#object.getProperty('CNUMBER')}}}}"
GVNodeCheck default-id="pay_external"
id="check_internal"
input="input"
on-exception-id="end"
GVNodeCheck/GVRouting condition="isInternalCCard"
next-node-id="search_internal"
GVOperationNode dump-in-out="false"
id="pay_internal"
id-system="CREDIT"
input="input"
next-node-id="end"
op-type="call"
operation-name="DataHandler"
output="output"
GVOperationNode dump-in-out="false"
id="pay_external"
id-system="CREDIT_EXTERNAL"
input="input"
next-node-id="end"
op-type="call"
operation-name="PayExternal"
InputServices:
gvdte-service
crtical="yes", internal="yes"
remove-fields="yes" type="service"
map-name-param:name="map-name" type="param"
value="PayExternalInput”
name="PayExternalInput

OutputServices:

gvdte-service:
critical="yes" internal="yes"
remove-fields="yes" type="service"
map-name-param:
name="map-name" type="param"
value="PayExternalOutput"
name="PayExternalOutput"
GVEndNode end-business-process="yes"
id="end"
op-type="end"
output="output"

GV Console Configuration

It is time to deploy and test your new Service. To do that follows these steps:

Deploy new Service

Suppose you have saved the VulCon Configuration file as "${{gv.app.home}}/TEST/REPG1.zip". To deploy the new Service follow this steps:

  1. Start GreenVulcano® ESB
  2. Access to the GV Console.
  3. In the Deploy New Service section click Sfoglia... (Browse) and select the file where you have saved the VulCon® configuration.
  4. Click Submit.

The section Deploy Services will be open. In this section you can select the services you want to deploy.

  1. Clicking on service CCardPay a new view will be open containing the files GVCore.xml present in local and in server.
  2. Click Deploy. Now you can save the document and write some notes about it.
  3. Save the Document. Saving you return to the Deploy Service section.
GV Console Utility section

Now pass to the GV Console® section Utility.

  1. Click on Reload configuration
  2. Select GVCore.xml and GVAdapters.xml and then Reload. A new windows will be open to confirm the operation
  3. Click OK.
GV Console Testing section

Go to the GV Console® section Testing. In this section you can finally test your new services:

  1. Into the Service voice select CCardPay
  2. Into the System voice select CREDIT_EXTERNAL
  3. Select the Payload on input containing the credit card number you want to test
  4. Click RequestReply

The Testing View will be expanded and it is also possible to view the GVBuffer Output panel where there are present some properties, among these the REC_READ property setted to 1, representing the number of record read from DB.

The file TestOutput.txt will be generated in the directory ${{gv.app.home}}/log as previously setted (see Testing area) containing information about owner, credit and state of the credit card number "1234123415555666" as passed in input.

<pre>
----------- TEST N. 0 2012.02.15 at 11:46:26 -----------
Standard Field:
	system   = CREDIT_EXTERNAL
	service  = CCardPay
	id       = 7F0001014F3B87B900021429
	retCode  = 0
GVBuffer: class org.apache.xerces.dom.DocumentImpl
<?xml version="1.0" encoding="UTF-8"?>
  <QueryResponse xmlns="http://www.credit.com/services">
     <name>MARIO BIANCHI</name>
     <cnumber>1234123415555666</cnumber>
     <credit>300.00000</credit>
     <active>true</active>
  </QueryResponse>
Properties:
	REC_DISCARD = 0
	IS_INTERNAL = true
	REC_TOTAL = 0
	REC_UPDATE = 0
	REC_INSERT = 0
	REC_READ = 1
	CNUMBER = 1234123415555666
	REC_DISCARD_CAUSE = 
</pre>