Author Interview at SYS-CON.TV

June 18th, 2007
buy cheap doxycycline online cheapest synthroid prices xanax without prescription cheap prozac tablets cheap tramadol acomplia zithromax pharmacy tramadol without a prescription phentermine pills buy generic accutane where to buy cialis cheap zoloft online doxycycline prices cheap generic phentermine nexium online cheap cheap synthroid tablets acomplia online nexium pills buy cheap propecia buy plavix buy diazepam without prescription accutane online stores accutane cheap cheap generic viagra clomid without prescription cheap plavix buy bactrim without prescription tramadol online phentermine without prescription buy synthroid diazepam online stores discount diazepam nexium online stores bactrim online stores order diazepam purchase lasix online purchase lorazepam bactrim prescription buy cheap tramadol zithromax online cheap acomplia generic phentermine plavix for sale cheap plavix tablets cheap tramadol tablets pharmacy lasix lasix sale pharmacy diazepam buy doxycycline accutane prices buy cheap phentermine lasix prices buy cheap nexium synthroid for sale plavix discount buy doxycycline cheap lowest price alprazolam cheap lorazepam online nexium cheap cheap generic cialis discount propecia pharmacy prozac soma discount soma online buy generic flagyl discount nexium cheapest tramadol prices discount viagra levitra generic buy accutane cheap synthroid pharmacy where to buy phentermine acomplia pills viagra sale bactrim pharmacy buy accutane without prescription lowest price acomplia buy lorazepam cheap buy phentermine without prescription diazepam for sale cheapest clomid valium prices buy prozac online tramadol sale clomid online synthroid cheap cheap alprazolam online order soma online buy zithromax phentermine no prescription where to buy lorazepam accutane online where to buy bactrim propecia cheap cheapest valium prices pharmacy lorazepam bactrim for sale price of soma buy cialis order bactrim online lorazepam without prescription zoloft without prescription lowest price diazepam pharmacy clomid cheap propecia buy levitra cheap purchase soma online purchase prozac order zithromax valium no prescription valium prozac prices nexium generic zoloft cheap cheap generic prozac order doxycycline online diazepam pills levitra accutane no prescription buy lorazepam tramadol prices online doxycycline where to buy synthroid buy alprazolam online alprazolam prescription zoloft buy cheap flagyl online zithromax pills online valium acomplia cheap plavix pills cheap zithromax online levitra online stores lorazepam pills order flagyl online doxycycline prescription cheap lorazepam buy acomplia discount acomplia cheapest prozac prices alprazolam without a prescription online synthroid cheap phentermine tablets alprazolam order clomid online cheapest diazepam prices zoloft for sale viagra pharmacy buy cheap lorazepam online clomid online cheap pharmacy tramadol buy cheap soma purchase clomid online cheap doxycycline purchase prozac online purchase cialis flagyl prescription diazepam prices viagra online stores accutane prozac pharmacy bactrim generic buy zoloft without prescription lowest price flagyl clomid pills buy clomid online cialis pharmacy pharmacy phentermine price of clomid buy acomplia online price of prozac phentermine online tramadol buy lasix online levitra without prescription buy cheap xanax online cheapest propecia prices cheapest acomplia prices buy lorazepam online cheap generic xanax accutane without a prescription synthroid without prescription order plavix flagyl without a prescription buy generic clomid lowest price lorazepam order soma order zoloft online propecia sale synthroid discount pharmacy cialis price of lasix prozac pills tramadol without prescription valium pharmacy purchase zoloft online buy cheap lorazepam accutane for sale lowest price clomid levitra no prescription synthroid sale nexium prices lowest price nexium generic lorazepam purchase synthroid xanax online cheap purchase bactrim cheapest alprazolam synthroid generic cheap xanax cheap generic acomplia buy cheap lasix online accutane pharmacy alprazolam pills cheap valium online lowest price cialis plavix generic buy levitra online tramadol online stores buy cheap nexium online zithromax lorazepam online stores acomplia no prescription lorazepam cheap bactrim no prescription buy plavix online lasix generic purchase clomid buy cheap zoloft online buy generic xanax doxycycline online cheap lorazepam online cheap cialis online cheap zithromax for sale generic lasix cheapest synthroid generic nexium purchase phentermine online prozac generic order prozac online clomid prices where to buy tramadol price of phentermine phentermine prescription lowest price propecia cialis online stores discount plavix cheap diazepam soma generic cheapest viagra prices cheapest bactrim prices buy cheap flagyl lorazepam pharmacy buy diazepam online propecia discount buy valium buy zithromax without prescription buy generic tramadol order levitra valium discount nexium online discount doxycycline bactrim cheap propecia prices plavix prices online nexium clomid generic synthroid buy cheap prozac online lasix online stores buy cheap valium online cheap xanax tablets xanax without a prescription buy soma online cheap phentermine online where to buy prozac where to buy alprazolam buy cheap plavix online order phentermine generic clomid buy tramadol cheap prozac cheap propecia tablets generic xanax purchase zithromax levitra online purchase viagra propecia generic generic synthroid buy cheap alprazolam online where to buy propecia acomplia without prescription cheapest diazepam order lorazepam xanax discount where to buy zithromax cheap diazepam tablets price of cialis cheap generic lasix order flagyl buy clomid without prescription diazepam online cheap order accutane zithromax without prescription doxycycline cheap lasix online cheap cheapest plavix alprazolam online buy cheap clomid online buy generic zithromax levitra for sale buy cheap acomplia doxycycline online stores purchase flagyl online nexium generic plavix pharmacy nexium price of alprazolam purchase nexium online buy generic cialis cheap flagyl tablets buy cheap bactrim online buy alprazolam cheap soma sale buy generic synthroid phentermine sale plavix pharmacy buy viagra online xanax purchase cialis online pharmacy flagyl alprazolam no prescription cheapest bactrim buy cialis online clomid sale flagyl online stores tramadol pills propecia online cheap lowest price tramadol cheap valium tablets price of viagra clomid no prescription synthroid pills order doxycycline nexium sale order cialis price of zithromax buy nexium cheap alprazolam for sale discount valium buy generic acomplia generic tramadol plavix without a prescription online clomid cheapest lorazepam prices lasix without a prescription order levitra online cheap cialis online online soma cialis no prescription buy propecia zoloft discount lowest price lasix cheap prozac phentermine generic cheapest levitra levitra pharmacy clomid pharmacy bactrim prices acomplia online cheap where to buy diazepam cheap generic levitra accutane sale tramadol discount cheapest doxycycline purchase acomplia online accutane online cheap cheap generic tramadol price of bactrim order lorazepam online order xanax online purchase levitra flagyl online valium for sale cialis plavix sale cheap levitra tablets price of zoloft purchase viagra online cheap generic zoloft flagyl discount prozac prescription soma pharmacy propecia order propecia online price of flagyl online levitra price of doxycycline bactrim propecia without a prescription acomplia prescription order synthroid zoloft online cheap flagyl sale buy synthroid cheap buy lasix without prescription zoloft without a prescription alprazolam sale buy tramadol without prescription prozac without a prescription flagyl generic buy propecia online cialis prices purchase lasix cheapest nexium purchase diazepam buy lorazepam without prescription buy cialis cheap lorazepam no prescription where to buy accutane xanax online zithromax discount prozac discount synthroid prescription lowest price bactrim discount zithromax accutane generic buy generic bactrim order valium online buy generic lorazepam cheap generic flagyl where to buy zoloft purchase accutane online discount phentermine plavix cheap zithromax cheap cheap generic lorazepam viagra cheap xanax online purchase bactrim online generic valium propecia online stores flagyl pharmacy lowest price valium buy synthroid without prescription cheap viagra online buy cheap lasix cheap doxycycline tablets levitra cheap online alprazolam diazepam pharmacy cheapest nexium prices purchase acomplia xanax pharmacy propecia pharmacy cheap accutane online valium without prescription cheap alprazolam purchase propecia purchase diazepam online cheapest phentermine prices generic zoloft order tramadol clomid online stores plavix no prescription price of synthroid cheap generic propecia cheapest tramadol order alprazolam online buy alprazolam without prescription buy cheap cialis discount levitra where to buy valium cheap prozac online cheap generic soma lorazepam generic buy flagyl cheap price of propecia lowest price soma order acomplia online lowest price viagra buy doxycycline without prescription cheap zithromax tablets flagyl no prescription diazepam without a prescription cheap levitra online prozac online cheap levitra without a prescription buy generic doxycycline buy prozac cheap phentermine for sale buy bactrim cheap pharmacy zithromax cheapest flagyl where to buy flagyl acomplia online stores buy lasix cheap buy cheap propecia online cheap soma cheapest accutane prices pharmacy alprazolam lasix pharmacy cheap zithromax viagra prescription zithromax without a prescription online accutane cheap lasix online acomplia generic cheap flagyl cheap clomid tablets order lasix online cheapest alprazolam prices buy nexium buy cheap clomid synthroid without a prescription accutane pills buy clomid diazepam sale bactrim sale lorazepam cheap doxycycline online valium pills buy soma cheap buy lasix phentermine online stores buy synthroid online online lorazepam lasix no prescription buy generic propecia xanax for sale cheapest zoloft prices buy phentermine cheap plavix online cheap bactrim cheap viagra tablets viagra without prescription cheap generic diazepam buy zoloft cheap order accutane online cheapest soma prices clomid cheap viagra prices phentermine cheap nexium pharmacy discount synthroid lorazepam prices buy xanax flagyl cheap cheap generic doxycycline buy cheap levitra prozac no prescription buy zithromax cheap discount lasix discount tramadol prozac without prescription discount cialis cheap lasix soma prices online phentermine buy propecia without prescription cheap diazepam online online diazepam plavix online cheap order bactrim where to buy soma cheapest xanax prices buy cheap xanax xanax prices cheap clomid online prozac online lowest price zithromax online bactrim cheapest cialis valium online stores synthroid online stores zoloft prices generic acomplia xanax cheap diazepam discount viagra online purchase tramadol online valium without a prescription order zithromax online doxycycline no prescription tramadol clomid for sale pharmacy soma viagra discount synthroid online cheap purchase propecia online viagra online cheap cheap valium cialis without a prescription discount prozac lasix online levitra online cheap cheap soma online buy levitra without prescription buy flagyl online buy cheap zithromax online acomplia discount where to buy plavix cheapest soma soma online cheap nexium without a prescription purchase alprazolam zoloft online tramadol no prescription cheap phentermine online cialis zoloft online stores phentermine online lasix pills valium sale cheap bactrim online clomid prescription generic viagra levitra pills purchase xanax online buy bactrim pharmacy plavix buy cheap diazepam accutane prescription buy cheap diazepam online buy nexium online cheap lorazepam tablets cheap alprazolam tablets price of valium buy cheap synthroid online discount bactrim lasix without prescription generic alprazolam flagyl without prescription online xanax viagra no prescription generic zithromax levitra prices generic cialis buy cheap phentermine online buy clomid cheap buy xanax cheap cialis online buy generic viagra doxycycline discount order clomid online propecia cheap plavix online purchase valium online cheap zoloft generic propecia lorazepam discount buy cheap soma online buy cheap prozac phentermine prices xanax pills online prozac prozac online stores acomplia pharmacy acomplia prices buy viagra lowest price doxycycline cheap acomplia online cheapest levitra prices buy cheap doxycycline buy cheap tramadol online propecia prescription zithromax generic buy tramadol price of plavix lowest price phentermine prozac sale buy alprazolam cheap generic clomid cheapest accutane discount soma purchase synthroid online buy generic plavix doxycycline generic purchase plavix xanax prescription valium generic bactrim online cheap purchase lorazepam online buy xanax online alprazolam online stores price of acomplia zoloft prescription soma pills generic levitra cheap synthroid discount zoloft alprazolam pharmacy viagra cheap cheap accutane cheap generic bactrim buy phentermine online buy flagyl buy levitra cheapest acomplia buy generic phentermine price of tramadol buy cheap zithromax cheap lasix tablets buy plavix cheap nexium discount tramadol pharmacy purchase accutane phentermine online cheap buy cheap acomplia online cialis cheap lasix for sale cheap flagyl online nexium no prescription cheapest lasix prices pharmacy xanax buy tramadol online alprazolam without prescription buy zithromax online order nexium viagra generic buy generic valium where to buy acomplia acomplia without a prescription buy cheap viagra pharmacy levitra order phentermine online buy flagyl without prescription buy accutane buy cheap alprazolam purchase zithromax online lowest price prozac lowest price accutane doxycycline sale bactrim without a prescription alprazolam online cheap cheap generic zithromax pharmacy bactrim levitra discount cheapest plavix prices buy cheap synthroid purchase doxycycline online buy cialis without prescription generic bactrim buy zoloft online synthroid prices propecia online cheap acomplia tablets buy cheap zoloft doxycycline pharmacy cheapest prozac cheap viagra cheap nexium online price of diazepam cheap generic plavix cialis prescription xanax online stores soma prescription plavix without prescription soma for sale lowest price zoloft cheapest zithromax prices cheapest zithromax buy generic alprazolam lorazepam for sale alprazolam generic cialis for sale cheap tramadol online cheapest cialis prices synthroid online order tramadol online buy viagra without prescription order viagra online zithromax no prescription order plavix online flagyl pills cheap cialis tablets cheap clomid diazepam generic buy generic nexium purchase alprazolam online flagyl propecia pills viagra without a prescription propecia for sale cheap cialis flagyl for sale prozac cheap diazepam without prescription zoloft sale order viagra accutane discount doxycycline for sale valium prescription lorazepam online bactrim discount cheapest valium order zoloft alprazolam cheap zoloft generic buy prozac without prescription purchase phentermine online lasix online flagyl cheapest propecia lorazepam sale order synthroid online valium online cheap purchase doxycycline cialis discount lowest price plavix purchase xanax zithromax prices pharmacy propecia buy prozac doxycycline cheap generic synthroid purchase tramadol pharmacy viagra cheapest xanax soma cheap generic accutane soma no prescription order lasix price of nexium buy valium without prescription buy cheap accutane xanax generic doxycycline without a prescription buy cheap levitra online synthroid no prescription cheapest phentermine valium online buy generic levitra cheapest doxycycline prices prozac for sale plavix online stores purchase levitra online lorazepam without a prescription zithromax online stores lasix prescription buy cheap cialis online buy valium online pharmacy zoloft pharmacy doxycycline price of accutane cheapest clomid prices clomid without a prescription valium cheap acomplia sale bactrim without prescription zoloft pharmacy levitra prescription tramadol cheap buy viagra cheap cheapest zoloft buy soma cheap propecia online flagyl online cheap cheap generic alprazolam cheapest lorazepam buy diazepam purchase soma soma without a prescription buy generic diazepam buy cheap viagra online cheap levitra cheap generic valium purchase zoloft order prozac plavix zoloft no prescription discount xanax pharmacy valium clomid discount cheap accutane tablets accutane without prescription soma without prescription soma cheap propecia no prescription propecia without prescription zithromax prescription pharmacy accutane cheapest viagra buy bactrim online diazepam cheap order acomplia buy generic zoloft order valium cheap soma tablets xanax sale buy generic soma viagra for sale cheap zoloft tablets lorazepam prescription diazepam prescription price of xanax nexium without prescription order diazepam online discount flagyl where to buy lasix pharmacy synthroid cheap nexium tablets buy cheap valium generic prozac buy xanax without prescription zithromax sale cheapest lasix bactrim pills lasix where to buy xanax diazepam online order xanax doxycycline pills purchase nexium phentermine pharmacy cialis pills buy doxycycline online buy soma without prescription lowest price levitra clomid alprazolam discount buy phentermine buy generic lasix buy acomplia without prescription cheap bactrim tablets discount lorazepam zithromax online cheap buy diazepam cheap generic soma order propecia generic diazepam order nexium online tramadol online cheap purchase plavix online lasix discount online viagra alprazolam prices phentermine discount where to buy levitra acomplia for sale soma online stores buy cheap bactrim bactrim online price of levitra generic accutane buy cheap accutane online order cialis online nexium for sale where to buy nexium price of lorazepam buy propecia cheap doxycycline online levitra sale cheap nexium cheapest flagyl prices cialis without prescription buy nexium without prescription discount accutane where to buy viagra zoloft pills where to buy doxycycline tramadol for sale buy zoloft tramadol generic cialis sale where to buy clomid online zoloft cheap synthroid online buy accutane online nexium prescription purchase flagyl flagyl prices buy generic prozac discount alprazolam diazepam no prescription buy cheap plavix viagra pills phentermine without a prescription buy valium cheap generic flagyl cialis generic online zithromax cheap generic nexium doxycycline without prescription lasix cheap online plavix buy plavix without prescription generic doxycycline plavix prescription buy acomplia cheap diazepam xanax no prescription discount clomid purchase valium online acomplia lowest price xanax tramadol prescription pharmacy acomplia lowest price synthroid order alprazolam

You can watch an interview about my book that was taped at JavaOne on SYS-CON.TV.

Ajax and Java Web Services Chapter Download

June 18th, 2007

You can download a sample chapter (Chapter 10) at TheServerSide.com

Book Code on Tomcat?

May 22nd, 2007

A couple people have commented in this blog that it would be good to have a version of the sample code from my book that runs on Tomcat. I agree that its a good idea. It shouldn’t be very difficult, since most of the code does not require all of Java EE 5, but only JAX-WS, JAXB, JSR-109 and JSR-181. And the JAX-WS RI runs on Tomcat (see instructions here). Probably, only the JSR-109 specific deployment stuff (e.g., stateless session bean deployment) would not move over.

One idea that I am considering is to put the book code on SourceForge under SVN and then readers who are interested in Tomcat could work with me on porting the code and junits over to Tomcat/JAX-WS. Similarly, if others got interested in doing the same thing for BEA, IBM WebSphere, JBoss, etc. these platforms could be handled as forks from the initial code base. Each port would be fairly straightforward, but there will be some minor wrinkles for each platform.

If you have any comments about this approach, please let me know.

P.S. GlassFish is great by the way and I still think everyone should give it a try :-)

“SOA Using Java Web Services” is a JavaOne 2007 Bestseller!

May 14th, 2007

I just got back from JavaOne and was pleased to see that my book was #8 on the top sellers list at the conference book store.

It was a real thrill to arrive at JavaOne and see my book in the conference bookstore. It was the first time that I saw it in print. My father-in-law (who is not a Java programmer ;-) …) reports that Barnes & Noble told him it will be available in their store starting May 18th. I expect that it will be available on Amazon.com any day now.

Thanks to everyone at JavaOne who bought the book. I hope you like it. Please email me with any comments, suggestions or questions.

About My Book ….

May 2nd, 2007

The following is the preface to my book SOA Using Java(TM) Web Services.

Java became a powerful development platform for Service-Oriented Architecture (SOA) in 2006. Java EE 5, released in May 2006, significantly enhanced the power and usability of the Web Services capabilities on the application server. Then Java SE 6, released in December 2006, incorporated the majority of those capabilities into the standard edition of the Java programming language.

Because robust Web Services technology is the foundation for implementing SOA, Java now provides the tools modern enterprises require to integrate their Java applications into SOA infrastructures.

Of course, Java has had basic Web Services capabilities for some time. JAX-RPC 1.0 was released in June 2002. J2EE 1.4, finalized in November 2003, included JAX-RPC 1.1. So what is significant about the latest versions of the Java Web Services (JWS) APIs?

The answers are power and ease of use. Programmers will find it much easier to build enterprise-class applications with Web Services in Java EE 5 than in J2EE 1.4. Evidence of that is contained in Chapters 9 and 10, which describe an application I developed to integrate online shopping across eBay, Yahoo! Shopping, and Amazon. It’s a pure Java EE 5 application, called SOAShopper, that consumes REST and SOAP services from those shopping sites. SOAShopper also provides its own SOAP and REST endpoints for cross-platform search, and supports an Ajax front-end. SOAShopper would have been a struggle to develop using J2EE 1.4 and JAX-RPC. With the new Java Web Services standards, it was a pleasure to write.

This book focuses on the following standards comprising the new Java Web Services:

  • JAX-WS 2.0 [JSR 224]—The Java API for XML-Based Web Services. The successor to JAX-RPC, it enables you to build and consume Web services with Java.
  • JAXB 2.0 [JSR 222]—The Java Architecture for XML Binding. Tightly integrated with JAX-WS, the JAXB standard controls how Java objects are represented as XML.
  • WS-Metadata [JSR 181]—Web Services Metadata for the Java Platform. WS-Metadata provides annotations that facilitate the flexible definition and deployment of Java Web Services.
  • WSEE 1.2 [JSR 109]—Web Services for Java EE. WSEE defines the programming model and run-time behavior of Web Services in the Java EE container.

These standards contain a few big improvements and many little enhancements that add up to a significantly more powerful Web Services programming platform. New annotations, for example, make it easier to
write Web Services applications. And the delegation, in JAX-WS 2.0 [JSR224], of the Java/XML binding to JAXB 2.0 [JSR 222] greatly improves the usability of JAX-WS as compared with JAX-RPC. The deployment model
has been greatly simplified by WS-Metadata 1.0 [JSR 181] and an improved 1.2 release of WSEE [JSR-109].

Chapters 1 and 2 review these JWS standards in detail and describe how they improve on the previous set of JWS standards. Chapters 3 through 10 focus on writing code. To really understand the power and ease of use of the new Java Web Services, you need to start writing code. And that is primarily what this book is about. Chapters 3 through 10 are packed with code examples showing you how to best take advantage of the powerful features, avoid some of the pitfalls, and work around some of the limitations.

Chapter 11 looks to the future and offers some ideas, along with a prototype implementation, for a WSDL-centric approach to creating Web Services that might further improve JWS as a platform for Service-Oriented Architecture.

I started writing this book in 2002, when JAX-RPC first appeared on the scene. I soon ran into trouble, though, because I wanted it to be a book for programmers and I had a hard time writing good sample code with JAXRPC. Four years later, when I started playing around with beta versions of the GlassFish Java EE 5 application server, I noticed that things had significantly improved. It was now fun to program Web Services in Java and I recommitted myself to finishing this book.

The result is a book with lots of code showing you how to deal with SOAP, WSDL, and REST from inside the Java programming language. Hopefully this code, and the writing that goes with it, will help you master Java Web Services and enable you to start using Java as a powerful platform for SOA.

Charting Book Sales with Amazon’s RESTful Web Services

May 1st, 2007

Being a new author of a book on SOA and Web Services, I've gotten interested in the Amazon sales rankings. I found myself periodically checking the sales rank of my book, and thought it would be nice to be able to create a little application to track it for me.

Today, I spent some time experimenting with the Amazon Web Services RESTful interface to poll the sales rank of several books, and created this application.

I created the application using:

  • Perl (to query Amazon Web Services)
  • MySQL (to store the sales rank time series data)
  • PHP and a charting library called PHP/SWF Charts (to create the graph)

The RESTful query to Amazon Web Services (AWS) that gets the sales rankings is this:

http://webservices.amazon.com/onca/xml?Service=AWSECommerceService\
&AWSAccessKeyId=#####&Operation=ItemLookup&IdType=ASIN\
&ItemId=0130449687,0131347969,0321349601,0596527756\
&ResponseGroup=SalesRank,Small

To run this query, you need to substitute your own AWS Access Key Id for the '#####'. You can get one by going to AWS and creating a free account. This RESTful query uses the ItemLookup operation that returns information about the specified ItemId(s).

The XML that is returned when this query is executed looks like this:

XML:
  1. <!-- snip -->
  2. <Item>
  3. <ASIN>0130449687</ASIN>
  4. <DetailPageURL>
  5. http://www.amazon.com/gp/redirect.html%3FASIN=0130449687%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0130449687%253FSubscriptionId=0K13X6P5GAEPQZ9DV482
  6. </DetailPageURL>
  7. <SalesRank>22353</SalesRank>
  8. <ItemAttributes>
  9. <Author>Mark D. Hansen</Author>
  10. <Manufacturer>Prentice Hall PTR</Manufacturer>
  11. <ProductGroup>Book</ProductGroup>
  12. <Title>SOA Using Java(TM)  Web Services</Title>
  13. </ItemAttributes>
  14. </Item>
  15. <!-- snip -->

To track the sales rank data over time, I use the following Perl script, invoked hourly as a cron job. This Perl code runs this query, parses the XML that gets returned, extracts the sale rank data, and inserts it into a MySQL database.

PERL:
  1. #!/usr/bin/perl
  2. use DBI;
  3. use LWP::Simple;
  4. use XML::Simple;
  5. use Data::Dumper;
  6. //snip
  7. $dbh = DBI->connect($myhost,$myuser,$mypwd);
  8. $content = get("http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=#####&Operation=ItemLookup&IdType=ASIN&ItemId=0130449687,0131347969,0321349601,0596527756&ResponseGroup=SalesRank,Small");
  9. my $xml = XML::Simple->new();
  10. my $doc = $xml->XMLin($content);
  11. foreach $e (@{$doc->{Items}->{Item}}) {
  12.     my $asin = $e->{ASIN};
  13.     my $rank = $e->{SalesRank};
  14.     my $title = $e->{ItemAttributes}->{Title};
  15.     my $insert_stmt = "insert into salesrank (salesrank, asin) values ($rank, \'$asin\')";
  16.     $dbh->do($insert_stmt);
  17. }
  18. $dbh->disconnect();

The last piece of the puzzle is to load the MySQL timeseries data that is collected by the above Perl script into a charting library. For this, I use the charting library called PHP/SWF Charts. The resulting Flash chart is displayed using
this HTML:

HTML:
  1. <BODY bgcolor="#FFFFFF">
  2. <h1>Amazon Sales Rank</h1>
  3. <?php
  4. include "phpswf_charts/charts.php";
  5. echo InsertChart ( "phpswf_charts/charts.swf", "phpswf_charts/charts_library", "booksales.php?uniqueID=" . uniqid(rand(),true), 600, 700 );
  6. ?>
  7. </BODY>
  8. </HTML>

As you can see, the HTML is very simple. The chart that is inserted, however, is configured by the PHP code (booksales.php) shown here:

PHP:
  1. <?php
  2.  
  3.   include "phpswf_charts/charts.php";
  4.  
  5.   mysql_connect($host, $user, $pwd);
  6.  
  7.   // setup chart
  8.   $chart[ 'chart_type' ] = "line";
  9.   $chart [ 'axis_category' ] = array ( 'orientation' => 'diagonal_down',
  10.                                        'size' => '12',
  11.                                        'skip' =>'3',
  12.                                        'margin' => true );
  13.   $chart [ 'axis_value' ] = array ( 'size' => '16' );
  14.   $chart [ 'legend_label' ] = array ( 'size' => '16' );
  15.  
  16.   // get the book titles
  17.   $result = mysql_query("select title from title order by title desc");
  18.   $num_titles = mysql_num_rows($result);
  19.   $arr_titles = array();
  20.   $chart [ 'chart_data' ][ 0 ][ 0 ] = "";
  21.   for ($i=1; $i <= $num_titles; $i++) {
  22.     $arr_titles[mysql_result($result,$i-1)] = $i;
  23.     $chart [ 'chart_data' ][ $i ][ 0 ] = mysql_result($result,$i-1);
  24.   }
  25.  
  26.   // get the timestamps
  27.   $result = mysql_query("select time from salesrank where time> '2007-04-30 20:00:00' group by time asc");
  28.   $num_timestamps = mysql_num_rows($result);
  29.   $arr_timestamps = array();
  30.   for ($i=1; $i <= $num_timestamps; $i++) {
  31.     $arr_timestamps[mysql_result($result,$i-1)] = $i;
  32.     $chart [ 'chart_data' ][ 0 ][ $i ] = mysql_result($result,$i-1);
  33.   }
  34.  
  35.   // populate the chart data
  36.   $qry = "select salesrank, time, title from salesrank, title where salesrank.asin = title.asin and time> '2007-04-30 20:00:00' order by time asc";
  37.   $result = mysql_query($qry);
  38.   for ($i=0; $i <mysql_num_rows($result); $i++) {
  39.    $chart [ 'chart_data' ][$arr_titles[mysql_result($result, $i, "title")]][$arr_timestamps[mysql_result($result, $i, "time")]] = mysql_result($result, $i, "salesrank");
  40.   }
  41.  
  42.   SendChartData ( $chart );
  43.  
  44. ?>

If you find this interesting, and want to learn more about how to build applications using Amazon's RESTful Web services, you might want to check out Chapter 9 in my book . The example illustrated there shows how to build a shopping search engine in Java that integrates Amazon, eBay, and Yahoo! Shopping.

Java EE 6 Specification Withdrawn Over Licensing Concerns

April 19th, 2007

On April 13, Sun Microsystems, the specification lead for Java EE 6 (JSR-313) withdrew the specification because of licensing concerns expressed by members of the Java EE 6 Expert Group.

The following companies abstained from a vote authorizing specification work to proceed: Google, Hewlett-Packard, Intel, Oracle, and SAP. BEA Systems, Fujitsu, IBM, and others did not vote. In choosing to abstain, SAP provided the following comment:

We will need to get more clarification for the new proposed license terms which seem to require a license fee per Java EE profile. If this means a fundamental change in the Java EE licensing model, SAP may decide to vote "NO" on this JSR based on the proposed license terms.

This development is significant, because, these companies are the heavyweights of the Java community.  Java EE 6 cannot proceed unless their issues are addressed.

The Java EE Profiles mentioned by SAP are subsets of Java EE tailored to specific application domains. As Java EE has grown in size and complexity, there has been increasing demand from vendors to componentize Java EE so that a variety of distributions can be created to serve specific markets. One example of such a profile, described in the JSR-313 Request, is for a Java EE Web Profile targeting Web developers. This is how the Web Profile is described in the JSR Request:

Java EE Web Profile - a subset of the Java EE platform targeted at web application development. This profile will provide a more gentle introduction to the Java EE platform, providing only those technologies needed by most web application developers, without the enterprise technologies that sometimes confuse such developers.

Presumably, Expert Group members would prefer a single Java EE license that includes the profiles. However, as described in Section 2.18 of the JSR-313 Request, there are separate licenses (and license fees) for Java EE and the Java EE Web Profile.

For the sake of the entire Java community, I hope that this issue get resolved quickly and that Java EE 6 gets back on track. The concept of Java EE Profiles is vital to keeping server side Java flexible, innovative, and adaptable.

On another note, Java licensing is a hot topic these days, with the Apache Software Foundation's open letter to Sun regarding problems with the terms of the Java SE 5 TCK. There has been some heated discussion of this issue at TheServerSide.com.

Why is Java Web Services so Hard?

April 14th, 2007

This is an excerpt from my book: SOA Using Java Web Services.

If you are a Java developer building enterprise applications today, chances are you are looking at how to best use the Web Services standards built into Java EE 5 to create systems using Service-Oriented Architecture (SOA) principles. These standards include JAX-WS 2.0 (formerly JAX-RPC 1.1) [JSR 224], JAXB 2.0 [JSR 222], Web Services Metadata 2.0 (WS-Metadata) [JSR 181], and Web Services for Java EE 1.2 (WSEE) [JSR 109]. I call these standards, taken together, Java EE 5 Web Services (JavaEE5-WS).

SOA applications are constructed from loosely-coupled Web services. So, naturally, as Enterprise Java developers, we turn to the JavaEE5-WS specifications as our tools for creating SOA applications. Furthermore, the leading Enterprise Java vendors hold out JavaEE5-WS technologies as the development platform of choice for SOA applications.

So, the JavaEE5-WS standards are very important. They are the foundation for SOA. And loosely-coupled SOA applications are critical to corporate competitiveness because they enable business processes to be flexible and adapt to rapidly changing global markets.

Unfortunately, if you are like me, you have found JavaEE5-WS complex and difficult to work with. There often seems to be lots of complex machinery required just to deploy a Java class as a Web Service or create a simple client to consume such services. Sure, you can get the simple “Hello World” application from the Java EE 5 tutorial working. But when you need to deploy your purchase ordering system, things suddenly get a lot more complicated. Either the WSDL you start with gets compiled into a myriad of bizarre classes that have to be manually wrapped and mapped into your real purchasing system. Or, if you start from your Java classes, the WSDL that gets produced doesn’t turn out the way you need it to. If you have run into these problems, then I sympathize with you. So have I, and that is what motivated me to write this book.

Am I Stupid or is Java Web Services Really Hard?

At first, I just thought I was stupid. Prior to getting involved with Java Web Services, I had been running a consulting business. I figured that since I’d been a manager for the past several years, the technologist side of my brain had atrophied. “Keep working at it!”, I said to myself, “and you’ll master this stuff.”. That was 3 years ago, and I’m still struggling to figure out how to best make use of the Enterprise Java standards for Web Services.

During those past 3 years, I’ve mastered topics such as Java generics, reflection, and EJBs. I’ve studied the Apache Axis [AXIS, AXIS2] source code – and even submitted a few patches. I’ve convinced myself that I’m not stupid. Yet, I’m still struggling to develop an intuitive understanding of these complex standards. And I’m not alone.

Richard Monson-Haefel, a distinguished technologist, published a 960 page book on the J2EE 1.4 versions of these Java Web Services specifications in late 2003. 960 pages! That is all the evidence anybody needs to prove that this stuff really is complex. Its not that any one particular topic is all that difficult. Sure, it takes a little while to figure out what the JAX-WS API does – for example. But, the real difficulty is getting your mind around all these APIs and how they relate to the underlying Web Services standards (e.g., XML, WSDL, and SOAP), the HTTP protocol, and the other Java EE container services (e.g., dependency injection). This complexity can make working with the JavaEE5-WS standards feel awkward and unnatural.

During the past two years, there has been a growing chorus of leading technologists - Monson-Haefel among them - bashing the Enterprise Java Web Services standards. And I agree that it is very difficult to do useful SOA-style application development work with the J2EE 1.4 versions of the Java Web Services standards. But, I have trouble agreeing that the specifications themselves are the real problem. Instead, I suspect that the problem itself – creating a general purpose framework for Web Services development – is just plain complicated.

Richard Monson-Haefel posted this email on his blog on April 22, 2006. It summarizes pretty well how a lot of us feel after having spent a lot of time working on Java Web Services:

Dave Podnar’s 5 Stages of Dealing with Web Services

  1. Denial - It’s Simple Object Access Protocol, right?
  2. Over Involvement - OK, I’ll read the SOAP, WSDL, WS-I BP, JAX-RPC, SAAJ, JAX-P,… specs. next, I’ll check the Wiki and finally follow an example showing service and client sides.
  3. Anger - I can’t believe those #$%&*@s made it so difficult!
  4. Guilt - Everyone is using Web Services, it must be me, I must be missing something.
  5. Acceptance - It is what it is, Web Services aren’t simple or easy.

One thesis of this book, simply stated, is that Web Services are hard. We need to accept that fact and move on. Web Services are hard because they are a form of distributed computing and distributed computing is just about the hardest problem in computer science.

Don’t Drink That Kool-Aid

In early 2001, when Ariba, IBM, and Microsoft published WSDL 1.1 as a W3C Note, Web Services were envisioned as a way make distributed computing easier. No longer would developers need to understand CORBA to create cross-platform, distributed applications. Even better, Web Services were envisioned as a technology to make distributed computing over the Internet possible.

Like me, most Java developers bought into this early Web Services vision. It made sense given our experience with the Internet during the 1990s. HTML over HTTP had fueled the astonishing growth of the World Wide Web – a distributed computing platform for people. We believed that standards (like SOAP and WSDL) for XML over HTTP would fuel similar growth for Web Services – a distributed computing platform for business applications.

We all drank that Kool-Aid. We believed that Web Services would make distributed computing easy.

The leaders of the Enterprise Java industry set to work implementing the Web Services vision. Along the way to realizing this vision, the Java industry discovered that they had created some pretty daunting specifications. The people who read the JAX-WS, JAXB, and other Enterprise Java Web Services specifications – including myself – got alarmed. We figured that something must have gone wrong. We assumed that the Expert Groups leading these specifications had gotten off-track. We got disillusioned and bitter about the lost promise of Web Services. We started bickering amongst ourselves about SOAP vs. REST and who is to blame for the complexity of the Java Web Services specifications.

But the complexity problem doesn’t result of choosing the SOAP framework instead of REST. It’s not a result of over-engineering on the part of the Expert Groups. As the Expert Groups got down to brass tacks – trying to make the Web Services vision happen – they rediscovered that distributed computing really is a daunting challenge. SOAP, WSDL, XML, and even REST, are not going to make distributed computing easy.

Certainly the Enterprise Java specifications for Web Services are flawed. But that is to be expected – new technologies always come with mistakes (look at EJB). The mistakes get corrected and flushed out with subsequent versions [1].

As one example of how the Enterprise Java specifications have improved, consider JAX-WS 2.0. Chapters 6 and 7 describe that specification in detail, so for now, I’m just going to give a preview of why I think it’s such a big improvement over JAX-RPC 1.1. For starters, the JAX-RPC data binding has been removed and the specification has been simplified to focus entirely on the WSDL to Java mapping. The XML Schema to Java data binding from JAX-RPC has been eliminated and the data binding features in Java EE 5 are provided by JAXB 2.0. Second, JAX-WS lets you use annotations to control the shape of the WSDL generated from a Java interface. The use of annotations in this manner simplifies and in some cases eliminates the need for the deployment descriptors required to deploy a JAX-RPC service. Third, JAX-WS provides interfaces (Dispatch on the client side, and Provider on the server side) that enable programmers to directly access and work with XML – effectively bypassing the JAXB data binding when they don’t want to use it. For certain, JAX-WS 2.0 could still be improved greatly. The biggest improvement that I can think of would be to provide an alternative binding (in addition to JAXB) that lets the developer work directly the native XML types that are specified in a WSDL and its associated schema. Some type of XML extension to the Java like XJ [XJ] might do the job. Much of the complexity and confusion that developers experience when working with JAX-WS relates to the difficulty of determining how the JAX-WS / JAXB generated classes created by the JAX-WS WSDL compiler map to the XML messages specified in the WSDL. But, that is a whole research area (creating a language that makes it simple to program directly with native XML types) unto itself where we are all still waiting for some breakthroughs. My point here is not that JAX-WS is ideal, but simply that is has improved on JAX-RPC much as EJB 3.0 has improved on EJB 2.1.

To summarize, in the years since the WSDL specification came out, the Enterprise Java community has created from scratch a Java-centric platform for distributed computing based on Web Services technologies. This has been a Herculean task and it shouldn’t surprise anyone that the specifications are difficult to understand! Viewed from this perspective, the JavaEE5-WS standards are not bad at all. In fact, they are a huge step forward toward enabling Enterprise Java to become a SOA development platform. These standards give us the APIs that we need to wrestle with the complexities of Web Services development.

So why are we disillusioned? What lesson should we be learning as we wallow in our disillusionment? I think it is the same lesson that we learn over and over again in this business – “Don’t drink the Kool-Aid”! If we didn’t start out by assuming that Web Services was going to be a silver bullet for distributed computing, we wouldn’t be disillusioned. Instead, we would be optimistic.

Round Pegs and Square Holes - Application Frameworks vs. Toolsets

Realizing that Web Services are intrinsically difficult forced me to rethink my assumptions about the JavaEE5-WS specifications. I no longer believed that these specifications could be significantly simplified. I accepted their complexity as the natural expression of the complexity of the underlying distributed computing problem.

Instead of viewing JavaEE5-WS as an application framework for SOA-style development, I recognized it as a toolset for distributed computing. My problem had not been stupidity, but using the tools incorrectly. Trying to create SOA applications with the JavaEE5-WS technologies is like trying to pound a square peg in a round hole. JavaEE5-WS is not an application framework.

Application frameworks make programming easier by encouraging application development along the lines of a particular architecture. For example, the Apache Struts [STRUTS] framework encourages the applications based on the Model 2 or Model View Controller (MVC) framework. Frameworks offer a layer of abstraction on top of complex toolsets. The layer of abstraction encourages you to program in a certain way. By restricting your programming choices to a sub-set of proven patterns, the framework makes your job easier and less confusing.

Application frameworks can also encourage good design. For example, in Chapter 4, I discuss the use of centralized XML Schema libraries as a mechanism to promote separation of concerns. Such libraries separate the type definition process (a necessary part of creating SOA application with Web Services) from the interface definition process (i.e., creating WSDL representations of individual SOA components). A good SOA framework, therefore, should encourage the use of XML Schema libraries and promote the reuse of schema across WSDL documents.

Application frameworks employ toolsets, but they go beyond toolsets. They encourage a particular manner of using toolsets. Struts, for example, employs Servlets and JavaServer Pages (JSP) among other toolsets. On top of these toolsets, Struts provides a framework of classes (e.g., Action, ActionMapping) for building applications according to the MVC framework.

Thinking through the Struts analogy to Web Services, I realized that JavaEE5-WS provides a toolset but not an application framework. To develop SOA business applications, I really wanted an application framework like Struts - not just the underlying toolset.

Along these lines, I started to think that a useful SOA application framework could be created on a foundation analogous to the ActionMapping and Action classes from Struts. In Struts, an ActionMapping maps an HTTP request to an Action instance that encapsulates calls to the appropriate business logic and dispatches the response to the appropriate View. Likewise, I thought, a SOA application framework could have a customizable Controller layer that receives SOAP messages and dispatches them to the appropriate implementation class. In this approach, the WSDL representation can be thought of as the View (using the MVC analogy), and the Java classes that implement the WSDL are the Model. One current limitation with the JavaEE5-WS toolset that hampers the implementation of this approach is that this dispatching process (analogous to the Controller) is difficult, if not impossible, for the programmer to manipulate. That is because it is hard-wired to correspond to the WSDL to Java mapping defined by JAX-WS. What control the programmer has over dispatching comes through annotations which are embedded in the target Java classes themselves. The JavaEE5-WS design is analogous taking the ActionMapping (Controller) and embedding it in the business logic (Model).

Don’t worry if this analogy to Struts seems confusing at this point. Chapters 9 – 11 explore the concept of a Java application framework for SOA in detail. And you don’t have to be a Struts programmer to understand it. At this point, I just want to give you a flavor for where I’m headed with the application framework idea.

The good news is that, by implementing the JavaEE5-WS toolset, the Enterprise Java vendors have done a great deal of hard work that paves the way for the development of application frameworks for SOA. One just has to get a little clever to work around some of the JavasEE5-WS limitations when attempting to create a SOA application framework.

Epiphany

Understanding the need for SOA application frameworks built on top of the JavaEE5-WS toolset was my epiphany. Instead of trying to create SOA applications using JavaEE5-WS, I began to think about how to create an application framework for SOA.

The result is contained in the last three chapters of this book – an effort to show how application frameworks for SOA can be created using JavaEE5-WS.

Before discussing either the JavaEE5-WS toolset APIs, or how to implement a SOA application framework on top of it, I need to introduce some common terminology in order to discuss the different components of a platform, like Java EE 5 Web Services, or Apache Axis, that enables the development and deployment of Web services. I call such a system a Web Services platform. The next section introduces what I call the Web Services Platform Architecture (WSPA), which provides the common terminology that is used throughout this book for discussing Web Services platforms. Think of the WSPA as our reference architecture. As we discuss Java EE 5 Web Services, we will refer back to the WSPA to discuss its strengths and weaknesses.


 


[1] Note that EJB 3.0 continues to improve and implements advanced Aspect Oriented Programming and Inversion of Control features that its many detractors have been calling for.

Using JAX-WS 2.0 with Castor (instead of JAXB)

April 6th, 2007

In the Java EE 5 Web Services programming model, JAX-WS is tightly integrated with JAXB. To invoke a Web service with JAX-WS, you typically generate Java proxy classes from the Web service’s WSDL using a WSDL compiler tool such as the GlassFish wsimport utility. (For a quick intro to invoking Web Service’s using JAX-WS and the wsimport utility to compile WSDL, see: The Java EE 5 Tutorial). These proxy classes are largely compiled from the WSDL’s schema using the JAXB schema compiler and its XML Schema to Java mapping.

Sometimes, however, you might not want to use JAXB generated classes to invoke a Web service. You might want to use another binding tool like Castor, XML Beans, or JiBX. Replacing JAXB with a tool like Castor makes sense in situations like these:

You want to use your existing Java classes to invoke the Web service. For example, you might have a CreditCard class that you’d like to use, rather than dealing with the machine generated representation of a credit card produced by JAXB.

You can’t or don’t want to add JAXB annotations to your existing classes. If the classes are in production, you may not be able to modify them. Or it may require a lengthy process of modification, unit testing, system testing, etc. to get annotated versions of the classes put into production. In such situations, it may be easier and faster to work with a tool like Castor than JAXB.

You may already be using Castor, or another binding tool that you like, and want to continue using it along with JAX-WS.

If any of these situations describe you, you are in luck. JAX-WS is flexible enough to work with other Java/XML binding tools. Read on to see how it’s done.

This blog shows how you can use the Castor (www.castor.org) Java/XML mapping tool and the JAX-WS Dispatch interface to map existing Java classes to XML message that can be used to interact with Web services. These same techniques can be applied to work with other Java/XML mapping tools as well. I have chosen Castor for this example simply because it is a relatively popular open source tool.

The example used here is a simple purchasing Web service. This service has an operation named requestOrder that enables you to place an order for a list of items and get back an order confirmation. As you can see in the RequestOrder WSDL, the req:requestOrder element used to invoke the requestOrder operation, contains information such as the customer number (req:CUST_NO) and credit card (req:ccard). The req:ccard element has type oms:BUSOBJ_CCARD. If you were to use a WSDL compiler to generate Java proxy classes from this WSDL, the credit card element would be represented by a JAXB generated class compiled from the oms:BUSOBJ_CCARD type defined by the orders.xsd schema.

But, suppose that you want to use your existing credit card class, like the one below. This CreditCard class is a simple structure containing the properties of a credit card (e.g, card number, expiration date). In this example, we will use Castor to bind it to the credit card XML type - oms:BUSOBJ_CCARD - used by the Web service.

JAVA:
  1. public class CreditCard {
  2.   public String type;
  3.   public String num;
  4.   public String expireDate;
  5.   public String name;
  6.   public float amount;
  7.   public String chargeDate;
  8.  
  9.   public static class OrderCcard {
  10.     protected CreditCard ccard;
  11.   }
  12. }

Castor enables you to map existing Java classes to XML. Rather than using annotations, like JAXB, Castor uses an external mapping file. So, to map your classes to XML, you create a mapping file that associates each class and its properties with an XML type or element and its children.

This snippet from the Castor mapping file (the entire file is here), shows how the Java property expireDate gets mapped to the oms:CC_EXPIRE_DATE element in the oms:BUSOBJ_CCARD schema.

Once you have mapped all your classes to the corresponding WSDL schema types (e.g., credit card, items, etc.) you need a wrapper class that bundles these parameters together. This is the class that you will map directly to the contents of the SOAP message that invokes the Web service. In this example, the wrapper class is called MyRequestOrder:

JAVA:
  1. public class MyRequestOrder {
  2.   protected String custno;
  3.   protected String purchordno;
  4.   protected CreditCard ccard;
  5.   protected List itemList;
  6.  
  7.   public CreditCard getCcard() {
  8.     return ccard;
  9.   }
  10.  
  11.   public void setCcard(CreditCard ccard) {
  12.     this.ccard = ccard;
  13.   }
  14.  
  15.   // more setters and getters ...
  16.  
  17. }

You can see how the MyRequestOrder class is mapped to the SOAP request element (req:requestOrder) in the Castor mapping file here.

The code below shows how to invoke the Web service using these classes (i.e., CreditCard, MyRequestOrder, etc.) and the Castor mapping file. At the beginning of this code, the mapping file is loaded into an instance of org.exolab.castor.mapping.Mapping. The Castor Mapping class plays a role similar to the JAXBContext class in that it is used to configure marshallers and unmarshallers. Next, an instance of MyRequestOrder is created along with a ByteArrayOutputStream to marshal it into. The Castor org.exolab.castor.xml.Marshller instance is constructed as a wrapper around the ByteArrayOutputStream. Then, the Marshaller is configured by loading in the Mapping instance using the setMapping method.

JAVA:
  1. public static void main(String[] args) throws Exception {
  2.  
  3.   // load Castor Mapping File
  4.   FileInputStream castorMappingFile = new FileInputStream(args[0]);
  5.   Mapping castorMapping = new Mapping();
  6.   castorMapping.loadMapping(new InputSource(castorMappingFile));
  7.  
  8.   // Use Castor to marshal MyRequestOrder to XML
  9.   MyRequestOrder requestOrder = createRequestOrder();
  10.   Marshaller m = new Marshaller(new OutputStreamWriter(ba));
  11.   m.setMapping(castorMapping);
  12.   m.marshal(requestOrder);
  13.   Source xmlSource = new StreamSource(new StringReader(ba.toString()));
  14.  
  15.   // create Dispatch
  16.   URL wsdlURL = new URL("http://localhost:8080/oms/RequestOrderService?wsdl");
  17.   QName serviceQName =
  18.   new QName("http://www.example.com/req", "RequestOrderService");
  19.   Service service = Service.create(wsdlURL, serviceQName);
  20.   QName portQName =
  21.   new QName("http://www.example.com/req", "RequestOrderPort");
  22.   Dispatch dispatch = service.createDispatch(portQName,
  23.   Source.class, Service.Mode.PAYLOAD);
  24.  
  25.   // invoke web service with Castor generated XML
  26.   Source orderSource = dispatch.invoke(xmlSource);
  27.  
  28.   // ... process the result contained in orderSource …
  29.  
  30. }

The method invocation m.marshal(requestOrder);
marshals the MyRequestOrder instance to an XML document (stored in the ByteArrayOutputStream) according to the rules specified in the Castor mapping file that was loaded. From this point, the Dispatch instance is created an invoked using the XML document generated by Castor.

As you can see from this code snippet, it is the Dispatch interface that enables us to use Castor instead of JAXB as the Java/XML binding mechanism. Using Dispatch, you can send XML directly to the target Web service. That XML can be generated by Castor, XML Beans, JiBX, or whatever your favorite tool binding tool is.

This example is explained in a lot more depth (along with full source code and installation instructions to build and run it with GlassFish) in Chapter 6 of my book SOA Using Java EE 5 Web Services.