return new Items[0];
}
}
You must register with Amazon to get a subscription ID (see Consuming Amazon Web Services
above). After you get your subscription ID, replace it in the code in Listing 2.
Now you're ready to compile this code. After you have run the setenv.bat file, you should be able to
compile the code easily by running javac *.java:. You get several class files in this directory. For
simplicity of packaging, I copy the entire src directory into a new directory called WEB-INF/classes.
Then, from WEB-INF/classes, I delete all the Java source files; from WEB-INF/src, I delete all the
class files. If you use an integrated development environment (IDE), such as Eclipse, a lot of this
manual work is done for you automatically.
Now you can invoke your Web service and see the results. Use a JSP file to do this.
Write a JSP file to display results from the Web service
Under the amazonclient directory, create a JSP file called searchAmazon.jsp. The code is shown in Listing 3.
In the JSP file shown in Listing 3, you're calling the AmazonClient class that you defined and
receiving an array of Item objects. You then iterate over this array to display the values.
You now have all the code you need.
Final steps before deploying the code
The last step is to set up the deployment descriptors so you can deploy the WAR file on Geronimo.
Under the WEB-INF directory, create two simple XML deployment descriptors. The first is the
standard J2EE WAR deployment descriptor, called web.xml (see Listing 4).
Listing 4. web.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd"
version="2.3">
<display-name>Amazon Sample</display-name>
<welcome-file-list>
<welcome-file>t;searchAmazon.jsp</welcome-file>
</welcome-file-list>
</web-app>
Geronimo requires a geronimo-jetty.xml descriptor. The code is shown in Listing 5. |