Exposing Web Services as Database Views

In recent years, Web Services have become the defacto standard in passing  data between applications.   They make communication between disparate computer languages and architectures relatively simple.  For the most part, we tend to think of web services in terms of traditional application development (Java, .NET, Ruby, PHP, etc …) and inter-process communication.  What if we looked at them from another perspective?  What if we could easily integrate web services into the database?  Make them consumable by Business Intelligence tools, and Data Mining engines WITHOUT having to change the traditional manner in which these tools access data … the standard table and view structure.  SQL is much less complicated than XPath (my opinion)! The remainder of this post is dedicated to demonstrating how to expose a web service as a database view using only resources found in the Oracle database. The method we will explore for exposing a web service as a view utilizes several built-in Oracle database features: PL/SQL (built in packages and the basic fare), XMLTable,  XMLType, and XQuery.

Consuming the Web Service

First and foremost … we have to consume or access a web service before we can expose it’s results in view form.  Web services use a protocol called SOAP (Simple Object Access Protocol).  In order to access the web service, we need to be able to construct, send, and receive SOAP messages.    Oracle provides a built-in PL/SQL package called UTL_HTTP that makes a simple matter to construct a SOAP API.  Tim Hall has created a simple and easy to use PL/SQL based SOAP API and I have created a utility/API which sits on top of his API that makes this step very simple.  Please see my previous post, PL/SQL Web Service Utility: Accessing Web Services with PL/SQL is Simple! , for all the details and code.  The examples in this post will utilize the code and methods introduced in that article.

Taking the SOAP Response and Creating a View …

The data that is received in response to a SOAP query is returned as an XML document.  Using a few other built-in Oracle features (XMLTable, XQuery, and XMLType  … note that XQuery is not available with Oracle 10g XE), we can query that XML data with a SQL statement.   At this point, creating the view is simple.  All we need is that SQL statement and we are in business!  The following two examples demonstrate the processes.  One example demonstrates this method on a simple XML structure returned by a web service provider, and the other example uses a more complex XML structure.  Both of the web services used in these examples are public web services from out in “the wild” (found them on Seekda! ).

Example 1 … Yesterday’s MLB Scores

This example creates a view based on a web service that returns all of the MLB (Major League Baseball) scores for a given date.   I could have used stock data … but what’s the fun in that?  The XML returned by this service has a flat structure, making it very uncomplicated to map elements to query columns using the XMLTable function.

Step 1. Create a PL/SQL function (packaged or stand alone) that returns the Web Service results as an XMLType object.

CREATE OR REPLACE FUNCTION getBaseballScoresWS(p_date VARCHAR2 := TO_CHAR(SYSDATE,’DD MON YYYY’))
RETURN XMLType
ISv_service_def WebServiceUtils.SERVICE_DEFINITION_TYPE;
v_param       WebServiceUtils.service_param_type;
v_param_list  WebServiceUtils.service_param_list := WebServiceUtils.service_param_list();

BEGIN

v_service_def.service_name       :=  ‘MLBScoresStr’;
v_service_def.service_url        :=  ‘http://www.streamingscores.com/livescoresservice.asmx’;
v_service_def.service_action_url :=  ‘http://StreamingScores.com/MLBScoresStr’;
v_service_def.service_ns         :=  ‘http://StreamingScores.com’;

v_param.name      := ‘date’;
v_param.data_type := ‘s:string’;
v_param.value     := p_date;

WebServiceUtils.addParamToCollection(v_param_list,v_param);

v_service_def.service_params := v_param_list;

RETURN XMLType(WebServiceUtils.executeWebService(v_service_def));

END;

The function returns the full  SOAP response with the following structure:

<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<soap:Body>
<MLBScoresStrResponse xmlns=”http://StreamingScores.com”>
<MLBScoresStrResult>
<Game>
<SportID>1</SportID>
<GameId>18931</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Twins</AwayTeam>
<AwayTeamAbbrev>MIN</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Indians</HomeTeam>
<HomeTeamAbbrev>CLE</HomeTeamAbbrev>
<AwayWins>68</AwayWins>
<AwayLosses>68</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>60</HomeWins>
<HomeLosses>76</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>1</AwayScore>
<HomeScore>3</HomeScore>
<AwayPitcher>N. Blackburn</AwayPitcher>
<HomePitcher>D. Huff</HomePitcher>
<Inning>Final</Inning>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:05 PM</StartTime>
<StartTimeUTC>2009-09-06T17:05:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18932</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Yankees</AwayTeam>
<AwayTeamAbbrev>NYY</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Blue Jays</HomeTeam>
<HomeTeamAbbrev>TOR</HomeTeamAbbrev>
<AwayWins>87</AwayWins>
<AwayLosses>49</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>60</HomeWins>
<HomeLosses>75</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>8</AwayScore>
<HomeScore>14</HomeScore>
<AwayPitcher>S. Mitre</AwayPitcher>
<HomePitcher>B. Tallet</HomePitcher>
<Inning>Top 8th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>1</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:07 PM</StartTime>
<StartTimeUTC>2009-09-06T17:07:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18924</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Cubs</AwayTeam>
<AwayTeamAbbrev>CHC</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Mets</HomeTeam>
<HomeTeamAbbrev>NYM</HomeTeamAbbrev>
<AwayWins>68</AwayWins>
<AwayLosses>66</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>61</HomeWins>
<HomeLosses>75</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>2</AwayScore>
<HomeScore>4</HomeScore>
<AwayPitcher>R. Wells</AwayPitcher>
<HomePitcher>M. Pelfrey</HomePitcher>
<Inning>Final</Inning>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:10 PM</StartTime>
<StartTimeUTC>2009-09-06T17:10:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18925</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Cardinals</AwayTeam>
<AwayTeamAbbrev>STL</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Pirates</HomeTeam>
<HomeTeamAbbrev>PIT</HomeTeamAbbrev>
<AwayWins>81</AwayWins>
<AwayLosses>56</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>53</HomeWins>
<HomeLosses>81</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>5</AwayScore>
<HomeScore>4</HomeScore>
<AwayPitcher>J. Piñeiro</AwayPitcher>
<HomePitcher>P. Maholm</HomePitcher>
<Inning>Bot 9th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:35 PM</StartTime>
<StartTimeUTC>2009-09-06T17:35:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18926</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Marlins</AwayTeam>
<AwayTeamAbbrev>FLA</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Nationals</HomeTeam>
<HomeTeamAbbrev>WAS</HomeTeamAbbrev>
<AwayWins>72</AwayWins>
<AwayLosses>64</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>46</HomeWins>
<HomeLosses>90</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>4</AwayScore>
<HomeScore>3</HomeScore>
<AwayPitcher>A. Sánchez</AwayPitcher>
<HomePitcher>J. Martin</HomePitcher>
<Inning>Bot 9th</Inning>
<Runners>1</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:35 PM</StartTime>
<StartTimeUTC>2009-09-06T17:35:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18927</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Reds</AwayTeam>
<AwayTeamAbbrev>CIN</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Braves</HomeTeam>
<HomeTeamAbbrev>ATL</HomeTeamAbbrev>
<AwayWins>62</AwayWins>
<AwayLosses>73</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>70</HomeWins>
<HomeLosses>66</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>2</AwayScore>
<HomeScore>2</HomeScore>
<AwayPitcher>J. Cueto</AwayPitcher>
<HomePitcher>T. Hudson</HomePitcher>
<Inning>Top 10th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>2</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:35 PM</StartTime>
<StartTimeUTC>2009-09-06T17:35:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18933</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Rangers</AwayTeam>
<AwayTeamAbbrev>TEX</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Orioles</HomeTeam>
<HomeTeamAbbrev>BAL</HomeTeamAbbrev>
<AwayWins>76</AwayWins>
<AwayLosses>59</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>55</HomeWins>
<HomeLosses>81</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>0</AwayScore>
<HomeScore>7</HomeScore>
<AwayPitcher>D. Holland</AwayPitcher>
<HomePitcher>J. Guthrie</HomePitcher>
<Inning>Top 9th</Inning>
<Runners>2,3</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>2</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:35 PM</StartTime>
<StartTimeUTC>2009-09-06T17:35:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18934</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Tigers</AwayTeam>
<AwayTeamAbbrev>DET</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Rays</HomeTeam>
<HomeTeamAbbrev>TB</HomeTeamAbbrev>
<AwayWins>74</AwayWins>
<AwayLosses>61</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>72</HomeWins>
<HomeLosses>63</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>5</AwayScore>
<HomeScore>3</HomeScore>
<AwayPitcher>E. Jackson</AwayPitcher>
<HomePitcher>W. Davis</HomePitcher>
<Inning>Top 9th</Inning>
<Runners>3</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>2</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 1:38 PM</StartTime>
<StartTimeUTC>2009-09-06T17:38:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18928</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Phillies</AwayTeam>
<AwayTeamAbbrev>PHI</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Astros</HomeTeam>
<HomeTeamAbbrev>HOU</HomeTeamAbbrev>
<AwayWins>77</AwayWins>
<AwayLosses>56</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>65</HomeWins>
<HomeLosses>70</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>3</AwayScore>
<HomeScore>4</HomeScore>
<AwayPitcher>C. Hamels</AwayPitcher>
<HomePitcher>B. Norris</HomePitcher>
<Inning>Top 8th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 2:05 PM</StartTime>
<StartTimeUTC>2009-09-06T18:05:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18929</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Giants</AwayTeam>
<AwayTeamAbbrev>SF</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Brewers</HomeTeam>
<HomeTeamAbbrev>MIL</HomeTeamAbbrev>
<AwayWins>75</AwayWins>
<AwayLosses>61</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>65</HomeWins>
<HomeLosses>70</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>1</AwayScore>
<HomeScore>1</HomeScore>
<AwayPitcher>J. Sánchez</AwayPitcher>
<HomePitcher>B. Looper</HomePitcher>
<Inning>Top 8th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 2:05 PM</StartTime>
<StartTimeUTC>2009-09-06T18:05:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18935</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Red Sox</AwayTeam>
<AwayTeamAbbrev>BOS</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>White Sox</HomeTeam>
<HomeTeamAbbrev>CHW</HomeTeamAbbrev>
<AwayWins>78</AwayWins>
<AwayLosses>57</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>68</HomeWins>
<HomeLosses>69</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>3</AwayScore>
<HomeScore>0</HomeScore>
<AwayPitcher>J. Lester</AwayPitcher>
<HomePitcher>J. Danks</HomePitcher>
<Inning>Mid 7th</Inning>
<Runners/>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>3</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 2:05 PM</StartTime>
<StartTimeUTC>2009-09-06T18:05:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18936</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Angels</AwayTeam>
<AwayTeamAbbrev>LAA</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Royals</HomeTeam>
<HomeTeamAbbrev>KC</HomeTeamAbbrev>
<AwayWins>80</AwayWins>
<AwayLosses>54</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>51</HomeWins>
<HomeLosses>84</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>7</AwayScore>
<HomeScore>2</HomeScore>
<AwayPitcher>J. Saunders</AwayPitcher>
<HomePitcher>L. Hochevar</HomePitcher>
<Inning>Bot 6th</Inning>
<Runners>1,2,3</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>1</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 2:10 PM</StartTime>
<StartTimeUTC>2009-09-06T18:10:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18930</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>D’Backs</AwayTeam>
<AwayTeamAbbrev>ARZ</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Rockies</HomeTeam>
<HomeTeamAbbrev>COL</HomeTeamAbbrev>
<AwayWins>61</AwayWins>
<AwayLosses>76</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>76</HomeWins>
<HomeLosses>60</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>1</AwayScore>
<HomeScore>4</HomeScore>
<AwayPitcher>Y. Petit</AwayPitcher>
<HomePitcher>J. De La Rosa</HomePitcher>
<Inning>Bot 3rd</Inning>
<Runners>1,2</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>2</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 3:10 PM</StartTime>
<StartTimeUTC>2009-09-06T19:10:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>18937</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Mariners</AwayTeam>
<AwayTeamAbbrev>SEA</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Athletics</HomeTeam>
<HomeTeamAbbrev>OAK</HomeTeamAbbrev>
<AwayWins>72</AwayWins>
<AwayLosses>65</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>60</HomeWins>
<HomeLosses>76</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>1</AwayScore>
<HomeScore>0</HomeScore>
<AwayPitcher>D. Fister</AwayPitcher>
<HomePitcher>G. González</HomePitcher>
<Inning>Bot 1st</Inning>
<Runners>1,2</Runners>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>1</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 4:05 PM</StartTime>
<StartTimeUTC>2009-09-06T20:05:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
<Game>
<SportID>1</SportID>
<GameId>19401</GameId>
<AwayTeamID>0</AwayTeamID>
<AwayTeam>Padres</AwayTeam>
<AwayTeamAbbrev>SD</AwayTeamAbbrev>
<HomeTeamID>0</HomeTeamID>
<HomeTeam>Dodgers</HomeTeam>
<HomeTeamAbbrev>LAD</HomeTeamAbbrev>
<AwayWins>60</AwayWins>
<AwayLosses>77</AwayLosses>
<AwayTies>0</AwayTies>
<HomeWins>81</HomeWins>
<HomeLosses>56</HomeLosses>
<HomeTies>0</HomeTies>
<AwayRank>0</AwayRank>
<HomeRank>0</HomeRank>
<AwayScore>0</AwayScore>
<HomeScore>0</HomeScore>
<AwayPitcher>T. Stauffer</AwayPitcher>
<HomePitcher>H. Kuroda</HomePitcher>
<Inning>0</Inning>
<Balls>0</Balls>
<Strikes>0</Strikes>
<Outs>0</Outs>
<TimeRemaining>0</TimeRemaining>
<StoppageTime>0</StoppageTime>
<StartTime>9/06 8:10 PM</StartTime>
<StartTimeUTC>2009-09-07T00:10:00Z</StartTimeUTC>
<TimeZoneOffset>240</TimeZoneOffset>
<TimeTBD>false</TimeTBD>
<HasTip>false</HasTip>
</Game>
</MLBScoresStrResult>
</MLBScoresStrResponse>
</soap:Body>
</soap:Envelope>

Step 2. Create a Query and View from the Resulting XML

Now that we have the XML, we use the XMLTable function and an XQuery expression to create a query and define a view based on this query (Notice the use of the namespace below …  if it’s specified in the XML, it must be used when parsing it.):

CREATE OR REPLACE VIEW MLB_SCORES_VIEW AS
SELECT
HomeTeam,
HomeTeamAbbrev,
AwayTeam,
AwayTeamAbbrev,
HomeScore,
AwayScore,
HomePitcher,
AwayPitcher,
CurrentInning,
Balls,
Strikes,
Outs,
TimeRemaining
FROM
XMLTable(XMLNamespaces(‘http://StreamingScores.com’ AS “x”),
‘for $i in $xml return $i//x:Game’
PASSING getBaseballScoresWS  as “xml”
COLUMNS
HomeTeam          VARCHAR2(100) PATH ‘x:HomeTeam’,
HomeTeamAbbrev    VARCHAR2(4)   PATH ‘x:HomeTeamAbbrev’,
AwayTeam          VARCHAR2(100) PATH ‘x:AwayTeam’,
AwayTeamAbbrev    VARCHAR2(4)   PATH ‘x:AwayTeamAbbrev’,
HomeScore         NUMBER(3)     PATH ‘x:HomeScore’,
AwayScore         NUMBER(3)     PATH ‘x:AwayScore’,
HomePitcher       VARCHAR2(100) PATH ‘x:HomePitcher’,
AwayPitcher       VARCHAR2(100) PATH ‘x:AwayPitcher’,
CurrentInning     VARCHAR2(50)  PATH ‘x:Inning’,
Balls             NUMBER(1)     PATH ‘x:Balls’,
Strikes           NUMBER(1)     PATH ‘x:Strikes’,
Outs              NUMBER(1)     PATH ‘x:Outs’,
TimeRemaining     VARCHAR2(50)  PATH ‘x:TimeRemaining’
) a
/

Example 2.  What’s Showing at the Movies …

This example uses a web service that lists theaters,  movies, and movie times for a given zipcode.  The steps are exactly same as in the previous example.  However, this example is little more complex.  The XML returned by this web service doesn’t lend itself as easily to be queried.  In the previous example the resulting XML had more of a flattened structure (one to one relationships), where as the XML returned in this example has more of relational structure (one to many relationships), which means we have to manipulate the XML into a flattened structure using an XQuery FLWOR (FOR, LET, WHERE, ORDER BY, RETURN) expression.

Step 1. Create the Function to reeturn our XML from the Web Service …

CREATE OR REPLACE FUNCTION getMovieListWS(p_zipcode VARCHAR2 := ’28216′,
p_radius  VARCHAR2 := ’5′)  RETURN XMLType
IS

v_service_def WebServiceUtils.SERVICE_DEFINITION_TYPE;
v_param       WebServiceUtils.service_param_type;
v_param_list  WebServiceUtils.service_param_list := WebServiceUtils.service_param_list();

BEGIN

v_service_def.service_name       :=  ‘GetTheatersAndMovies’;
v_service_def.service_url        :=  ‘http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx’;
v_service_def.service_action_url :=  ‘http://www.ignyte.com/whatsshowing/GetTheatersAndMovies’;
v_service_def.service_ns         :=  ‘http://www.ignyte.com/whatsshowing’;

v_param.name      := ‘zipCode’;
v_param.data_type := ‘s:string’;
v_param.value     := p_zipcode;

v_param_list.EXTEND;
v_param_list(v_param_list.COUNT) := v_param;

v_param.name      := ‘radius’;
v_param.data_type := ‘s:int’;
v_param.value     := p_radius;

v_param_list.EXTEND;
v_param_list(v_param_list.COUNT) := v_param;

v_service_def.service_params := v_param_list;

RETURN XMLType(WebServiceUtils.executeWebService(v_service_def));

END;
/

Here is the resulting XML response.  Notice the one to many relationship between Theater tag and the Movies tag …

soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<soap:Body>
<GetTheatersAndMoviesResponse xmlns=”http://www.ignyte.com/whatsshowing”>
<GetTheatersAndMoviesResult>
<Theater>
<Name>AMC Northlake 14</Name>
<Address>7325 Northlake Mall Drive, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>11:20am | 2:00pm | 4:50pm | 7:30pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Carriers</Name>
<RunningTime>1 hr 24 mins</RunningTime>
<ShowTimes>10:30am | 12:50pm | 3:10pm | 5:30pm | 7:40pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>11:00am | 1:50pm | 4:40pm | 7:30pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>10:00am | 12:20pm | 3:00pm | 5:40pm | 8:10pm | 10:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>1:40pm | 6:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>10:30am | 1:20pm | 4:10pm | 7:00pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>11:50am | 2:30pm | 5:10pm | 7:50pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>2:30pm | 5:20pm | 7:50pm | 10:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>12:00pm | 3:30pm | 6:50pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>10:20am | 1:10pm | 4:10pm | 7:20pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Post Grad</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>1:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>11:20am | 4:00pm | 9:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
<ShowTimes>4:20pm | 7:15pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>10:00am | 12:20pm | 2:40pm | 5:00pm | 7:20pm | 9:40pm | 10:40am | 1:00pm | 3:20pm | 5:40pm | 8:00pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>1:30pm | 4:20pm | 7:10pm | 10:00pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Observer Omnimax Theatre</Name>
<Address>301 North Tryon Street, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>G</Rating>
<Name>Under the Sea 3D</Name>
<RunningTime>0 hrs 35 mins</RunningTime>
<ShowTimes>1:00pm | 3:00pm | 4:00pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Epicentre Theater 5</Name>
<Address>210 E Trade St., Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>12:30pm | 3:40pm | 6:50pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>12:45pm | 3:50pm | 7:00pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>12:00pm | 3:20pm | 6:25pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Goods: Live Hard. Sell Hard.</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>1:00pm | 4:00pm | 7:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>12:15pm | 3:30pm | 6:35pm | 9:20pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Manor Theatre</Name>
<Address>607 Providence Road, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>Adam</Name>
<RunningTime>1 hr 37 mins</RunningTime>
<ShowTimes>2:00pm | 4:10pm | 7:00pm | 9:10pm</ShowTimes>
</Movie>
<Movie>
<Name>Yoo-Hoo, Mrs. Goldberg</Name>
<ShowTimes>2:10pm | 4:20pm | 7:10pm | 9:20pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Park Terrace Stadium 6</Name>
<Address>4289 Park Road, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>(500) Days of Summer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>1:30pm | 3:50pm | 6:50pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>2:10pm | 4:30pm | 7:30pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Paper Heart</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>4:50pm | 9:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>G</Rating>
<Name>Ponyo</Name>
<RunningTime>1 hr 40 mins</RunningTime>
<ShowTimes>1:40pm | 4:05pm | 7:00pm | 9:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
<ShowTimes>1:50pm | 4:35pm | 7:20pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Cove</Name>
<RunningTime>1 hr 34 mins</RunningTime>
<ShowTimes>1:55pm | 7:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hurt Locker</Name>
<RunningTime>2 hrs 07 mins</RunningTime>
<ShowTimes>1:20pm | 4:15pm | 7:10pm | 10:00pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Movies at Birkdale</Name>
<Address>16950 Birkdale Commons Pkwy, Huntersville, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>(500) Days of Summer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>12:35pm | 2:35pm | 4:40pm | 7:20pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Carriers</Name>
<RunningTime>1 hr 24 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
</Movie>
<Movie>
<Rating>G</Rating>
<Name>Ponyo</Name>
<RunningTime>1 hr 40 mins</RunningTime>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination 3D</Name>
<RunningTime>1 hr 22 mins</RunningTime>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Starlight Cinema 14</Name>
<Address>11240 US Hwy 29, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>11:45am | 2:10pm | 4:35pm | 7:15pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>11:50am | 2:25pm | 4:55pm | 7:35pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>12:30pm | 2:55pm | 5:25pm | 7:50pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>11:55am | 2:25pm | 4:40pm | 7:10pm | 9:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>11:40am | 2:20pm | 5:00pm | 7:45pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>11:50am | 2:15pm | 4:45pm | 7:20pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>12:00pm | 2:35pm | 5:10pm | 7:40pm | 10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>11:40am | 2:55pm | 7:05pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Orphan</Name>
<RunningTime>2 hrs 03 mins</RunningTime>
<ShowTimes>12:05pm | 2:50pm | 7:25pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Post Grad</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>12:20pm | 2:40pm | 4:50pm | 7:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>12:15pm | 2:45pm | 5:20pm | 7:30pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>12:10pm | 2:40pm | 5:10pm | 7:55pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>11:45am | 2:30pm | 5:05pm | 7:45pm | 10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Ugly Truth</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>12:25pm | 2:45pm | 5:15pm | 7:30pm | 9:55pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Phillips Place Stadium 10</Name>
<Address>6911 Phillips Place Ct., Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>12:30pm | 2:50pm | 5:10pm | 7:30pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>12:15pm | 2:55pm | 5:25pm | 8:00pm | 10:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>11:45am | 2:25pm | 5:05pm | 7:50pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>11:50am | 2:15pm | 4:40pm | 7:00pm | 9:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>12:00pm | 2:30pm | 5:00pm | 7:40pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>12:10pm | 3:30pm | 6:45pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>1:00pm | 4:00pm | 7:15pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>12:05pm | 2:20pm | 4:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>12:20pm | 2:45pm | 5:20pm | 7:25pm | 9:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>11:55am | 2:35pm | 5:15pm | 7:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Ugly Truth</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>7:10pm | 9:45pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>AMC Concord Mills 24</Name>
<Address>8241 Concord Mills Blvd, Concord, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>(500) Days of Summer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>10:20am | 12:40pm | 3:00pm | 5:20pm | 7:40pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Aliens in the Attic</Name>
<RunningTime>1 hr 26 mins</RunningTime>
<ShowTimes>10:10am | 12:25pm | 2:35pm | 4:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>10:00am | 12:20pm | 2:45pm | 5:10pm | 7:55pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Carriers</Name>
<RunningTime>1 hr 24 mins</RunningTime>
<ShowTimes>10:15am | 12:25pm | 2:35pm | 4:50pm | 7:05pm | 9:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>2:30pm | 5:10pm | 7:50pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>10:45am | 1:10pm | 3:35pm | 6:00pm | 8:20pm | 10:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>10:25am | 12:45pm | 3:05pm | 5:25pm | 7:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>11:45am | 2:30pm | 5:15pm | 8:00pm | 10:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>10:05am | 11:00pm | 12:25pm | 1:20pm | 2:50pm | 3:45pm | 5:15pm | 6:10pm | 7:45pm | 8:35pm | 10:10pm | 11:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>10:35am | 12:10pm | 1:05pm | 2:45pm | 3:40pm | 5:20pm | 6:15pm | 7:55pm | 8:50pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Harry Potter and the Half-Blood Prince</Name>
<RunningTime>2 hrs 33 mins</RunningTime>
<ShowTimes>12:20pm | 3:40pm | 7:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Ice Age: Dawn of the Dinosaurs</Name>
<RunningTime>1 hr 34 mins</RunningTime>
<ShowTimes>10:35am | 12:55pm | 3:15pm | 5:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>1:00pm | 4:20pm | 7:35pm | 10:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>11:00am | 1:50pm | 4:40pm | 7:30pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Old Partner</Name>
<RunningTime>2 hrs 03 mins</RunningTime>
<ShowTimes>10:30am | 12:30pm | 2:40pm | 4:50pm | 6:50pm | 8:50pm | 10:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Orphan</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>8:00pm | 10:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Play the Game</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>10:40am | 3:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Post Grad</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Shorts</Name>
<RunningTime>2 hrs 06 mins</RunningTime>
<ShowTimes>10:05am | 12:35pm | 2:50pm | 5:05pm | 7:25pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Star Trek</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
<ShowTimes>10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>2:00pm | 4:50pm | 7:40pm | 10:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>10:00am | 12:10pm | 2:25pm | 4:30pm | 6:40pm | 8:55pm | 11:00pm | 12:40pm | 2:55pm | 5:00pm | 7:10pm | 9:25pm | 12:40pm | 2:55pm | 5:00pm | 7:10pm | 9:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 48 mins</RunningTime>
<ShowTimes>1:25pm | 3:50pm | 6:20pm | 8:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Proposal</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>7:05pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>11:40am | 2:20pm | 5:00pm | 7:35pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Name>The Ugly Truth</Name>
<ShowTimes>1:15pm | 6:20pm | 8:40pm | 11:00pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Ayrsley Grand 14</Name>
<Address>9110 Kings Parade Blvd., Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>1:40pm | 4:00pm | 7:20pm | 9:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Carriers</Name>
<RunningTime>1 hr 24 mins</RunningTime>
<ShowTimes>1:50pm | 3:40pm | 5:30pm | 7:35pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>1:20pm | 3:50pm | 7:25pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>1:20pm | 3:20pm | 5:20pm | 7:30pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>1:10pm | 3:00pm | 5:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>1:00pm | 3:40pm | 7:00pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>1:30pm | 3:40pm | 5:40pm | 7:45pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>1:45pm | 4:15pm | 7:40pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>1:45pm | 5:00pm | 8:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>7:10pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>1:00pm | 3:00pm | 5:00pm | 7:15pm | 9:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
<ShowTimes>1:40pm | 4:15pm | 7:20pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination 3D</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>1:15pm | 3:10pm | 5:00pm | 7:10pm | 9:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>4:00pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>1:30pm | 4:20pm | 7:00pm | 9:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Ugly Truth</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>1:50pm | 7:30pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>AMC Carolina Pavilion 22</Name>
<Address>9541 South Boulevard, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>(500) Days of Summer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>6:50pm | 9:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>A Perfect Getaway</Name>
<RunningTime>1 hr 37 mins</RunningTime>
<ShowTimes>4:40pm | 10:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Aliens in the Attic</Name>
<RunningTime>1 hr 26 mins</RunningTime>
<ShowTimes>1:10pm | 3:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>11:15am | 1:55pm | 4:20pm | 7:15pm | 9:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Bandslam</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>12:45pm | 4:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Carriers</Name>
<RunningTime>1 hr 24 mins</RunningTime>
<ShowTimes>11:10am | 1:25pm | 3:30pm | 5:45pm | 8:15pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>11:00am | 1:45pm | 4:30pm | 7:10pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>10:45am | 12:55pm | 3:10pm | 5:35pm | 8:00pm | 10:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Funny People</Name>
<RunningTime>2 hrs 26 mins</RunningTime>
<ShowTimes>6:25pm | 9:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>11:20am | 1:40pm | 3:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>11:25am | 2:25pm | 5:10pm | 7:50pm | 10:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>11:30am | 2:05pm | 4:50pm | 7:35pm | 10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>11:45am | 2:30pm | 5:00pm | 7:30pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Harry Potter and the Half-Blood Prince</Name>
<RunningTime>2 hrs 33 mins</RunningTime>
<ShowTimes>10:55am | 2:15pm | 5:25pm | 8:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Ice Age: Dawn of the Dinosaurs</Name>
<RunningTime>1 hr 34 mins</RunningTime>
<ShowTimes>11:35am | 1:50pm | 4:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>10:45am | 2:00pm | 5:30pm | 7:00pm | 8:45pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>10:50am | 1:35pm | 4:25pm | 7:25pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Orphan</Name>
<RunningTime>2 hrs 03 mins</RunningTime>
<ShowTimes>1:05pm | 7:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Post Grad</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>12:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>11:00am | 1:15pm | 3:40pm | 5:50pm | 8:05pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Spread</Name>
<RunningTime>1 hr 37 mins</RunningTime>
<ShowTimes>7:20pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Taking Woodstock</Name>
<RunningTime>2 hrs 00 mins</RunningTime>
<ShowTimes>3:20pm | 6:40pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>11:05am | 12:20pm | 1:20pm | 2:30pm | 3:25pm | 4:45pm | 5:40pm | 7:05pm | 8:10pm | 9:15pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Goods: Live Hard. Sell Hard.</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>6:35pm | 9:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>6:55pm | 9:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>1:00pm | 4:10pm | 6:45pm | 9:35pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Transformers: Revenge of the Fallen</Name>
<RunningTime>2 hrs 29 mins</RunningTime>
<ShowTimes>11:40am | 3:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Up</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>11:50am | 2:35pm | 4:55pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Cinemark Movies 10</Name>
<Address>9508 Northeast Ct, Matthews, NC</Address>
<Movies>
<Movie>
<Rating>PG</Rating>
<Name>Bandslam</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>1:40pm | 4:10pm | 7:15pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Ice Age: Dawn of the Dinosaurs</Name>
<RunningTime>1 hr 34 mins</RunningTime>
<ShowTimes>12:45pm | 1:55pm | 3:05pm | 4:15pm | 5:30pm | 6:35pm | 7:45pm | 9:00pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>My Sister’s Keeper</Name>
<RunningTime>1 hr 48 mins</RunningTime>
<ShowTimes>1:45pm | 4:20pm | 7:25pm | 9:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Night at the Museum: Battle of the Smithsonian</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>12:55pm | 3:25pm | 5:55pm | 8:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Star Trek</Name>
<RunningTime>2 hrs 06 mins</RunningTime>
<ShowTimes>1:00pm | 7:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Taking of Pelham 123</Name>
<RunningTime>1 hr 46 mins</RunningTime>
<ShowTimes>3:50pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Transformers: Revenge of the Fallen</Name>
<RunningTime>2 hrs 29 mins</RunningTime>
<ShowTimes>12:30pm | 2:05pm | 3:40pm | 5:15pm | 6:50pm | 8:25pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Up</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>1:05pm | 2:15pm | 3:30pm | 4:35pm | 5:50pm | 6:55pm | 8:10pm | 9:15pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Arboretum Stadium 12</Name>
<Address>8008 Providence Road, Charlotte, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>1:20pm | 4:20pm | 7:30pm | 9:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>1:10pm | 4:25pm | 7:25pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>1:45pm | 4:45pm | 7:45pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>1:15pm | 4:15pm | 7:10pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>1:40pm | 4:40pm | 7:50pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>1:30pm | 4:30pm | 7:40pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>2:00pm | 7:00pm | 10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>1:05pm | 4:00pm | 7:20pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Post Grad</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>1:25pm | 4:10pm | 7:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>1:50pm | 4:50pm | 7:35pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Hangover</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>1:35pm | 4:35pm | 7:55pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>1:00pm | 4:05pm | 7:15pm | 9:45pm</ShowTimes>
</Movie>
</Movies>
</Theater>
<Theater>
<Name>Regal Movies @ Franklin Square</Name>
<Address>3778 E. Franklin Boulevard, Gastonia, NC</Address>
<Movies>
<Movie>
<Rating>PG-13</Rating>
<Name>All About Steve</Name>
<RunningTime>1 hr 39 mins</RunningTime>
<ShowTimes>12:20pm | 2:40pm | 5:05pm | 7:30pm | 9:55pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>District 9</Name>
<RunningTime>1 hr 51 mins</RunningTime>
<ShowTimes>11:55am | 2:30pm | 5:00pm | 7:45pm | 10:20pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Extract</Name>
<RunningTime>1 hr 31 mins</RunningTime>
<ShowTimes>12:35pm | 2:50pm | 5:10pm | 7:20pm | 9:40pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>G-Force</Name>
<RunningTime>1 hr 28 mins</RunningTime>
<ShowTimes>11:50am | 2:15pm | 4:40pm | 7:10pm | 9:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>G.I. Joe: The Rise of Cobra</Name>
<RunningTime>1 hr 58 mins</RunningTime>
<ShowTimes>1:00pm | 4:20pm | 7:25pm | 10:15pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Gamer</Name>
<RunningTime>1 hr 35 mins</RunningTime>
<ShowTimes>12:25pm | 2:45pm | 5:20pm | 7:40pm | 10:05pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Halloween II</Name>
<RunningTime>1 hr 45 mins</RunningTime>
<ShowTimes>12:10pm | 2:35pm | 5:25pm | 8:00pm | 10:30pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Harry Potter and the Half-Blood Prince</Name>
<RunningTime>2 hrs 33 mins</RunningTime>
<ShowTimes>12:00pm | 3:15pm | 6:45pm | 10:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>Inglourious Basterds</Name>
<RunningTime>2 hrs 32 mins</RunningTime>
<ShowTimes>11:45am | 3:00pm | 6:30pm | 9:45pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>Julie &amp; Julia</Name>
<RunningTime>2 hrs 04 mins</RunningTime>
<ShowTimes>1:15pm | 4:15pm | 7:05pm | 9:50pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG</Rating>
<Name>Shorts</Name>
<RunningTime>1 hr 29 mins</RunningTime>
<ShowTimes>12:15pm | 9:20pm | 2:25pm | 4:45pm | 7:00pm</ShowTimes>
</Movie>
<Movie>
<Rating>R</Rating>
<Name>The Final Destination</Name>
<RunningTime>1 hr 22 mins</RunningTime>
<ShowTimes>12:05pm | 12:50pm | 2:10pm | 2:55pm | 4:50pm | 5:30pm | 7:15pm | 7:50pm | 9:25pm | 10:10pm</ShowTimes>
</Movie>
<Movie>
<Rating>PG-13</Rating>
<Name>The Time Traveler’s Wife</Name>
<RunningTime>1 hr 47 mins</RunningTime>
<ShowTimes>1:05pm | 4:25pm | 7:55pm | 10:25pm</ShowTimes>
</Movie>
<Movie>
<Name>Jobs</Name>
</Movie>
</Movies>
</Theater>
</GetTheatersAndMoviesResult>
</GetTheatersAndMoviesResponse>
</soap:Body>
</soap:Envelope>

Step 2. Create the query and define the view.  For this XML document we have use the XQuery FLWOR expression to create a flattened version of the original document.  We do this by taking the Theater tag and it’s immediate child elements and the Movie tag and it’s child elements and making them all attributes of the Movie tags that are the children of each Theater tag.  Giving us a  flattened structure like:

<Movie theater=”blah” address=”blah” name=”blah”  rating=”blah” runtime=”blah” showtimes=”blah></Movie>

Here is the entire view definition with the XMLTable function and XQuery FLWOR expression:

CREATE OR REPLACE VIEW LOCAL_MOVIES_VW AS
SELECT
theatre,
address,
movie,
rating,
runtime,
showtimes
FROM
XMLTable(XMLNamespaces(‘http://www.ignyte.com/whatsshowing’ AS “x”),
‘for $i in $xml//x:Theater
for $x in $i//x:Movie
return <Movie theater=”{$i/x:Name/text()}”
address=”{$i/x:Address/text()}”
name=”{$x/x:Name/text()}”
rating=”{$x/x:Rating/text()}”
runtime=”{$x/x:RunningTime/text()}”
showtimes=”{$x/x:ShowTimes/text()}”></Movie>’
PASSING getMovieListWS  as “xml”
COLUMNS
theatre          VARCHAR2(100) PATH ‘/Movie/@theater’,
address          VARCHAR2(100) PATH ‘/Movie/@address’,
movie            VARCHAR2(100) PATH ‘/Movie/@name’,
rating           VARCHAR2(100) PATH ‘/Movie/@rating’,
runtime          VARCHAR2(100) PATH ‘/Movie/@runtime’,
showtimes        VARCHAR2(100) PATH ‘/Movie/@showtimes’) a
/

Now, we can access the data provided by the web service by simply executing a SQL statement against our newly defined view.

Wrapping It up …

Exposing web services as a view is a great way to take data from non-traditional sources and include it directly into any existing data model.  As always … if you have any questions, please feel free to contact me.

Comments are closed.