A Round-Trip Test
All that remains now is to give our application a spin.
Build and run your application by pressing
The application should launch a browser window with your application. I recommend using Internet Explorer (IE) for this, since IE has a nice XML viewer. You can copy and paste the URL into IE if it launched in Safari by default.
Ctrl-click) the hyperlink and choose "Download link to disk." Save the XML in a location you will remember.
In the freshly downloaded XML, copy, paste, and modify some of the item nodes using a text editor. This will simulate new data. Remember to delete the
idvalue for the new nodes so that the application will know that they are new. Here is the XML that I am using if you would prefer not to create your own. Note that it is okay to add line breaks and white space, if this helps you to manage the XML.
Go back to your application in the web browser. Click the Browse... button and select the XML containing the new data items. Click Submit.
The Results item should indicate the successful parsing of the XML file.
Click the hyperlink again to generate fresh XML from the database. You should see your new data items. Notice that, unlike the XML you uploaded, they now have
Adding Web Service Support
Besides accessing the XML through a web page, it would be nice if the tools we plan to create could also request and submit XML via a web service. I will demonstrate this remote interaction in a future article. For now, let us add this functionality to our "hub" application. It's easy!
Add the following line to the end of the
Applicationfunction in the Application.java file:
Isn't WebObjects great? That single line of code will allow applications to connect to the XML class via web services!
There are a few features that would be nice, but I left out for the sake of brevity. If you're feeling ambitious, you could add them yourself. The first is to allow imported XML to add
measureTypes to the database. The second is to allow modification of existing data. Actually, if this project was a real assignment, we probably would not want to add either of these features to protect the critical data already in the database, but it would be a good programming exercise to add this functionality.
In the next article, we will build a Cocoa application to facilitate data entry. Stay Tuned!
Return to the Mac DevCenter