Posts tagged as:

rest

Daily del.icio.us for March 27th through April 3rd

by Vinny Carpenter on April 4, 2008

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

{ 0 comments }

Daily del.icio.us for March 26th through March 27th

by Vinny Carpenter on March 27, 2008

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

{ 0 comments }

Daily del.icio.us for January 9th

by Vinny Carpenter on January 9, 2008

  • enunciate - Enunciate is a Web service deployment framework. It is not another Web service stack implementation. Rather, Enunciate leverages existing Web service technologies to provide a mechanism to build, package, deploy, and to clearly, accurately deliver your We
  • Ryan Heaton's Blog: Web Service Programming for the Masses, Part I: Developing the Web Service API - This is the first part of a tutorial will walk you through developing a Web service API that could meet the requirements of all of the above-mentioned use cases. For the sake of clarity and brevity, we'll keep the operations simple, but by the time we're
  • Bob Rhubart's Blog: The SOA Governance Prescription - A significant part of getting your SOA to do what it's supposed to do is getting the people involved in the SOA to do what they're supposed to do
  • Pinaki Poddar's Blog: Slice: OpenJPA for Distributed Databases - Slice is a OpenJPA plug-in for horizontally-partitioned, distributed databases. As distributed databases are being increasingly common in enterprise IT ecosystem, I considered extending OpenJPA to transact against a set of databases instead of a a single
  • Top 10 SQL Server Integration Services (SSIS) and DTS tips - Whether you plan to migrate SQL Server Data Transformation Services (DTS) packages to SQL Server Integration Services (SSIS) or run DTS packages in SQL Server 2005, this expert advice can help
  • How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server - SQL Server Central - In this article, I will show you how to create a new Excel output file and populate the file with discrete spreadsheets containing specific data from a database. We will Integration Services for the task
  • Application Development Trends - SpringSource Offers Spring.NET 1.1 - SpringSource is offering the final release of Spring.NET 1.1. Spring.NET 1.1 supports the ASP.NET Framework for Web development. It enables dependency injection for pages, controls, modules and providers
  • InfoQ: Bruce Johnson discusses Google Web Toolkit - Google Web Toolkit (GWT) tech lead Bruce Johnson discusses the design of GWT, how GWT converts Java into JavaScript, community involvement with GWT, new features in GWT 1.4, and the philosophy behind GWT.
  • Book Review: Google Web Toolkit Applications - Google Web Toolkit, by Ryan Dewsbury, is an excellent book for those looking to use GWT to good advantage, covering most areas of GWT functionality in exceptional detail. It covers software engineering, server integration, custom component composition, CS
  • Adobe - Developer Center : Using BEA Workshop Studio and Java to create Flex-based RIAs - In this tutorial, I walk you through the steps to creating an RIA using Java for the back-end business logic and Flex for the front-end view of the application. I will use the BEA Workshop Studio (Flex Bundle) to create a simple Java mid-tier and a simple
  • smarturls-s2 - Google Code - SmartURLs-S2 is a Struts 2 plugin that provides a rich set of convention based handling for web applications. In addition, it also provides a component framework for developing web application components in separate codebases and the deploying them into a
  • Building Struts 2 Apps Without XML Gluecode - In this article, we jettison XML gluecode for "convention over configuration". Using the SmartURLs plugin for Struts 2, we can autowire Action classes to page templates with search-engine-optimized URIs.
  • Embedding Flickr Photos - In this article, I'll explain how to fetch data from Flickr using a proxy client library and displaying the data in a Visual Web Application page.
  • Atlassian Developer Blog - How to build an Atlassian plugin - There's a single command that will download Tomcat, install Confluence or JIRA, start them up, load sample data, then install your plugin for testing. And once you've started the application once, you can just leave it running while you uninstall and rein
Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Mar 21, 2007 through Mar 27, 2007

by Vinny Carpenter on March 27, 2007

  • Enunciate Your Web Service API - From your source code, Enunciate will build a fully-documented, interoperable web application in the form of a web application archive (war file). A consolidated, annotated XML contract is generated at compile-time. Each service class is published as a SO
  • Uni-Form - One Form to Rule Them All - Uni-Form is an attempt to standardize form markup (xhtml) and css, "modularize" it, so even people with only basic knowledge of these technologies can get nice looking, well structured, highly customizable, semantic, accessible and usable forms.
  • sq1-struts2 - Google Code - 'Apache Struts 2 from Square One' is a training course designed for people who want to create Java web applications, not just quickly, but correctly. Training sessions include a technology primer and a coding exercise. This Project hosts materials used by
  • Scand Unveils dhtmlxCombo, Ajax Combobox with Autocomplete - Scand LLC announced the release of new Ajax-based UI component dhtmlxCombo v1.0. It's a JavaScript combobox control which provides suggestion search and automatic completion functionality to web-based applications
  • Ultimate htaccess Examples | evolt.org - Here's my list of the ultimate htaccess code snippets and examples that I use all the time.
  • Dr. Dobb's | Adobe Woos Web Developers With Apollo Alpha | March 19, 2007 - Apollo is something of an anti-AJAX: It brings elements of online interaction to a desktop client application. Like Flash, Apollo includes a free runtime that users will need to download to their PCs. Using Adobe's free Apollo development kit, programmers
Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Mar 17, 2007

by Vinny Carpenter on March 17, 2007

  • SXC - Simple XML Compiler - SXC (Simple XML Compiler) allows you to created optimized parsers and writers for XML. Through a declarative API you're able to tell SXC what type of XML to expect and what actions to associate with it.
  • On the Stre@m - Flex has become more accessible - The Flex module for Apache and IIS provides web-tier compilation of MXML and ActionScript files on Apache and IIS web servers.
  • Assessing the Survivors of the Java IDE Wars - For enterprise development, I'd say IDEA wins out with its rich support for both J2EE and Java EE 5, followed closely by NetBeans (which also does an impressive job here), and last is Eclipse/MyEclipse (mostly due to their current lack of support for Java
  • An XQuery Servlet for RESTful Data Services - This paper shows how to use XQuery for data integration, and how to expose an XQuery as a RESTful data service using a Java servlet
  • Control.Tabs : Projects : LivePipe - Control.Tabs is a javascript library for creating accessible, flexible & unobtrusive tabbed interfaces in your applications or pages.
Tags: , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Mar 05, 2007 through Mar 06, 2007

by Vinny Carpenter on March 6, 2007

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Feb 27, 2007

by Vinny Carpenter on February 27, 2007

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Feb 25, 2007 through Feb 26, 2007

by Vinny Carpenter on February 26, 2007

Tags: , , , , , , , , , , , , , , , , , ,

Related posts

Daily del.icio.us for Nov 28, 2006

by Vinny Carpenter on November 28, 2006

Tags: , , , , , , , , , , , , , ,

Related posts

Life is beautiful with XMLBeans and XStream

by Vinny Carpenter on January 30, 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:

[code lang="java"]

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 < itemsArray.length; i++) {
AmazonWSObject amzn = processResults(itemsArray, i);
results.add(i, amzn);
}

// During validation, errors are added to the ArrayList
boolean isValid = items.validate(validationOptions);

// Print the errors if the XML is invalid.
if (!isValid) {
for (Object validationError : validationErrors) {
log.error(">> " + 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;
}

[/code]

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:

Tags: , , , , , , , , , , , ,

Related posts

a densely-branched tree