Difference between revisions of "GVExample CCardQuery"

From GreenVulcano Wiki
Jump to: navigation, search
(Defining Systems, Channels and Operations)
({{GVCONSOLE}} Configuration)
 
(16 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
CCardQuery Service executes the following operations:
 
CCardQuery Service executes the following operations:
# Receives a request Web Service from client, with a credit card number to be controlled.
+
# Receives a [[Web Services|Web Service]] request from client, with a credit card number to be controlled.
# If this card is locally managed, reads the data using DataHandler.  
+
# If this card is locally managed, reads the data from DB 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 16: Line 16:
 
# Implement the [[Flow|flows]].
 
# Implement the [[Flow|flows]].
  
===Defining Systems, Channels and Operations===
+
===Defining Systems, Channels, Operations and XPath===
 +
 
 +
For this exercise, you need first of all to define an XPath for querying web services. This can be made in {{VULCON}} core view, simply by right-clicking on the element '''GVHpath/XPath''' and then selecting Insert after (or Insert before) -> XPathNamespace. Then fill the ampty field as in the following table.
 +
 
 +
{|class="gvtable"
 +
! Element !! Value
 +
|-
 +
| XPathNamespace || namespace="http://www.credit.com/services"<br/>prefix="cred"
 +
|}
 +
 
 +
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 Services|Web service]] with {{L_VULCON}} is using the Wizard. We start from a [http://en.wikipedia.org/wiki/Web_service Web Service] WSDL, that describes a withdrawal operation on a credit card.
 +
 
 +
From the Core view of {{L_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 <nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl-, choose the parameters to create the {{GVESB}} service.
 +
 
 +
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 change those names to CCardPay and CCardQuery for the services, PayExternal and QueryExternal for the [[ws-call]] operations respectively. Now is possible to modify the workflow.
 +
 
 +
From the {{L_VULCON}} Core view, element System "CREDIT" -> Channel "CHANNEL_CREDIT_WS", insert a [[dh-call]] operation and set its attributes and sub-elements as follow:
  
To define a System, go to {{VULCON}} core view and insert the System CREDIT with the Channel CHANNEL_CREDIT_WS, with the following operations:
 
 
* [[dh-call]]:
 
* [[dh-call]]:
 
{|class="gvtable"
 
{|class="gvtable"
! Attribute !! Value  
+
! Element !! Value  
 +
|-
 +
| [[dh-call]] || name="DataHandler"
 +
|-
 +
| [[dh-call]]/[[DBOBuilder]] || name="CCardQuery" <br/> jdbc-connection-name="ds.gv_test" <br/>
 +
|-
 +
| [[dh-call]]/[[DBOBuilder]]/[[DHVariables]]/[[DHVariables#DHVariable|DHVariable]] || name="decimal-separator" value="."
 +
|-
 +
| [[dh-call]]/[[DBOBuilder]]/[[DHVariables]]/[[DHVariables#DHVariable|DHVariable]] || name="grouping-separator" value=","
 
|-
 
|-
| name || DataHandler
+
| [[dh-call]]/[[DBOBuilder]]/[[DHVariables]]/[[DHVariables#DHVariable|DHVariable]] || name="format" value="#0.00"
 
|-
 
|-
| DBOBuilder || name="CREDIT::CCardQuery" <br/> jdbc-connection-name="ds.test_gv" <br/>  
+
| [[dh-call]]/[[DBOBuilder]]/[[DBOSelect]] || name="CCardQuery" <br/> transformation="CCardQuery" <br/> type="dbo" <br/>
DHVariables:
 
: name="decimal-separator" value="."
 
: name="grouping-separator" value=","
 
: name="format" value="#0.00"
 
 
|-
 
|-
| DBOBuilder/ DBOSelect || name="CCardQuery"  <br/> transformation="CCardQuery"  <br/> type="dbo" <br/>statement id="1" <br/>
+
| [[dh-call]]/[[DBOBuilder]]/[[DBOUpdate]]/[[statement]] || id="1" <br/> type="select" <br/>  
type="select" <br/>  
 
 
  select p.NAME, cc.CNUMBER, cc.CREDIT, cc.ENABLED
 
  select p.NAME, cc.CNUMBER, cc.CREDIT, cc.ENABLED
 
  from PERSON p, CREDIT_CARD cc
 
  from PERSON p, CREDIT_CARD cc
Line 38: Line 58:
 
  and cc.CNUMBER = <nowiki>@{{CNUMBER}}</nowiki>
 
  and cc.CNUMBER = <nowiki>@{{CNUMBER}}</nowiki>
 
|}
 
|}
 +
 
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 allow to have data in XML format. So, you need to define the following parameters into the [[GVDataTransformation]] section:
 
{|class="gvtable"
 
{|class="gvtable"
! Attribute !! Value
+
! Element !! Attributes
 
|-
 
|-
 
| [[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"
+
| Transformations/[[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="CCardQuery" DataSourceSet="Default"  <br/> XSLMapName="DataHandler/CREDIT/[[CCardQuery.xsl]]"<br/> type="transformation"
 
|-
 
|-
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalInput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalInput.xsl]]"  <br/> type="transformation"
+
| Transformations/[[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalInput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalInput.xsl]]"  <br/> type="transformation"
 
|-
 
|-
| [[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalOutput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalOutput.xsl]]" <br/> type="transformation"
+
| Transformations/[[GVDataTransformation#XSLTransformation|XSLTransformation]] || name="QueryExternalOutput" DataSourceSet="Default" <br/> XSLMapName=" CREDIT_EXTERNAL/[[QueryExternalOutput.xsl]]" <br/> type="transformation"
 
|}
 
|}
  
Now insert the [[Service]] CREDIT_EXTERNAL with the [[Channel]] CHANNEL_CREDIT_EXT with the following operations:
+
Now control that the [[ws-call]] element attributes and subelements defined into [[System]] CREDIT_EXTERNAL -> [[Channel]] CHANNEL_CREDIT_EXT will be set as:
 
* [[ws-call]]:
 
* [[ws-call]]:
 
{|class="gvtable"
 
{|class="gvtable"
! Attribute !! Value  
+
! Element !! Value  
 +
|-
 +
| [[ws-call]] || name="QueryExternal"
 +
|-
 +
| [[Ws-call#AxisWebServiceInvoker|ws-call/AxisWebServiceInvoker]] || operation="Query" <br/> ref-dp="EXTERNAL::QueryWSDataProvider"<br/> returnType="body-element"<br/> type="invoker"
 
|-
 
|-
| Name || QueryExternal
+
| [[Ws-call#AxisWebServiceInvoker|ws-call/AxisWebServiceInvoker]]/WSDLInfo || type="wsdlinfo"<br/>wsdl="file://<nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl/[[ExternalCreditService.wsdl]]"
 
|-
 
|-
| [[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]]/BasicHttpAuth || user="xmlp<nowiki>{{ws.auth.user}}</nowiki>"<br/>password="xmlp<nowiki>{{ws.auth.password}}</nowiki>"
: type="wsdlinfo"
 
: wsdl="file://<nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl/[[ExternalCreditService.wsdl]]"
 
 
|}
 
|}
  
Note that the easiest way to configure a Web Service with {{VULCON}} is using the Wizard. In this example we start from the [[ExternalCreditService.wsdl]] [http://en.wikipedia.org/wiki/Web_service Web Service] WSDL, present in folder <nowiki>${{gv.app.home}}</nowiki>/xmlconfig/wsdl, that describes a withdrawal operation on a credit card.
+
The ws-call operation already defined makes use of the [[Data provider]] module. So, you need to define the following parameters into the [[GVDataProviderManager]] section, present in the Adapter Core View of {{L_VULCON}}:
 
 
From the Core view of {{L_VULCON}}, right clicking the Services element, launch the [[Wizard Call Web Service]] and, after selecting the WSDL file, choose the parameters to create the {{GVESB}} service.
 
 
 
After that you can modify your workflow through {{L_VULCON}} [[Palette]] and set the elements as will be described in the next section.
 
 
 
===Definition of Services===
 
 
 
To define the CCardQuery Service, use the voice "Wizard new Service" (Right clicking the element Services) and set the following parameters:
 
 
{|class="gvtable"
 
{|class="gvtable"
! Attribute !! Value
+
! Element !! Attributes
 
|-
 
|-
| Service name || CCardQuery
+
| [[Axis2MessageContextDataProvider]] || name="EXTERNAL::PayWSDataProvider"
 
|-
 
|-
| Group || CREDIT_GRP
+
| [[Axis2MessageContextDataProvider]]/Field || direction="OUT" key="message"<br/>
 
|-
 
|-
| Scenario || Synchronous- Synchronous
+
| [[Axis2MessageContextDataProvider]]/Field/Expression || type="ognl"
|-
+
  envelope.body.addChild(@org.apache.axis2.util.XMLUtils
| Server (Participant) || system="CREDIT" <br/> channel="CHANNEL_CREDIT_WS" <br/>request operation= "DataHandler"
+
    @toOM(#input.object.getDocumentElement()))
 
|}
 
|}
  
A new Flow has been created and must be modified in its main steps. But first it is also needed to add a [[Participant]] with the attributes:
+
===Flow implementation===
* system="CREDIT_EXTERNAL"
 
* channel="CHANNEL_CREDIT_EXT"
 
  
===Flow implementation===
+
[[File:GVExamplesCCardQueryFlow.jpg|thumb|CCardQuery flow]] In order to define the CCardQuery service [[Flow]] design it as shown in the picture:
  
[[File:GVExamplesCCardQueryFlow.jpg|thumb|CCardQuery flow]]To define the CCardQuery 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 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 following table shows the parameters to be defined for each operations of the Flow:
+
The following table shows the parameters to be defined for each Flow node:
  
 
{|class="gvtable"
 
{|class="gvtable"
Line 103: Line 115:
 
| first-node || Prepare
 
| first-node || Prepare
 
|-
 
|-
| Conditions/GVBufferCondition || condition="isInternalCCard" <br/> Property:
+
| [[Conditions]]/[[GVBufferCondition]] || condition="isInternalCCard"
: name="IS_INTERNAL" operator="equal"
+
|-
: type="gvbuffer-field"
+
| [[Conditions]]/[[GVBufferCondition]]/Property || name="IS_INTERNAL" operator="equal"<br/>type="gvbuffer-field"<br/>value="true"<br/>value-type="text"
: value="true"
 
: value-type="text"
 
 
|-
 
|-
| ChangeGVBufferNode || dump-in-out="true" <br/>id="prepare" <br/>input="input" <br/>next-node-id="check_internal" <br/>clear-data="false" <br/>PropertyDef:
+
 
: name="CNUMBER"
+
| [[ChangeGVBufferNode]] || dump-in-out="true" <br/>id="prepare" <br/>input="input" <br/>next-node-id="check_internal"
: <nowiki>value="js{{gvesb::var doc=XMLUtils.parseDOM_S(new java.lang.String(object.getObject()),false,true); XMLConfig.get(doc,'//cred:cnumber')}}" </nowiki><br/>
 
PropertyDef:
 
: name="IS_INTERNAL"
 
: 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"
+
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]] || clear-data="false"
 
|-
 
|-
| 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"
+
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]]/PropertyDef || name="CNUMBER"<br/><nowiki>value="js{{gvesb::var doc=XMLUtils.parseObject_S(object.getObject(),false,true); XMLUtils.get_S(doc,'//cred:cnumber')}}"</nowiki>
 
|-
 
|-
| 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:
+
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]]/PropertyDef || name="sql{{ds.gv_test::select decode(count(*), 1, 'true', 'false') from credit_card where cnumber=ognl{{#object.getProperty('CNUMBER')}}}}"
: gvdte-service
 
: crtical="yes",internal="yes"
 
: remove-fields="yes" type="service"
 
: map-name-param:name="map-name" type="param"
 
: value="QueryExternalInput”
 
: name="QueryExternalInput
 
OutputServices:
 
: gvdte-service:
 
: critical="yes" internal="yes"
 
: remove-fields="yes" type="service"
 
: map-name-param:
 
: name="map-name" type="param"
 
: value="QueryExternalOutput"
 
: name="QueryExternalOutput"
 
 
|-
 
|-
| GVEndNode || end-business-process="yes"  <br/>id="end"  <br/>op-type="end"  <br/>output="output"
+
| [[GVNodeCheck]] || default-id="pay_external"<br/> id="check_internal"<br/> input="input" <br/>on-exception-id="end"
 +
|-
 +
| [[GVNodeCheck]]/GVRouting || condition="isInternalCCard" <br/>next-node-id="search_internal"
 +
|-
 +
| [[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"
 +
|-
 +
| [[GVOperationNode]]/InputServices/dh-selector-service || critical="yes"<br/>internal="yes"<br/> type="service"
 +
|-
 +
| [[GVOperationNode]]/InputServices/dh-selector-service/dh-selector-call || DH_SERVICE_NAME="CCardQuery"<br/>name="setDBService"
 +
|-
 +
 
 +
| [[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"
 +
|-
 +
| [[GVOperationNode]]/InputServices/gvdte-service || critical="yes" internal="yes"<br/>remove-fields="yes" type="service"
 +
|-
 +
| [[GVOperationNode]]/InputServices/gvdte-service/map-name-param || name="map-name" value="QueryExternalInput"
 +
|-
 +
| [[GVOperationNode]]/InputServices/gvdte-service/gvdte-context-call || name="QueryExternalInput"
 +
|-
 +
| [[GVOperationNode]]/OutputServices/gvdte-service || critical="yes" internal="yes"<br/>remove-fields="yes" type="service"
 +
|-
 +
| [[GVOperationNode]]/OutputServices/gvdte-service/map-name-param || name="map-name" value="QueryExternalOutput"
 +
|-
 +
| [[GVOperationNode]]/OutputServices/gvdte-service/gvdte-context-call || name="QueryExternalOutput"
 +
|-
 +
| [[GVEndNode]] || end-business-process="yes"  <br/>id="end"  <br/>op-type="end"  <br/>output="output"
 
|}
 
|}
 +
 +
=={{GVCONSOLE}} Configuration==
 +
 +
It is time to deploy and test your new Service. To do that follow these steps:
 +
 +
[[File:GVCONSOLEDeploy.jpg|thumb|Deploy new Service]]Suppose you have saved the {{VULCON}} Configuration file as <nowiki>"${{gv.app.home}}/TEST/REPG1.zip"</nowiki>. To deploy the new Service follow this steps:
 +
# [[Starting|Start {{GVESB}}]]
 +
# [[GV_Console#Access|Access to the {{GVCONSOLE}}]].
 +
# In the Deploy New Service section click Browse... and select the file where you have saved the {{L_VULCON}} configuration.
 +
# Click Submit.
 +
 +
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 file GVCore.xml present in local and in server.
 +
# 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.
 +
 +
[[File:GVConsoleUtilityReload1.jpg|thumb|{{GVCONSOLE}} Utility section]]Now pass to the {{L_GVCONSOLE}} section [[Utility]].
 +
# Click on [[Reload_Configuration|Reload configuration]]
 +
# Select GVCore.xml and GVAdapters.xml and then Reload.
 +
# Confirm the operation.
 +
 +
[[File:GVConsoleTesting.jpg|thumb|{{GVCONSOLE}} Testing section]]Go to the {{L_GVCONSOLE}} section [[Testing]]. In this section you can finally test your new services:
 +
# From the Service list select CCardQuery
 +
# From the System list select CREDIT_EXTERNAL
 +
# Select the Payload on input containing the credit card number you want to test
 +
# 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 set to 1, representing the number of record read from DB.
 +
 +
The file TestOutput.txt will be generated in the directory <nowiki>${{gv.app.home}}</nowiki>/log as previously set (see [[Testing]] area) containing information about owner, credit and state of the credit card number "1234123415555666" as passed in input.
 +
<syntaxhighlight lang="XML">
 +
<pre>
 +
----------- TEST N. 0 2012.02.15 at 11:46:26 -----------
 +
Standard Field:
 +
system  = CREDIT_EXTERNAL
 +
service  = CCardQuery
 +
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>
 +
</syntaxhighlight>

Latest revision as of 22:06, 2 June 2014

Description

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

CCardQuery Service executes the following operations:

  1. Receives a Web Service request from client, with a credit card number to be controlled.
  2. If this card is locally managed, reads the data from DB 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 CCardQuery service follow these steps:

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

Defining Systems, Channels, Operations and XPath

For this exercise, you need first of all to define an XPath for querying web services. This can be made in VulCon core view, simply by right-clicking on the element GVHpath/XPath and then selecting Insert after (or Insert before) -> XPathNamespace. Then fill the ampty field as in the following table.

Element Value
XPathNamespace namespace="http://www.credit.com/services"
prefix="cred"

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.

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 change those names to CCardPay and CCardQuery for the services, PayExternal and QueryExternal for the ws-call operations respectively. Now is possible to modify the 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:

Element Value
dh-call name="DataHandler"
dh-call/DBOBuilder name="CCardQuery"
jdbc-connection-name="ds.gv_test"
dh-call/DBOBuilder/DHVariables/DHVariable name="decimal-separator" value="."
dh-call/DBOBuilder/DHVariables/DHVariable name="grouping-separator" value=","
dh-call/DBOBuilder/DHVariables/DHVariable name="format" value="#0.00"
dh-call/DBOBuilder/DBOSelect name="CCardQuery"
transformation="CCardQuery"
type="dbo"
dh-call/DBOBuilder/DBOUpdate/statement id="1"
type="select"
select p.NAME, cc.CNUMBER, cc.CREDIT, cc.ENABLED
from PERSON p, CREDIT_CARD cc
where p.ID = cc.ID_OWNER
and cc.CNUMBER = @{{CNUMBER}}

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:

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

Now control that the ws-call element attributes and subelements defined into System CREDIT_EXTERNAL -> Channel CHANNEL_CREDIT_EXT will be set as:

Element Value
ws-call name="QueryExternal"
ws-call/AxisWebServiceInvoker operation="Query"
ref-dp="EXTERNAL::QueryWSDataProvider"
returnType="body-element"
type="invoker"
ws-call/AxisWebServiceInvoker/WSDLInfo type="wsdlinfo"
wsdl="file://${{gv.app.home}}/xmlconfig/wsdl/ExternalCreditService.wsdl"
ws-call/AxisWebServiceInvoker/BasicHttpAuth user="xmlp{{ws.auth.user}}"
password="xmlp{{ws.auth.password}}"

The ws-call operation already defined makes use of the Data provider module. So, you need to define the following parameters into the GVDataProviderManager section, present in the Adapter Core View of VulCon®:

Element Attributes
Axis2MessageContextDataProvider name="EXTERNAL::PayWSDataProvider"
Axis2MessageContextDataProvider/Field direction="OUT" key="message"
Axis2MessageContextDataProvider/Field/Expression type="ognl"
 envelope.body.addChild(@org.apache.axis2.util.XMLUtils
   @toOM(#input.object.getDocumentElement()))

Flow implementation

CCardQuery flow

In order to define the CCardQuery 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"
Conditions/GVBufferCondition/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"
ChangeGVBufferNode/ChangeGVBuffer clear-data="false"
ChangeGVBufferNode/ChangeGVBuffer/PropertyDef name="CNUMBER"
value="js{{gvesb::var doc=XMLUtils.parseObject_S(object.getObject(),false,true); XMLUtils.get_S(doc,'//cred:cnumber')}}"
ChangeGVBufferNode/ChangeGVBuffer/PropertyDef name="sql{{ds.gv_test::select decode(count(*), 1, 'true', 'false') from credit_card where cnumber=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="search_internal"
id-system="CREDIT"
input="input"
next-node-id="end"
op-type="call"
operation-name="DataHandler"
output="output"
GVOperationNode/InputServices/dh-selector-service critical="yes"
internal="yes"
type="service"
GVOperationNode/InputServices/dh-selector-service/dh-selector-call DH_SERVICE_NAME="CCardQuery"
name="setDBService"
GVOperationNode dump-in-out="false"
id="search_external"
id-system="CREDIT_EXTERNAL"
input="input"
next-node-id="end"
op-type="call"
operation-name="QueryExternal"
GVOperationNode/InputServices/gvdte-service critical="yes" internal="yes"
remove-fields="yes" type="service"
GVOperationNode/InputServices/gvdte-service/map-name-param name="map-name" value="QueryExternalInput"
GVOperationNode/InputServices/gvdte-service/gvdte-context-call name="QueryExternalInput"
GVOperationNode/OutputServices/gvdte-service critical="yes" internal="yes"
remove-fields="yes" type="service"
GVOperationNode/OutputServices/gvdte-service/map-name-param name="map-name" value="QueryExternalOutput"
GVOperationNode/OutputServices/gvdte-service/gvdte-context-call name="QueryExternalOutput"
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 follow 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 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 CCardQuery a new view will be open containing the file 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.
  3. Confirm the operation.
GV Console Testing section

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

  1. From the Service list select CCardQuery
  2. From the System list 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 set 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 set (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  = CCardQuery
	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>