95-843 Service Oriented Architecture Carnegie Mellon University Assigned: Wednesday, November 23, 2011 Homework 4 Due: Tuesday December 6, 11:59:00 PM In this project you will build a BPEL process that interacts with two external web services. One service will be provided by an organization that provides on-demand financial market data - see http://www.xignite.com. The second service will be used for currency conversion and is provided by http://www.webservicex.net. This project has been adapted from the course text "Oracle SOA Suite 11g R1 Developer's Guide" and is found in chapter 5. Parts one and two describe the construction of a synchronous BPEL process. Parts three and four describe the construction of an asynchronous process that makes use of the synchronous process. Part 1. Build a simple BPEL process that interacts with an external web service. 1) In order to use the financial service you will need to register at http://www.xignite.com. 2) The WSDL that you will need is found here: https://www.xignite.com/xQuotes.asmx?WSDL 3) Save this file to the virtual machine's C: drive under the name C:\OracleSOASuite11gDevelopersGuide\Chapter05\XigniteQuotes.wsdl. 4) We will use the following XSD file from the course text. Save it to C:\OracleSOASuite11gDevelopersGuide\Chapter05\StockService.xsd. 5) Our web service, the one we are writing in BPEL, will use the XSD above. The web service from Xignite is defined in the Xignite WSDL. We will need to build a mapping from our service vocabulary to the external service's vocabulary. 6) In JDeveloper, create a new SOA Application. It's name is StockQuoteApplication. The Project name is StockQuoteProject. Create an empty composite. 7) Drag a BPEL component onto the composite. Its name is StockQuoteBPEL. It will be a SOAP based synchronous service and we want the input to this BPEL process and the output from this BPEL process to be defined based upon the vocabulary expressed in the XSD above. Use the magnifying glass icon to the right of the input and output text boxes to browse the file system. The Type Chooser has an Input Schema button on the top right. On the Input Schema File wizard use the magnifying glass icon again to browse to the StockService.xsd. We can now select from this vocabulary. Use the GetQuote for the input to the BPEL process and use the GetQuoteResponse for the output. 8) Right click and add a partner link to the BPEL process. Its name will be xigniteservice and it will be based on the wsdl that we retrieved from Xignite.com. Use the magnifying glass icon to browse for the wsdl. Choose OK to prompts asking if it's OK to extend or move the file. Choose the partner role as XigniteQuotesSOAP role. Leave the My Role selection as unspecified (this is a synchronous call and only one interface is required.) 9) Place an invoke activity onto your BPEL diagram. Name the invoke "CallForQuote". Connect the invoke to the partner link by clicking and dragging an arrow. From the wizard choose GetSingleQuote. We want to name the input and output variables of this service. Use the green plus sign on the wizard to name the variables XigniteInput and XigniteOutput respectively. Note that the types of these variables are already defined in the WSDL. 10) The inputs and the outputs of the BPEL process are defined with a different vocabulary than the inputs and outputs of the Xignite service. Use the assign activity to perform a mapping from the BPEL variables to the Xignite variables. Drag two assign activities onto the BPEL diagram - one before the invoke and one after. Name the first "prepareToCall" and name the second "gatherResponse". This is done by double clicking the assign activity and choosing the General tab. Use the assign wizard to connect the correct BPEL input to the correct Xignite input. Note that two different namespaces are being used. We are mapping the name stockSymbol to the name symbol. In the GatherResponse assign we want to map the outputs of the Xignite service to the outputs of our BPEL process. Map the name "symbol" to "stockSymbol" and "last" to "amount". To add the currency string 'USD' to the output drag the function symbol onto the currency output variable. Enter the string constant 'USD' in the expression box. Include the single quotes. 11) Deploy the StockQuoteProject to the application server. This is done by right clicking the project, choosing deploy and specifying an existing connection. 12) Visit the Enterprise Manager web application. This is located at http://localhost:7001/em. Log on with your username and password. 13) When testing your new project, you may receive an error message embedded within the response from Xignite. It may be rejecting this request because it does not have the requesting machine's IP address as a registered address. If this is the case, then visit xiginte and register the IP address. The best way to learn what this address is is to examine the error responses from xignite. Use the trace feature of the Enterprise Manager to do this. Check the payload of the callForQuote invoke. Part 2. Access a web service that performs currency conversion. 1) Create a new partner link and name it CurrencyConvertor. Associate the new partner link with the currency convertor wsdl. This will be a synchronous SOAP based web service with My Role set to not specified. 2) Create a new Invoke activity that uses the new partner to convert from USD to the currency specified in the original request from the originating client. Perform this invoke before returning the converted price to the client. 3) Add two assign activities. One just prior to and another just after the call to the currency convertor. The first will prepare to call the currency convertor and the second will be used to compute a stock price based on the value returned by the currency convertor and the value returned by Xignite. 4) When deploying the new service be sure to select the "Overwrite" check box so that you overwrite the previous composite on the administration server. Test the new service by looking up IBM's stock price in Canadian currency "CAD'. Part 3. Adding and asynchronous service that places an order for a stock. 1) Add a new asynchronous BPEL component to the existing composite. Use placeOrder for the input and placeOrderResponse for the output. These are defined in the XSD shown above. Note that the BPEL process that was generated has an initial receive but at the end it has an invoke (rather that a reply). 2) Place an assign activity between the receive and the invoke. The assign activity will copy all inputs to the outputs and assume that the bid price is the actual price. 3) Deploy this service and test it. Note that you need to chooses between two operations. Be sure to select the order operation. 4) Add a wait activity to this process. The wait activity should be added just after the receive and should be set for one minute. After it is deployed, run a test and note the delay in the callback to the client. Part 4. Add a loop in the asynchronous process. The instructions for this step are well described in chapter 5 of the course text and will not be enumerated here. The general idea is to modify the composite so that the asynchronous process makes a call to the BPEL process that we wrote above. The asynchronous BPEL process will make a call to the synchronous BPEL process from within a while loop. Three conditions will be present after the invoke. 1) If the request is to 'Buy' and if the selling price is lower than the bid price then call back to the user telling them that a purchase occurred at the selling price. 2) If the request is to 'Sell' and if the selling price is higher than the asking price then call back to the user telling them that a sale occurred at the selling price. 3) Otherwise, wait 1 minute and check the selling price again. Submission for credit. Send a note to the TA when you have completed all of these parts. Be sure to identify your group and be sure to describe what processes you have available for testing.