Advanced Web Service Interoperability In Easy Steps
NetBeans IDE 6.1 comes with enhanced support for web services development, reflecting the state of industry-wide adopted technologies in web services and Service Oriented Architecture (SOA). NetBeans includes unique and easy to use tools, from visual web service design to enabling powerful technologies for security, reliability or transactions. Bundled together with ready-to-run examples, help and documentation, it provides an easy entrance point for beginners in web service development as well as a broad set of features required by enterprise class solutions and SOA.
METRO Overview
Most of the web service related features in NetBeans are built with the use of Project Metro. Project Metro is the Web services stack (framework) from Sun Microsystems. The stack is integrated in GlassFish V2, a high-performance, production-quality, Java EE 5 compatible application server.
The individual components of Metro can be divided in two categories:
● JAX-WS Implementation – The core Web services platform
● Project Tango, also referred to as Web Services Interoperability Technology (WSIT)
JAX-WS is the core Web Service platform, including all the SOAP message functionality, and Project Tango adds interoperability with Microsoft .NET, Reliability, Security, and Transactions.
Tango Terminology
- Credentials – A set of claims used to prove the identity of a client. They contain an identifier for the client and a proof of the client's identity, such as a password. They may also include information, such as a signature, to indicate that the issuer certifies the claims in the credential.
- Direct Authentication – A type of authentication where the service validates credentials directly with an identity store, such as a database or directory service.
- Impersonation – The act of assuming a different identity on a temporary basis so that a different security context or set of credentials can be used to access the resource.
- Message Layer Security – Represents an approach where all the information that is related to security is encapsulated in the message. In other words, with message layer security, the credentials are passed in the message.
- Mutual Authentication – This is a form of authentication where the client authenticates the server in addition to the server that authenticates the client.
- Security Token – A set of claims used to prove the identity of a client. They contain an identifier for the client and a proof of the client's identity such as a password. They may also include information, such as a signature, to indicate that the issuer certifies the claims in the credential. Most security tokens will also contain additional information that is specific to the authentication broker that issued the token.
- Transport Layer Security – Represents an approach where security protection is enforced by lower level network communication protocols (such as SSL).
- Trusted subsystem (domain) – This is a process where a trusted business identity is used to access a resource on behalf of the client. The identity could belong to a service account or it could be the identity of an application account created specifically for access to remote resources.
Get Ready For Web Services
Implement and Deploy web service
In this example, we show how to develop a web service. We enhance this service with additional capabilities in later chapters. Our service will be able to receive banking orders and store them in a map (for simplicity, we'll skip databases in this example). First, create an Enterprise Application in which we will host our web service, by choosing File -> New Project and selecting Enterprise Application. Click Next and name the application BankApplication. Leave the other values at default. Your wizard screen for Enterprise Application should look similar to Figure 1.
Note: The target server is GlassFish v2. You can have it installed with your NetBeans IDE 6.1 installation if you choose the Full or Web & J2EE download or specifically select GlassFish). If you don't have it, download GlassFish from http://glassfish.dev.java.net, and register it into NetBeans through Tools -> Servers.

Figure 1. Creating Enterprise Application
Now create the web service itself in the EJB module. Right-click BankApplication-ejb node and select New -> Web Service. In the wizard window, name the web service BankOrderService and place it in package bankorder.service as shown on Figure 2.

Figure 2. Creating a Web Service in an EJB module
After clicking Finish, you should see the Visual Designer window for your web service. It is empty, because we did not define any operations for the service yet. Our application should be able to receive orders, and we would like to model them as a Java class with 3 fields for recipient account number, sender account number, and the actual amount being transferred. We will represent this data in a class called bankorder.data.BankOrder. Create the class as shown on Listing 1, and then use the Refactoring -> Encapsulate Fields feature in the editor to generate setters and getters for all fields.
Listing 1. BankOrder.java Class for transferring information about the Banking orders between service and client
package bankorder.data;
public class BankOrder {
private int id;
private String receiverAccount;
private String sender Account;
}
With the data transfer class ready, we are able to implement the web service itself. Return to the web service BankOrderService we created in previous step, click Add Operation in the visual designer, and fill in the details as shown in Figure 3. The operation should return String as a status code to reflect if the order has been successfully submitted or not, and will take our BankOrder data transfer object as a parameter. After you added the operation, select Source tab at the top of the visual designer, which will navigate you to the service source code. There, make sure the implementation of the receiveBankOrder() operation corresponds to Listing 2.

Figure 3. Creating Data Transfer Object
Listing 2. BankOrderService.java Banking Web Service implementation
package bankorder.service;
import bankorder.data.BankOrder;
import java.util.HashMap;
import javax.jws.*;
import javax.ejb.Stateless;
@WebService()
@Stateless()
public class BankOrderService {
public static final HashMap bankOrderStorage = new HashMap();
@WebMethod(operationName = "receiveBankOrder")
public String receiveBankOrder(@WebParam(name = "order")
BankOrder order) {
String status = "";
try {
order.setId(bankOrderStorage.size());
bankOrderStorage.put(order.getId(), order);
return "OK";
} catch (Exception e) {
status += e.getLocalizedMessage();
}
return "FAIL" + status;
}
}
Implementing the web service is the final step, and we're ready to deploy the web service to the application server (GlassFish). Right-click the BankApplication node, and select the Undeploy & Deploy menu item. Once the application is deployed, verify your service by invoking BankOrderService -> Test Web Service action. After invocation, your browser window should show a page similar to Figure 4.

Figure 4. Web Service Tester Page
| Attachment | Size |
|---|---|
| figure1.png | 69.91 KB |
| figure2.png | 58.05 KB |
| figure3.png | 38.63 KB |
| figure4.png | 46.74 KB |
| figure5.png | 68.87 KB |
| figure6.png | 58.29 KB |
| figure7.png | 77.2 KB |
| figure8.png | 12.83 KB |
| figure9.png | 20.8 KB |
| figure10.png | 42.9 KB |
| figure11.png | 81.43 KB |
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Jeff Rubinoff replied on Mon, 2008/06/16 - 11:11am
nasim khan replied on Tue, 2009/10/06 - 12:04am
Very nice simple introductin of wsit.Any way I'll be subscribing to your feed and I hope you post again soon.
pankaj barman replied on Wed, 2009/10/07 - 12:20pm
Pankaj Shukla replied on Thu, 2010/01/21 - 8:37am
giminicologu (not verified) replied on Mon, 2010/05/31 - 8:54am
Ritesh Kumar replied on Thu, 2011/03/10 - 5:32am
Loops Like replied on Sat, 2011/09/17 - 11:55am
Hello,
It is given in Mack OSX. How can I impliment it in Windows? Please give me a suggession.
loops@ san antonio dentists
Jen Worton replied on Sat, 2011/11/12 - 8:21am
Good tutorial - easy to follow and informative. Thanks for the detailed instructions on advanced web services.
Jen @ Christmas Advent Calendars
Lucie Hauri replied on Mon, 2012/01/16 - 4:11am
in response to:
pankaj barman
Bratnyh Tnyh replied on Mon, 2012/02/13 - 4:40am
Inchanto Delmar replied on Tue, 2012/02/21 - 1:18pm
Carla Brian replied on Sun, 2012/04/01 - 5:57pm
Mateo Gomez replied on Mon, 2012/05/21 - 3:45am
this is a great option for web service
mexican dip recipes
Jesse Jaackson replied on Thu, 2012/05/31 - 6:09am
Jesse Jaackson replied on Mon, 2012/06/04 - 4:44am
Really your post is really very good and I appreciate it. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it. You write very well which is amazing. I really impressed by your post.
clubmz reviews
Jesse Jaackson replied on Tue, 2012/06/12 - 2:24am
You have a very good site, well constructed and very interesting i have bookmarked you hopefully you keep posting new stuff.Fine information, thanks to the author. This work is really useful and significant.Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
cell spyware
Eulana Twepo replied on Thu, 2012/06/21 - 12:01pm
Tariq Honey replied on Sat, 2012/11/03 - 8:41am
I truly enjoy reading on this internet site. Very nice post. I have truly enjoyed surfing around your blog posts. is tighten to common. After all I’ll be subscribing to your rss feed and I hope you write again soon! This post shows a report that credible strategy of countenance resulting from which cause your post turn so informative.
vakantiehuis dordogne
Matt Brown replied on Wed, 2012/11/28 - 3:28pm
Herymangter Mangter replied on Thu, 2013/02/07 - 12:17am
Thank you for taking time to share it with the readers, I am more than happy to have come across it. Keep up the good work. grosir jilbab murah
Bryan Low replied on Sun, 2013/02/24 - 4:45am
Bartley Ridge will be accessible via Bartley MRT station on the Circle Line. Commuting to Toa Payoh and Paya Lebar area as well as the city area is therefore very convenient. It is also near to many eateries along the Upper Serangoon area as well as NEX shopping mall.
Bartley Launch
Bryan Low replied on Thu, 2013/03/07 - 10:16pm
Hillview Peak is also near to Bukit Gombak Stadium and Bukit Batok Golf Range. Entertainment for your loved ones and friends is therefore at your fingertips with the full condo facilities as well as the amenities near Hillview Peak.
Hillview Peak
Atiq Rumi replied on Mon, 2013/04/08 - 4:37am
I am in the middle of working on a school report on this topic and your post has helped me with the information I needed to complete it. Thanks.GoPro Australia
Rontu Moniriu replied on Mon, 2013/04/08 - 1:01pm
Definitely right place to discuss this topic here, so I am quite sure they will learn lots of new stuff here than anybody else!
Paras Onikas replied on Mon, 2013/05/06 - 5:55am
Paras Onikas replied on Wed, 2013/05/08 - 2:51am
Definitely right place to discuss this topic here, so I am quite sure they will learn lots of new stuff here than anybody else!
Santa Clara Real Estate
Star Khan replied on Wed, 2013/05/15 - 4:41am
Michael Tompson replied on Thu, 2013/05/16 - 2:24am
Very profound and uniq information, thank you for sharing it with us. The post really helpful for my job.Online Payment Gateway