95-843 Service Oriented Architecture Carnegie Mellon University Assigned: Thursday, April 4, 2013 Homework 3 Due: Thursday, April 11, 11:59:00 PM Part 1. ======= In this graded project you will build a composite application using Oracle's SOA Suite 11g. This composite will be built from three components. The first component is a file adapter. It will be configured to read a file when that file is placed into the NewData directory. The adapter will poll for the file every 10 seconds. It will then delete the file and make a copy of it to an archive directory. It will also generate an XML equivalent file and construct an XSD that contains the grammar for the XML. This XML file will be available to the other components in the SOA Suite. The second component in the composite is also a file adapter. It will write data to a log file called CoolLog.txt. The third component is a mediator component (think lightweight ESB) that will read data from the first component, transform it using XSLT, and write the data to the second component. 0) The steps below have been adapted and modified from the book "Oracle SOA Suite 11g Handbook" and these steps are also found on this web site (see chapter 7): http://technology.amis.nl/blog/13380/soa-suite-11g-handbook-chapter-complements 1) Create a directory called C:\Testing with subdirectories C:\Testing\NewData and C:\Testing\NewSampleData and C:\Testing\Log and C:\Testing\Archive. Within the Log directory, create an empty file called CoolLog.txt. 2) Build a text file named C:\Testing\NewSampleData\CoolArrivedData.txt with the following data: 1,Jones,Andy,ENG100,PSY050,MAT220 2,Hein,Peter,MAT010,CHM230,CSC401 3,Miller,Kyle,MAT010,CHM230,HST080 4,Williams,Ann,MAT010,ENG100,PSY050 5,Kim,Jenny,ENG100,CHM230,HST080 6,Carter,Herb,PSY050,CHM230,CSC401 7,Popov,Dimitri,PSY050,PHY100,ENG100 8,Smith,Kellie,PSY050,HST080,ECN110 Be sure to include a final return at the end. That is, hit return on line 8 after ECN110. 3) Build a text file named C:\Testing\NewSampleData\CoolLoggedData.txt with the following data: 2012-03-29,Michael,McCarthy 4) Run JDeveloper and create a new SOA Application with an empty composite. This application will be called CoolCopyTransformAndLogApplication, the project will be called CoolCopyTransforAndLogProject and the composite will be called CoolCopyTransformAndLogComposite. 5) Drag and drop a file adapter to the Exposed Services Lane. 6) Name the service provided by the adapter CoolReadFileAndGenerateXMLService. 7) Select Define from operation and schema (specified later) 8) Select Read File as the operation type and give it the name CoolReadArrivedDataOperation. 9) Select Logical Name for directory names. 10) The logical directory name is COOLINPUTDIR. 11) We do not need to process the files recursively. 12) We do want to archive processed files. Give this directory the logical name COOLARCHIVE. 13) We do want to delete files after successful retrieval. 14) Use wild cards and include files with the name pattern *.txt. 15) There are multiple messages and we will publish message in batches of 1. 16) Set the polling frequency to 10 seconds. In real life, this field would be much larger. 17) The minimum age is 0 seconds. 18) We are not using a trigger file. We must describe the format of the XML document that is to be generated. 19) Click the gear icon to the right of the URL text box. 20) The file type is delimited. 21) We will browse to the first data file above (CoolArrivedData.txt) to use as our sample. 22) The file contains multiple record instances all of a single type. 23) Our namespace is http://coolexample.com/coolarriveddata. 24) The element name containing multiple records is coolRoot. 25) Our record name is coolRecord. 26) Give each field a name. Use the names: RecordID,Last,First,Course1,Course2,Course3. 27) An XSD will be generated. Give it the name CoolArrivedData.xsd. 28) Use the testing page to see if we are generating the correct XML from the sample data file. 29) If the XML looks clean, we are finished and should return to the Adapter Configuration wizard. 30) The URL field (to the left of the gear) should now point to our schema xsd. 31) Finish the wizard. The new service is displayed. It has a single operation. 32) We need to associate the logical names with physical names. Do this by placing a complete file path as the value of the property element that is found below the binding.jca element in composite.xml. C:\Testing\NewData : C:\Testing\Archive At this point we are able to read a comma delimited file when it arrives. We will be generating an XML equivalent and this XML may be used by other components in the composite. 33) Drag a new file adapter to the external references lane of the the composite editor. We will use this adapter to generate a log file from the XML arriving from the first adapter. 34) The name of this new service is LogNames. 35) We will define from operation and schema later. 36) We are using this adapter to write files. 37) The operation name is WriteCoolLogFile. 38) Use the logical name COOLLOGDIR. 39) Next to file naming conventions enter CoolLog.txt. 40) Select append to existing file. 41) To the right of the URL input box, select the gear symbol. 42) We want to create a new file of the delimited type. 43) The file name of the sample is C:\Testing\NewSampleData\CoolLoggedData.txt Choose Sample all rows. 44) We want to generate multiple records all of the same type. 45) The target namespace is http://coolexample.com/coollog. 46) The name containing multiple records is CoolInputLog. 47) The name containing each record is CoolInput. 48) The first field is named Date, the second is named FirstName and the last is named LastName. 49) The XSD file name is LogInput.xsd. 50) Test and then finish and then return to the adapter configuration wizard. To the left of the gear should be the URL of the XSD. Finish the wizard. 51) We need to associate the logical names with physical names. Do this by placing a complete file path as the value of the property element that is below the binding.jca element in composite.xml. C:\Testing\Log 52) We need a mediator to take the XML from the input adapter and write it to the output adapter. 53) Drag a mediator and place it in the Components Lane in the Composite Editor. Note that the input adapter is reading a file and generating XML. The output adapter is reading XML and generating an output file. 54) Name the mediator CoolMoverFromInputToOutput and define the interface later. 55) Click and drag to create a wire from the input adapter to the mediator. 56) Click and drag to create a wire from the mediator to the output adapter. 57) Double click the mediator and click the mapping icon to the right of "Transform Using". 58) This is a New XSLT mapper. Name it InputToLog.xsl 59) In the mapping editor on the left is the input XSD. On the right is the output XSD. 60) From Date Functions on the right, drag the current-date function to the middle lane. Drag and connect that to the Date element in the output tree. 61) Drag the name data from the input to the output as appropriate. You can view source to see the generated XSLT. 62) Deploy the project by right clicking the project and selecting deploy. 63) How will you Test it? Place the CoolArrivedData.txt file into the NewData directory and see if it soon disappears. The Archive and Log directories should be populated. 64) Inform your TA that you have completed the project and that it is deployed. The TA will log on to your virtual machine and test it with his/her own data file. In your email to the TA, be sure to include your name and your machine number. Part 2. ====== As described on the course slides, it is very easy to build a web service in Java using Jax-WS 2.0 and JDK 6. Java should be available at the DOS command line on the virtual machines. If it is not then type the following at the DOS command: set PATH=%PATH%;C:\Oracle\Middleware\SOASuite11gR1PS3\jdk160_21\bin Write a web service using JAX-WS as shown on the course slides. This web service will have a single method with the following signature: void log(String firstName, String lastName) The log method simply displays the first and last name to the console screen. Modify Part 1 of this assignment so that the mediator routes to this remote log method rather than the file adapter. When a file is copied to the NewData directory, the remote method should be visited for each person on the file. You may write your web service on any machine with a recent version of java and with a public IP address. If you prefer, you may write your web service on the VM's provided for the class. Simply work from a DOS shell and use the commands as provided in the slide set covering JAX-WS 2.0. The idea behind this part of the assignment is to demonstrate to you how easy it is to build a web service and how that web service may be accessed by the SOA Suite. Submit a screen shot showing your web service displaying the names on the file.