Difference between revisions of "GVExample CCardPay"

From GreenVulcano Wiki
Jump to: navigation, search
({{GVCONSOLE}} Configuration)
(Flow implementation)
Line 112: Line 112:
 
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]] || clear-data="false"
 
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]] || clear-data="false"
 
|-
 
|-
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]]/PropertyDef || name="CNUMBER"<br/><nowiki>value="js{{gvesb::var doc=XMLUtils.parseDOM_S(new java.lang.String(object.getObject()),false,true); XMLConfig.get(doc,'//cred:cnumber')}}" </nowiki>
+
| [[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>
 
|-
 
|-
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]]/PropertyDef || name="IS_INTERNAL"<br/>value="sql{{ds.test_gv::select decode(count(*), 1, 'true', 'false') from credit_card where cnumber=ognl{{#object.getProperty('CNUMBER')}}}}"
+
| [[ChangeGVBufferNode]]/[[ChangeGVBuffer]]/PropertyDef || name="IS_INTERNAL"<br/>value="sql{{ds.gv_test::select decode(count(*), 1, 'true', 'false') from credit_card where cnumber=ognl{{#object.getProperty('CNUMBER')}}}}"
 
|-
 
|-
 
| [[GVNodeCheck]] || default-id="pay_external"<br/> id="check_internal"<br/> input="input" <br/>on-exception-id="end"  
 
| [[GVNodeCheck]] || default-id="pay_external"<br/> id="check_internal"<br/> input="input" <br/>on-exception-id="end"  

Revision as of 11:11, 30 May 2014

Description

This service has the purpose of showing how GreenVulcano® ESB uses DataHandler to query a DB and implement Web Services.

CCardPay 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 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.

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="CCardPay"
jdbc-connection-name="ds.test_gv"
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/DBOUpdate name="CCardPay"
transformation="CCardPay"
type="dbo"
dh-call/DBOBuilder/DBOUpdate/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"
Transformations/XSLTransformation name="CCardPay" DataSourceSet="Default"
XSLMapName="DataHandler/CREDIT/CCardPay.xsl"
type="transformation"
Transformations/XSLTransformation name="PayExternalInput" DataSourceSet="Default"
XSLMapName="CREDIT_EXTERNAL/PayExternalInput.xsl"
type="transformation"
Transformations/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
ws-call name="PayExternal"
ws-call/AxisWebServiceInvoker operation="Pay"
ref-dp="EXTERNAL::PayWSDataProvider"
returnType="body-element"
type="invoker"
ws-call/AxisWebServiceInvoker/WSDLInfo type="wsdlinfo"
wsdl="file://${{gv.app.home}}/xmlconfig/wsdl/ExternalCreditService.wsdl"

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

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"
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="IS_INTERNAL"
value="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="pay_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/InputServices/dh-selector-service critical="yes"
internal="yes"
type="service"
GVOperationNode/InputServices/dh-selector-service/dh-selector-call DH_SERVICE_NAME="CCardPay"
GVOperationNode dump-in-out="false"
id="pay_external"
id-system="CREDIT_EXTERNAL"
input="input"
next-node-id="end"
op-type="call"
operation-name="PayExternal"
GVOperationNode/InputServices/gvdte-service critical="yes" internal="yes"
remove-fields="yes" type="service"
GVOperationNode/InputServices/gvdte-service/map-name-param name="map-name" value="PayExternalInput"
GVOperationNode/InputServices/gvdte-service/gvdte-context-call name="PayExternalInput"
GVOperationNode/OutputServices/gvdte-service critical="yes" internal="yes"
remove-fields="yes" type="service"
GVOperationNode/OutputServices/gvdte-service/map-name-param name="map-name" value="PayExternalOutput"
GVOperationNode/OutputServices/gvdte-service/gvdte-context-call 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 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 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.
  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. 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 use and the amount to reduce from.
  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 set (see Testing area) containing information about the credit card numbers you passed in input and the number of records founded and updated.

<pre>
----------- TEST N. 0 2012.03.02 at 14:11:38 -----------
Standard Field:
	system   = CREDIT_EXTERNAL
	service  = CCardPay
	id       = 7F0001014F50AFC600014063
	retCode  = 0
GVBuffer: NULL

Properties:
	REC_DISCARD = 0
	IS_INTERNAL = true
	REC_TOTAL = 1
	REC_UPDATE = 1
	REC_INSERT = 0
	REC_READ = 0
	CNUMBER = 1234123415555666
	REC_DISCARD_CAUSE = 
</pre>