95-843 Service Oriented Architecture Carnegie Mellon University Assigned: Friday, June 8 Homework 4 Due: Friday, June 15, 2012, 11:59:00 PM When you have completed this project, notify your instructor by email. In your email, provide your machine name and your application and project names and any instructions that may be useful. * In your email, state exactly what parts of this homework you have working. * 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. Part three asks that you add switch and flow statements to your work in part two. Part 1. Build a simple BPEL process that interacts with an external web service. 0) In order to use the currency converter service, you will save the WSDL located at http://www.webservicex.net/CurrencyConvertor.asmx?WSDL to the file C:\OracleSOASuite11gDevelopersGuide\Chapter05\Currency.wsdl. 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: http://www.xignite.com/xQuotes.asmx?WSDL 3) Save the Xignite WSDL 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. You may copy and paste this xsd file from this document. 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. Its 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 right on the BPEL process (not the composite). 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 "CallXignite". Connect the invoke to the partner link by clicking and dragging an arrow. From the wizard, choose the GetSingleQuote operation. 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 callXignite invoke. The trace manager is executed by clicking the instance ID. 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. To create the second assign activity, drag the function symbol to the output variable. (This is the output variable for the entire BPEL process.) This will open up an expression builder. You may then build XPath expressions and use multiplication to compute the final result. 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. Add a test condition to your process so that the currency conversion service is not used when the visitor requests currency in US Dollars. Xignite already returns the stock price in US dollars, so, in this case, the conversion step is not needed. If currency conversion is required then, of course, both services need to be called. At a minimum, call these services sequentially. For full credit, call them in parallel.