This tutorial outlines the steps to consume StrikeIron web services prepackaged with NetBeans IDE 6.1 or 6.0, using the Visual Web designer. Specifically, it will demonstrate how to build a web application that invokes the US Address Verification service to verify the address entered by the user.
Contents
To follow this tutorial, you need the following software and resources.
Both Tomcat and GlassFish can be installed, optionally, with the Web and Java EE distribution of NetBeans IDE. Alternatively, you can visit the GlassFish downloads page or the Apache Tomcat downloads page.
You also need a StrikeIron account in order to access StrikeIron web services. As a NetBeans user, you obtain free StrikeIron hits when you register for a StrikeIron account. For more details, visit http://developer.strikeiron.com/netbeans/freetrial/.
NetBeans IDE 6.0 and 6.1 come prepackaged with a set of popular StrikeIron web services. You can access them by switching to the Services window, expanding the Web Services node, and opening the StrikeIron Services node. There, after a moment while the services load, you should see the following services (in 6.0—6.1 has many more):
Later in the tutorial, we will demonstrate how to consume these web services by dragging and dropping them onto the Visual Web designer.
First, you need to create a web project that is supported by the Visual Web designer.
Creating a project in NetBeans 6.1 includes new options which can be left at the default. For example, the Use Dedicated Folder for Storing Libraries checkbox may be left unselected.
Check Visual Web JavaServer Faces under Frameworks, as shown below:
Click Finish.After you create the USAddressVerificationDemo project, the IDE automatically opens the default Page1.jsp in the Design tab, which contains an empty canvas. On the right-hand side of the canvas, you will see the Palette (available under the Window menu). We will implement the page as shown below: 
Here is how to design the page shown above:
This section shows you code to invoke the US Address Verification service. This code uses the web page you made in Designing the Web Page to collect data and display the result.
public String validateButton_action() {
USAddressVerificationSoapVerifyAddressUSA bean =
this.getUSAddressVerificationSoapVerifyAddressUSA1();
//bean.setUnregisteredUserEmail("your_email_address_here");
bean.setUserID("your_strikeiron_userid_here");
bean.setPassword("your_strikeiron_password_here");
bean.setAddressLine1((String) getAddressLine1TF().getText());
bean.setAddressLine2((String) getAddressLine2TF().getText());
bean.setCityStateZip((String) getCityStateZipTF().getText());
getResultTF().setText(bean.invokeMethod().getAddressStatus());
return null;
}
In order to access StrikeIron web services, you need a StrikeIron userid and password. You can obtain free StrikeIron hits by registering for a StrikeIron account. For more details, visit http://developer.strikeiron.com/netbeans/freetrial/.
To test the application, do the following:

In the Services window, right-click on the StrikeIron Services node and choose Find StrikeIron Services. Type a search word, such as "stock", and press Enter. When the search returns, the results are displayed in a list on the left of the dialog. Select a row to see the service description details.
To use a service, select it and click Add. The new service is added to the StrikeIron folder and is then immediately ready for trying out.
For more information about using NetBeans IDE to develop Java EE applications, see the following resources:
To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE Java EE development features, join the mailing list.
You are viewing a mobilized version of this site...
View original page here