Advertisements

links for 2006-01-31

January 31, 2006

XML creation, parsing and processing with Java has gotten so much easier with tools like XMLBeans, XStream and many other such tools. I personally love XMLBeans and XStream and I try to use them for all of my XML processing needs. While they both consume XML, they solve different problems. XMLBeans allows you to process XML by binding it to Java types using XML schema that has been compiled to generate Java types that represent schema types. XStream on the other hand allows you to serialize objects to XML and back again using special reflective secret sauce.

I’ve been using these tools for many years now and so you tend to forget just how useful and powerful they are and how productive they make you. Case in point – A friend of mine came to me for help. He was building an application that would allow him to resale items from Amazon on his site and he wanted to use the Amazon eCommerce Web Services to search for products programmatically and update a local database that housed his content. Having played with Amazon E-Commerce Service (ECS) before, I offered to write up a simple application that would make the Web Services call, process the results and present them back to you.

Amazon’s ECS is an API that allows you to access Amazon data and functionality through a Web site or Web-enabled application. ECS follows the standard Web services model: users of the service request data through XML over HTTP (REST) or SOAP and data is returned by the service as an XML-formatted stream of text. In addition to the WSDL, ECS also provides XML schemas for validating the XML output of REST requests. So I decide to use XMLBeans to create my type system using the XML Schema provided by Amazon. XMLBeans provides you with a utility (scomp) to compile your schema into Java XMLBeans classes and metadata. To generate the Java code, use the following command:

scomp –jar amznws.jar AWSECommerceService.xsd

This generates a jar file named amznws.jar, which will contain all of the code needed to bind an XML instance to the Java types representing your schema. In my application, I use HttpClient to make my REST request and then use the XMLBeans generated jar file to process the result. Here’s a snippet of code from my sample class:

	
	        if (StringUtils.isNotBlank(searchCriteria)) {
            String url = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&" +
                    "AWSAccessKeyId=*YOUR_KEY*&AssociateTag=*YOUR_TAG*&Operation=ItemSearch&SearchIndex=Books&" +
                    "Keywords=" + searchCriteria + "&ResponseGroup=Large,Images";


            GetMethod method = new GetMethod(url);
            List results = new ArrayList();

            try {
                int statusCode = client.executeMethod(method);

                if (statusCode != HttpStatus.SC_OK) {
                    log.error("Method failed: " + method.getStatusLine());
                }

                // Read the response body.
                InputStream in = method.getResponseBodyAsStream();
                String xmlPayload = parseISToString(in);

                // Set up the validation error listener.
                ArrayList validationErrors = new ArrayList();
                XmlOptions validationOptions = new XmlOptions();
                validationOptions.setErrorListener(validationErrors);

                ItemSearchResponseDocument items = ItemSearchResponseDocument.Factory.parse(xmlPayload);

                if (items != null) {

                    ItemsDocument.Items[] itemsArray = items.getItemSearchResponse().getItemsArray();
                    for (int i = 0; i > " + validationError + "\n");
                        }
                    }
                } else {
                    log.error("Search returned no results");
                }
            } catch (HttpException e) {
                log.error("Fatal protocol violation: " + e.getMessage());
            } catch (IOException e) {
                log.error("Fatal transport error: " + e.getMessage());
                log.error(e.toString());
            } catch (XmlException e) {
                log.error(e.toString());
            } finally {
                method.releaseConnection();
            }

            return results;
        } else {
            return null;
        }
        
        

As you can tell, HttpClient makes the REST call a snap and XMLBeans makes processing the results easy as well. In total, I spent 3-4 hours getting the application working and a lot of the time was spent figuring out the data set returned from Amazon and trying to come up with a meaningful example. Here is a zip file with the IDEA project that has all the stuff needed to make this work including a simple JSP and a JUnit test class.

Links of Interest:

links for 2006-01-30

January 30, 2006

I was just reading Scoble’s blog entry that talks about EVDO and his experiences and one of the entries in the comment caught my eye. David Rupp pointed out the Kyocera KR1 Broadband EVDO Router that has built In WiFi and basically rebroadcasts EVDO over WiFi (using 802.11g). In addition, it offers 4 10/100 Ethernet ports and works with a ton of EVDO cards. This is awesome and I can’t wait for these devices and EVDO services to become mainstream

I have been testing EVDO services with Cingular and Sprint using my phone (Bluetooth DUN) and I am getting an average of 300k-400k which is not bad, but it would be nice to keep the phone and have 1MB + bandwidth that the dedicated EVDO cards offer. Best of both worlds.

EVDO, spring, cingular, wifi, bluetooth, evdo+router, kyocera, scoble

I guess the title above says it all – Set your VCR, DVR, PC-DVR or Media Center PC to record U2 in High definition. Director Hamish Hamilton gives you a front row seat for all the excitement from the sold out Vertigo tour. Vertigo//2005 features electric performances of songs drawn from across the band’s entire career. Featuring the hits “Vertigo”, “Sometimes You Can’t Make It On Your Own”, “One”, and “The Streets Have No Name”.

There are several replays of this concert on HDNet – Check the schedule here.

dvr, hd, u2, music, concert, live

January 29, 2006

As a recurring feature, I post a list of books that I am currently reading. I am a voracious book collector and (usually) reader as well. With a very demanding job, a wife and a young daugther, I’ve built up quite a backlog and hope to get to most of these books in the next few months. Books I am currently reading include:

Technical Books

Naked Conversations : How Blogs are Changing the Way Businesses Talk with Customers
Robert Scoble, Shel Israel
Wiley
ISBN: 047174719X
Price: $24.95
Rating: 4.5 (Total Reviews: 15)
Sales Rank: 3000

Pragmatic Ajax : A Web 2.0 Primer
Justin Gehtland, Ben Galbraith, Dion Almaer
Pragmatic Bookshelf; 1 edition (February 1, 2006)
ISBN: 0976694085
Price: $23.07
Rating: This item has not yet been released
Sales Rank: 40,075

My Job Went to India : 52 Ways to Save Your Job (Pragmatic Programmers)
Chad Fowler
Pragmatic Bookshelf
ISBN: 0976694018
Price: $19.95
Rating: 4.5 (Total Reviews: 11)
Sales Rank: 18002

Rapid J2EE(TM) Development : An Adaptive Foundation for Enterprise Applications (Hewlett-Packard Professional Books (Paperback))
Alan Monnox
Prentice Hall PTR
ISBN: 0131472208
Price: $44.99
Rating: 4.5 (Total Reviews: 5)
Sales Rank: 605254

CISSP All-in-One Exam Guide, Third Edition (All-in-One)
Shon Harris
McGraw-Hill Osborne Media
ISBN: 0072257121
Price: $79.99
Rating: 4.0 (Total Reviews: 107)
Sales Rank: 779

Translucent Databases
Peter Wayner
Flyzone Sr Llc
ISBN: 0967584418
Price: $29.95
Rating: 4.0 (Total Reviews: 9)
Sales Rank: 111219

Head First HTML with CSS & XHTML (Head First)
Eric Freeman, Elisabeth Freeman
O’Reilly Media, Inc.
ISBN: 059610197X
Price: $34.95
Rating: 5.0 (Total Reviews: 7)
Sales Rank: 967

Non-technical Books

Some of the non-technical books that I am currently reading (or collecting dust in my new book pile) are:

Freakonomics : A Rogue Economist Explores the Hidden Side of Everything
Steven D. Levitt, Stephen J. Dubner
William Morrow
ISBN: 006073132X
Price: $25.95
Rating: 4.0 (Total Reviews: 767)
Sales Rank: 6

State of War : The Secret History of the C.I.A. and the Bush Administration
James Risen
Free Press
ISBN: 0743270665
Price: $26.00
Rating: 4.0 (Total Reviews: 43)
Sales Rank: 87

Why Do Men Have Nipples? Hundreds of Questions You’d Only Ask a Doctor After Your Third Martini
Mark Leyner, Billy Goldberg
Three Rivers Press
ISBN: 1400082315
Price: $13.95
Rating: 3.5 (Total Reviews: 179)
Sales Rank: 246

Dog Days
Ana Marie Cox
Riverhead Hardcover
ISBN: 1594489017
Price: $23.95
Rating: 3.5 (Total Reviews: 20)
Sales Rank: 2581

links for 2006-01-29

January 29, 2006

I hate Roxio and Nero!

January 28, 2006

I have had it – I cannot tell you how frustrating it is to burn a simple f***ing DVD on my computer. Roxio and Nero and all the other DVD burning software that I have tried for Windows just suck and I’ve burnt more coasters than.. Ok. Can’t think of a smart or funny analogy here but I’ve burnt a lot of coasters.

Since we’ve had our daughter, my wife and I have been putting our digital camcorder to good use. I typically capture the movies to my computer before burning them onto a DVD with titles, transitions, pictures and music. I typically use Roxio to burn my DVD and the results are usually hit or miss. After installation, Roxio works fine for a few days or weeks and then just starts burning coasters. So I’ll download Nero and try that and that may work fine for a few weeks before it goes into coaster mode. Usually a simple uninstall and a reinstall fixes the problem with Roxio but that is such a hassle. There are times when that doesn’t work and the typical answer from Roxio support is to rebuild my machine. F*** you – Fix your software so that it works and doesn’t require me to rebuild my machine. In Roxio’s defense, I install any piece of software I can find that seems interesting. I do download a lot of software from any development tool, add-on to utility programs and I must be clobbering something but this is just garbage. Why can’t a program protect its own DLL’s or registry settings or whatever is breaking this

My burner machine configuration is a DELL Pentium 4 (ancient) 2 GHz machine with 1 GB of RAM, Windows XP SP2 and an external USB 2.0 Plextor PX-708UF DVD burner. I own Roxio v7.0 and don’t want to upgrade to v8.0 as I may be facing the same issues. This is enough of a hassle to make me want to buy a MAC. Now that Macs are running a real processor with some performance, it might be worth checking out one of those shiny new MacBook Pros. And if I can run OS X and Vista on the same laptop, that’s a pretty good deal. If only Apple made a Tablet!

Is there any other software out there that will let me burn a DVD without these hassles? There has to be an alternative to this nightmare scenario. If you have a solution that’s working for me, please drop me a line or comment below.

Roxio, Nero, Windows+xp, dvd, software, mac, osx, macbook

links for 2006-01-27

January 27, 2006

Ajax Programming in BEA WebLogic Portal, Part 1 by John Margaglione — John Margaglione explains the rationale for using Ajax programming methods within the BEA WebLogic Portal environment, and offers some best practices and advice to avoid the many pitfalls awaiting the new Ajax programmer.

BEA, Weblogic, portal, ajax, tutorial

Developing Ajax Applications That Preserve Standard Browser Functionality by Mark Schiefelbein — Ajax applications are praised for their richness, interactivity, and responsiveness, which are achieved by loading data asynchronously using the XMLHttpRequest object instead of loading new pages. In this article, Mark Schiefelbein shows how to preserve standard browser history functionality while taking advantage of these Ajax features.

ajax, xmlhttprequest, bea, dev2dev, back+button

FeedLounge vs. FeedDemon

January 26, 2006

I use FeedDemon for all my blog/feed reading and have done so for many years. I really love FeedDemon and I cannot think of a feature that it is missing. Nick Bradbury has done a great job with FeedDemon and it continues to flourish with the NewsGator acquisition. I love the fact that I can keep my feeds and what I’ve read vs. not read in sync between many computers. My typical usage pattern is to use FeedDemon at home and the NewsGator browser interface at home. So if I subscribe to something new or mark something as read at work, I don’t have to do that again at home.

Nick has just put out the beta of the latest version (v2.0) and he’s made a great product even better. My only compliant so far is that the synchronization is renaming my feeds – I will typically rename the feed from the creative title/tag-line to the person’s name so I know whose feed I am reading and it seems like FeedDemon is re-discovering feed attributes on sync.

Along with the beta of FeedDemon, I have been playing with the latest web-based, AJAX enabled feed (RSS/ATOM) reader from Alex King called FeedLounge. Alex has done a great in creating this PHP Phyton based feed reader and it is really very functional for a web interface. I signed up for a paid account and have been playing with it for the past week and you can tell how popular FeedLounge is as I am noticing growing pains. The application has gotten slower and slower and crawls to a halt for a couple of minutes every once in a while. FeedLounge is really a beautifully written web application and offers the 3-pane layout, (among others) which usually sells me on user interfaces. FeedLounge imports OPML files, allows you to tag blog entries and works great in FireFox.

I started my paid subscription of FeedLounge to ‘check-out’ the application and not because I was looking to replace FeedDemon as my primary feed reader. FeedLounge does have all the features that I like and require but there is still something about a fat-client application running on your machine that can run offline. There is nothing missing in FeedLounge but I still can’t seem to make my self switch to it and that’s really odd and something I can’t explain. I am and have always been a huge proponent of web applications over fat-client application but I can’t seem to leave FeedDemon. Maybe FeedDemon is just that good?

Update: Alex corrected me – Apparently most of the backend for FeedLounge is written in Python. Thanks Alex

FeedDemon, FeedLounge, NewsGator, alex+king, nick+bradbury, rss, atom, opml, php, web2.0, ajax, fat-client

links for 2006-01-26

January 26, 2006

  • Download Performancing for Firefox 1.1 | Performancing.com
    Performancing for Firefox 1.1Performancing for Firefox is a full featured blog editor that sits right within Firefox. Just hit F8 or click the little pencil icon at the bottom right to bring up the blog editor and easily post to your WordPress, MovableTypTagged as: blogging extension extensions firefox performancing
  • Presentation Zen: Where to get quotations for presentations? via LifeHacker
    In my presentations, I may have several slides which feature a quote from a famous (sometimes not so famous) individual in the field. The quote may be a springboard into the topic or serve as support or reinforcement for the particular point I’m makingTagged as: presentation
  • Inside Firefox – The Inside Track on Firefox Development
    From a development point of view, the idea of Firefox 2 is to deliver significant user experience enhancements on top of a relatively stable rendering engine as significant retooling is done on the main development trunk for what will become Firefox 3, anTagged as: blog browser features firefox mozilla

links for 2006-01-25

January 25, 2006