WebCenter - Exposing Twitter Data in an ADF WSRP2 Portlet
By John Brunswick on Nov 02, 2010
How many times have you been asked to consume a web service and display it in a portal? Thankfully development tools have come a long way and it is now trivial to consume a service for display - even if the service consists of XML without an XSD. In this tutorial we will use JDeveloper to consume an XML feed from Twitter (RSS) and display it within WebCenter using ADF.
Check out the video below for a complete walkthrough. Source and steps are beneath the video. Happy coding!
1. Open Twitter and find an account that you would like to follow
2. View the RSS feed for that account and save it to a location on your local disk
3. Open JDeveloper
4. Create a new application called "Twitter Fusion" using the Application Template "Fusion Web Application (ADF)"
5. Navigate to "Application" -> "Project Properties" -> "Java EE Application" and update "Java EE Web Application Name" and "Java EE Web Context Root" to "twitter"
6. Add "WebCenter Portlet Creation Service" to the view project
7. Create folder in "Web Content" called "xsd", this will house the XSD file that let's JDeveloper understand the content coming from Twitter
8. Within the XSD folder create a new file "XML Schema from XML Document", name this file twitter.xsd, browse to the XML document that you saved from Twitter's RSS feed
9. Within the "Web Content" folder create a new JSF page, name it twitter.jspx
10. Run the JSF page and note the URL (http://x.x.x.x:7101/twitter/faces/xsd/twitter.xsd)
11. Using the path copy the URL to the XSD file
12. In the Model project create a new URL Data Control using the RSS feed as the URL and the URL to the XSD that was just created
13. Drill into the newly created Data Control DC_URL -> loadData() -> Return -> rss -> channel -> item and drag and drop the item node into the JSF page
14. On the ADF page select Table -> ADF Read-only Table from the options list
15. Enable "Row Selection" and "Sorting", remove description, guid and source
16. Navigate to the "af:table" node in Structure pane in JDeveloper and select "af:table"
17. In the Property Inspector pane under Apperance -> ColumnStretching select Last
18. On the JSF page click and drag the Title column to the far right of the page
19. Right click the JSF page and select Run to review the page
20. In JDeveloper right click twitter.jspx and select "Create Portlet Entry". Enter TwitterFusion in the first 4 fields and enter a description/
21. Right click twitter.jspx and select Run
22. In your browser adjust the URL to expose the WSDL for the WSRP entry for the new portlet - use the WSRP2 entry (http://x.x.x.x:7101/twitter/portlets/wsrp2?WSDL)
23. Open the Enterprise Manager instance for WebCenter
24. Navigate to the Register Producer section of Enterprise Manager and enter the WSRP2 URL from the WSDL displayed in your browser previously. Call the new entry Twitter Fusion
25. Open your WebCenter instance, navigate to a page and open composer. Select Portlets -> Twitter Fusioon -> and TwitterFusion to add the Twitter portlet to your page.