Welcome!

Adobe Flex Authors: Liz McMillan, RealWire News Distribution, Maureen O'Gara, Yakov Fain, Keith Swenson

Related Topics: Adobe Flex

Adobe Flex: Article

MX Developer's Journal: Using Breeze Web Services to Display a List of Recordings for a Meeting

The Breeze 5 Meeting module creates SWF files to allow for easy delivery of the recording over the web

The getPrincipleID() method is used to obtain the principleID associated with a username and password. You can do this by calling the user-accounts web service action and then use the xmlSearch() function to verify that the request was returned. If so, extract the principleID from the return XML string. When extracting data from an XML object, it is sometimes helpful to use the cfdump tag on the XML object to take a look at the structure. Otherwise you may run into problems trying to obtain the exact path of the node data you are looking for. In this case, you can locate the principleID using this syntax:

<cfset principalID = xml.results.users.user.XmlAttributes["user-id"]>

Once you have obtained the principleID from the return XML you can return it to the calling script with a cfreturn tag.

The terminateSession() method simply calls the logout web service action with the session ID to end the session on the Breeze server. You will notice by looking at this method that the same set of ColdFusion tags are used to call and interpret an action from the Breeze server. I will parameterize this common task and construct it as a reusable method in the next CFC to increase cohesiveness.

Manipulating XML Data in MeetingManager.cfc
Look at the meetingManager.cfc to see how I acquire the list of recordings and convert them into a query object. The MeetingManager.cfc has two public methods and four private ones. The public methods are init() and getRecordings(). The private methods are scoArray2Query(), sco2Record(), ISO8601ToDate(), and callBreeze(). The getRecordings() method is the only method the outside world cares about. The private methods are used internally in this component and exist to achieve highly cohesive code fragments. If you where to extend the functionality of the MeetingManager component or use it in a different context, you may want to make these methods public. However, for the purposes of this tutorial they should remain private. The getRecordings() takes two parameters, meetingID and a session ID. From these two pieces of information you will be able to call a series of web services actions to find all the data you need on the recordings for the meeting in question. You can start out by calling the sco-contents web service to obtain all the sco objects for this meeting. In the MeetingManager.cfc, I have broken out the task of calling the Breeze server into one common method that takes in parameters and passes back an XML string. This common functionality is contained in the callBreeze() private method. You will use this method to obtain a list of sco's, at which point you then use the xmlSearch() ColdFusion function to filter out all sco's that are not of type archive.

<cfset recordings = xmlSearch(xmlOutput, "//sco[@icon='archive']")>

This type is what Breeze 5 associates with all recording sco's. The ColdFusion function xmlSearch() returns a data structure of type array, which is then pass to the scoArray2Query() private method for conversion to data type query (Figure 1).

You will be converting the XML to a query because when an XML node is returned from Breeze 5, the data is fragmented inside the heavily nested structure of XML, which complicates data manipulation for display. In addition to this, you are going to need to get more details about each recording before producing the list to the user.

Inside the scoArray2Query() method, I take the array of recording nodes and loop through each node and call the sco-info web service action for each recording in the array. You need to do this step to get more detailed information about the recording that is not provided in the initial node returned by the sco-contents web service action. Once this call is made, you will pass the XML to the sco2Record() method to convert the XML into a query record. This is done by using the queryAddRow() and querySetCell() ColdFusion functions. One way that I have found to extract data from an XML node is to use the cfswitch and cfcase tags inside, of a cfloop structure.


<cfloop from="1" to="#arrayLen(node.xmlChildren)#" index="key">

<cfswitch expression="#node.xmlChildren[key].xmlName#">

<cfcase value="date-created" >

... do something ...

</cfcase>

<cfcase value="name">

... do something ...

</cfcase>

...

</cfswitch>

</cfloop>
In this method I also call the ISO8601ToDate() method to convert Breeze dates to ColdFusion data types. This method could be a global function for your application but for this tutorial I have made it part of the MeetingManager component. After the sco2Record() method has finished executing, control is returned to the calling method, scoArray2Query(). This method continues to loop through all of the elements in the array and then returns the resulting query data structure through its cfreturn tag. This returns control to the getRecordings() method, which returns the query to recordingList.cfm.

At this point you can run this code on your server by calling the recordingList.cfm in the browser. To verify that it is working, specify a meetingID to a meeting that has two or three recordings. Once run, your app will display a cfdump structure for the query object.

Where to Go from Here
Now that you understand the pieces of this application, I encourage you to extend the application a bit. One way to extend the application would be to format the resulting query object in HTML and CSS. If you go this route, try to make the recording title a link to the actual recording. To facilitate single sign-on, remove the call to terminateSession() in recordingList.cfm and pass the session ID in the recording URL. Another extension could be to create a new method in MeetingManager.cfc called getPresentations() to return a query of presentations associated with a particular meeting. The getPresentations() method would be almost identical except you would need to filter on type presentation rather than archive.

I would also encourage you to try to integrate this code into your existing application. You may do this by populating the variables at the top of recordingList.cfm by using session, URL, or form-scoped variables. Perhaps you might set the Breeze URL in application.cfm along with the accessKey for Breeze 4.1 users.

Congratulations! You are well on your way to unlocking one of the best kept secrets in the Breeze Web Services API. Today you worked with some of the most important web services actions such as login, logout, sco-info, and user-info. From this point you should be able to experiment with the entire set of web services to best suit your application and integration needs. Happy coding!

This article originally appeared on www.macromedia.com/devnet. Reprinted with permission.

More Stories By Joseph Baarsch

Joseph Baarsch is currently employed as a Systems Developer at the University of Wisconsin ­ Stout and also does software engineering consulting through Spectrum Interactive LLC. In addition to his full time work, Joseph is deepening his understanding of engineering and design principles at the University of Minnesota in their Masters of Science in Software Engineering program.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
SYS-CON India News Desk 03/02/06 07:00:32 PM EST

One of the unique features of the Macromedia Breeze 5 Meeting module is the ability to capture or record the meetings as they take place for future replay. After a recording session finishes, the Breeze 5 Meeting module creates SWF files to allow for easy delivery of the recording over the web.

devGraham 03/01/06 05:15:35 AM EST

// One way to extend the application would be
// to format the resulting query object in
// HTML and CSS. If you go this route, try to
// make the recording title a link to the
// actual recording. To facilitate single
// sign-on, remove the call to
// terminateSession() in recordingList.cfm
// and pass the session ID in the recording
// URL.

Very cool.