SOA 11g Tutorial: PO Routing App

 

This is part of the Oracle SOA11g hands on tutorials.

Create App

* File -> New -> General -> Applications -> Generic Application
* On Create Generic Application wizard Step 1, enter
Application Name: POProcessing
Directory: C:\po\POProcessing
Applicatoin Package Prefix: blank
* On Step 2, enter
Project Name: POProcessing
Directory: C:\po\POProcessing\POProcessing
* On Step 2, Project Technologies
– Move SOA from left panel to right panel
* On Step 3, select
Empty Composite
* Click Finish

Add Web Service

* Drag and drop Web Service icon from Component Palette on Exposed Services lane
* On Create Web Service screen, enter
Name: receivePO
Type: Service
* Click Create WSDL from schema icon (second one to the right of WSDL URL field)

Create WSDL

* On Create WSDL screen, accept
File Name: receivePO.wsdl
Directory: C:\po\POProcessing\POProcessing
Namespace: http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO
Port Type: execute_ptt
Operation: execute
Interface Type: One-Way Interface

Define Input
* click the green plus icon above the Input panel
* On Add Message Part screen, click the browse for schema icon (magnifying glass)
* On Type Choose screen, click the Import Schema File icon (first icon on upper right)
* On Import Schema File screen, enter
Check: Copy to Project
URL: file:/C:/po/schemas/po.xsd (or click the magnifying glass and browse to po.xsd file)
– click OK
* On Localize Files screen,
– uncheck maintain original directory structure…
– click OK
* Back on Type Choose screen,
– select PurchaseOrder
– click OK
* Back on Add Message Part screen, enter
Part Name: purchaseOrderPart
URL: xsd/po.xsd
Schema Element: purchaseOrder
– click OK
* Back on Create WSDL screen, click OK
* Back on Create Web Service screen, click OK

Add Routing Component

* Drag and drop a Mediator from Palette to Components lane, enter
Name: routePO
Template: Define Interface Later
* Click OK

Add File Adapter

* Drag and drop a File Adapter to External References lane
* Click Next on Step 1
* Step 2, enter
– Service Name: WriteApprovalResults
* Step 3,
– Select “Define from operation and schema
– click Next
* Step 4,
– Select Write File
* Step 5,
– Select Physical path
Directory for Outgoing Files: c:\temp\po
File naming Convention: order_%SEQ%.txt
* Step 6,
– click magnifying glass icon
* On Type Choose screen, click the Import Schema File icon (first icon on upper right)
* On Import Schema File screen, enter
Check: Copy to Project
URL: file:/C:/po/schemas/internalorder.xsd (or click the magnifying glass and browse to internalorder.xsd file)
– click OK
* On Localize Files screen,
– uncheck maintain original directory structure…
– click OK
* Back on Type Choose screen,
– select Order
– click OK
* Back on Step 6, verify:
URL: xsd/internalorder.xsd
Schema Element: Order
– click Next
* Click Finish

Wire Web Service, Mediator and FileAdapter

* Drag right arrow on upper right of receivePO web service and drop on lower left of routePO.
* Drag right arrow on lower right of routePO and drop on right arrow on upper left of WriteApprovalResults.

Add Transformation Steps

* Double click routePO

Input Mapper

* Click on the transform icon to the right of the “Transform Using” field
* Select Create New Mapper File and click OK
* On the new mapper file,
– drag from left side inp1:PurchaseOrder to right side inp1:Order
* On Auto Map Preferences screen,
– click show Dictionaries button
– click on Add button under Dictionaries panel
– browse to c:\po\schemas\po2internalorders-dictionary.xml
– click OK button (dictionary provides synonyms for words)
* Save and close mapper file

* Save all and close routePO.mplan file

Deploy

* Right click POProcessing project
* Select Deploy -> POProcessing
* On Deploy POProcessing screen,
– select Deploy to Application Server
* On Deploy Configuration screen,
– check Overwrite any existing composites with the same revision ID if reploying
– click Next
* One Select Server screen,
– select MyAppServerConnection
– click Next
* Click Finish on Summary screen

Testing

* Login Enterprise Console http://localhost:7001/em
* Click Farm_soa_domain -> SOA -> soa-infra -> POProcessing
* Click Test tab
* Under Input Arguments,
– select XML View
– Repace content with that of C:\po\input\po-small-Headsetx1.txt

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/ns/order">
        <ns1:PurchaseOrder>
            <ns1:CustID>1111</ns1:CustID>
            <ns1:ID>2121</ns1:ID>
            <ns1:productName>Bluetooth Headset</ns1:productName>
            <ns1:itemType>Electronics</ns1:itemType>
            <ns1:price>49.99</ns1:price>
            <ns1:quantity>1</ns1:quantity>
            <ns1:status>Initial</ns1:status>
            <ns1:ccType>Mastercard</ns1:ccType>
            <ns1:ccNumber>8765-8765-8765-8765</ns1:ccNumber>
        </ns1:PurchaseOrder>
    </soap:Body>
</soap:Envelope>

* Click Test Web Service button
* Check that a new file named order_1.txt is created in c:\temp\po directory. Note that this is the directory on the server side.

<?xml version="1.0" encoding="UTF-8" ?><inp1:Order xmlns:inp1="http://xmlns.oracle.com/ns/order" xmlns="http://xmlns.oracle.com/ns/order">
   <inp1:customerId>1111</inp1:customerId>
   <inp1:orderId>2121</inp1:orderId>
   <inp1:prodName>Bluetooth Headset</inp1:prodName>
   <inp1:itemType>Electronics</inp1:itemType>
   <inp1:price>49.99</inp1:price>
   <inp1:qty>1</inp1:qty>
   <inp1:status>Initial</inp1:status>
   <inp1:creditCardInfo>
      <inp1:cardNumber>8765-8765-8765-8765</inp1:cardNumber>
      <inp1:cardType>Mastercard</inp1:cardType>
   </inp1:creditCardInfo>

Add CreditCardStatus web service (partner link)

* Drag and drop Web Service icon to External References lane
* On Create Web Service screen, enter
Name: getCreditCardStatus
* Click Find existing WSDLs icon to the right of “WSDL URL” field
* On SOA Resource Browser screen,
– select Resource Palette from the top drop down box.
– select IDE Connections -> Application Server -> MyAppServerConnection -> SOA -> soa_server1 -> default -> validationForCC[1.0] -> getStatusByCC (ws)
Or enter: http://locahost:8001/soa-infra/services/default/validationForCC/getStatusByCC?WSDL
– Click OK
– Click OK on Create Web Service dialog

Add BPEL Component

* Drag and drop BPEL Process to Components lane
* On Create BPEL Process screen, enter
Name: approveLargeOrder
Namespace: http://xmlns.oracle.com/POProcessing/POProcessing/approveLargeOrder
Template: Asynchronous BPEL Process
Service Name: approvelargeorder_client
Expose as a SOAP service: Un-checked
Input:
– click on magnifying glass
– select Project Schema Files -> internalorder.xsd -> order
– click OK
Output:
– click on magnifying glass
– select Project Schema Files -> internalorder.xsd -> order
– click OK
* Click OK
* Wire approveLargeOrder BPEL process to getCreditCardStatus web service by drag and drop a line from the lower right corner of approveLargeOrder to upper left corner of getCreditCardStatus .

BEPL Approval Process

* Open BPEL editor by either
– Double click approveLargeOrder BPEL process icon
– Or right click BPEL process icon and select Edit…

Add Invoke

* Drag and drop Invoke icon right below receiveInput icon
* Drag wire from Invoke icon and connect with getCreditCardStatus partner link.
* On Edit Invoke screen,
– enter
Name: invokeCCStatusService
– Click the green plus sign to the right of Variables/Input and accept defaults
– Click the green plus sign to the right of Variables/Output and accept defaults
– Click OK

Add Assign

* Drag and drop an Assign icon before invokeCCStatusService
* Double click to bring up the Edit Assign screen
* On General tab:
– Name: assignCCNumber
* Click Copy Rules tab
* Copy one
– Drag from left side
Variables/Process/Variables/inputVariable/payload/Order/creditCardInfo/cardNumber
– to right side
Variables/Process/Variables/invokeCCStatusService_execute_inputVariable/creditcardSatusRequestPart/creditcardStatusRequest/CCNumber
* Copy two
– Drag from left side
Variables/Process/Variables/inputVariable/payload/Order
– to right side
Variables/Process/Variables/outputVariable/payload/Order
* Click OK
* Save All

Add Switch

* Drag and drop Switch icon under invokeCCStatusService
* Double click Switch icon to open the Switch dialog.
* On General tab enter
– Name: EvalulateCCStatus
Click OK
* Click condition block and enter
Label: validCreditCard
Condition:
– Click XPath condition builder, enter condition:

bpws:getVariableData('invokeCCStatusService_execute_OutputVariable','creditcardStatusPart','/ns3:creditcardStatus') = 'VALID'

– Click OK

Valid Credit Card Branch

* Drag and drop Assign icon below condition block
* Double click Assign icon and name it assignApproval on General tab
* Click Copy Rules tab
* Drag the Expression icon (first icon on upper right) and drop onto
Variables/Process/Variables/outputVariable/payload/Order/status
* Enter into the Expression panel
‘approved’
* Click OK
* Click OK on Edit Assign screen

InValid Credit Card Branch

* Repeat previous Assign steps for the otherwise branch but
– Name: assignInvalidCC
– Use value
‘invalidCreditCard’ (with single quotes)
* Save All

Modify Mediator

* Back in composite.xml file
* Wire routePO mediator to approveLargeOrder BPEL process
– Drag a wire from lower right of routePO icon to upper right of approveLargeOrder icon.
* Open routePO.mplan file by double clicking routePO icon
* Enter filter criteria for WriteApprovalResults::Write operation

($in.purchaseOrderPart/inp1:PurchaseOrder/inp1:price  * $in.purchaseOrderPart/inp1:PurchaseOrder/inp1:quantity) < 1000

* Enter filter criteria for approveLargeOrder operation

($in.purchaseOrderPart/inp1:PurchaseOrder/inp1:price * $in.purchaseOrderPart/inp1:PurchaseOrder/inp1:quantity) >= 1000

* Create transformation map for approveLargeorder
– click on transformation icon
– select Create new Mapper File and accept default file name
– click OK
– drag PurchaseOrder to Order
– click OK on automapping
– drag inp1:ccType to inp1:cardType
– drag inp1:ccNumber to inp1:cardNumber
* Setup Callback Target Operation
– Click cog icon to the right of Callback
– Click Service as target type
– Select POProcessing | References | WriteApprovalResults | Write
– Click OK
* Create transformation map for Callback
– repeat previous steps but drag from Order to Order

ReDeploy

Test

* Valid credit card input message:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/ns/order">
        <ns1:PurchaseOrder>
            <ns1:CustID>1111</ns1:CustID>
            <ns1:ID>2222</ns1:ID>
            <ns1:productName>iPod shuffle</ns1:productName>
            <ns1:itemType>Electronics</ns1:itemType>
            <ns1:price>145</ns1:price>
            <ns1:quantity>30</ns1:quantity>
            <ns1:status>Initial</ns1:status>
            <ns1:ccType>Mastercard</ns1:ccType>
            <ns1:ccNumber>1234-1234-1234-1234</ns1:ccNumber>
        </ns1:PurchaseOrder>
    </soap:Body>
</soap:Envelope>

* order_.txt file (status has changed to approved)

<?xml version="1.0" encoding="UTF-8" ?><ns1:Order xmlns:ns1="http://xmlns.oracle
.com/ns/order" xmlns="http://xmlns.oracle.com/ns/order">
   <ns1:customerId>1111</ns1:customerId>
   <ns1:orderId>2222</ns1:orderId>
   <ns1:prodName>iPod shuffle</ns1:prodName>
   <ns1:itemType>Electronics</ns1:itemType>
   <ns1:price>145</ns1:price>
   <ns1:qty>30</ns1:qty>
   <ns1:status>approved</ns1:status>
   <ns1:creditCardInfo>
      <ns1:cardNumber>1234-1234-1234-1234</ns1:cardNumber>
      <ns1:cardType>Mastercard</ns1:cardType>
   </ns1:creditCardInfo>
</ns1:Order>

* Invalid credit card input message:
– change credit card number to 4321-4321-4321-4321 to simulate invalid credit card

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/ns/order">
        <ns1:PurchaseOrder>
            <ns1:CustID>1111</ns1:CustID>
            <ns1:ID>2222</ns1:ID>
            <ns1:productName>iPod shuffle</ns1:productName>
            <ns1:itemType>Electronics</ns1:itemType>
            <ns1:price>145</ns1:price>
            <ns1:quantity>30</ns1:quantity>
            <ns1:status>Initial</ns1:status>
            <ns1:ccType>Mastercard</ns1:ccType>
            <ns1:ccNumber>4321-4321-4321-4321</ns1:ccNumber>
        </ns1:PurchaseOrder>
    </soap:Body>
</soap:Envelope>

* order_.txt file (status is now invalidCreditCard)

<?xml version="1.0" encoding="UTF-8" ?><ns1:Order xmlns:ns1="http://xmlns.oracle
.com/ns/order" xmlns="http://xmlns.oracle.com/ns/order">
   <ns1:customerId>1111</ns1:customerId>
   <ns1:orderId>2222</ns1:orderId>
   <ns1:prodName>iPod shuffle</ns1:prodName>
   <ns1:itemType>Electronics</ns1:itemType>
   <ns1:price>145</ns1:price>
   <ns1:qty>30</ns1:qty>
   <ns1:status>invalidCreditCard</ns1:status>
   <ns1:creditCardInfo>
      <ns1:cardNumber>4321-4321-4321-4321</ns1:cardNumber>
      <ns1:cardType>Mastercard</ns1:cardType>
   </ns1:creditCardInfo>
</ns1:Order>

* Click Launch Message Flow Trace to see process message flow

This entry was posted in soa11g. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.