Enterprise Integration Zone is brought to you in partnership with:

Martin has posted 1 posts at DZone. View Full User Profile

Advanced Web Service Interoperability In Easy Steps

06.12.2008
| 57859 views |
  • submit to reddit
This article is intended for programmers who are interested in adding additional qualities to their services, clients, or SOA solutions, as well as for beginners in Java web service development. You will learn how to use NetBeans IDE 6.1 to develop Java web service clients and services that can interoperate with Microsoft .NET 3.0 clients and services, how to use encryption and signatures to protect confidentiality and integrity of message transmission without need for SSL, and how to use Reliability features to ensure that none of your application messages are lost or delivered twice.

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

 

AttachmentSize
figure1.png69.91 KB
figure2.png58.05 KB
figure3.png38.63 KB
figure4.png46.74 KB
figure5.png68.87 KB
figure6.png58.29 KB
figure7.png77.2 KB
figure8.png12.83 KB
figure9.png20.8 KB
figure10.png42.9 KB
figure11.png81.43 KB
Published at DZone with permission of its author, Martin Grebac.

(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

Very nice, simple introduction to WSIT functionality.

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.

<a href=" http://www.allsarongs.com/"> Sarong </a>

 

 

 

pankaj barman replied on Wed, 2009/10/07 - 12:20pm

I read this article. Pretty good post. I just stumbled upon your blog and wanted to say,simple introduction to WSIT functionality. Lawyers Devon Park

Pankaj Shukla replied on Thu, 2010/01/21 - 8:37am

Bankruptcy - Debt Mediators help you with debt problems through debt consolidation with debt agreements and advice on bankruptcy.

giminicologu (not verified) replied on Mon, 2010/05/31 - 8:54am

This domain needs some very good service client and the best in giving advices about that are those at Trianz and after having a meeting with them you would certainly know better about how you can improve your services .

Ritesh Kumar replied on Thu, 2011/03/10 - 5:32am

Very Well , and easy ....templates to create a web service ........we(me and my friend) enjoyed.....very much in creating this web service ..thanks alot.....

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

it is true... the author has excellent writing skills. I am really impressed. I will follow the above advice. Mallorca property

Bratnyh Tnyh replied on Mon, 2012/02/13 - 4:40am

website design cumbria - Search Marketing solutions to UK businesses looking to promote their websites on the internet and through the search engines.

Inchanto Delmar replied on Tue, 2012/02/21 - 1:18pm

Very informative and simply article. Thank you. chat

Carla Brian replied on Sun, 2012/04/01 - 5:57pm

I will try this one. I thnk this is really effective. Thanks for sharing it though. - Alan Shortall

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

You must know by now, your post goes to the nitty-gritty of the patient matter. Your quality basically leaves me seeking to know more. Just so you know, i will instantly pick up your feast to keep up currently with your on the internet site. Looking Out thanks is basically my little way of saying excellent job for a amazing source. Take my best needs for your next publish... free cell phone spy software

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

Solicit feedback from a trusted vocational trade school friend or colleague. It will help to have a different perspective. Develop thick skin and use donaire vs mathebula constructive criticism and advice to improve your skills.

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

Hello, I am an officer of united payment service system and have followed these steps those you have described in this post.But I am facing some problem to get access from the PC's those are not at the same port.Is it a problem or not?Again how can I over it?

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!

Term and fees

Paras Onikas replied on Mon, 2013/05/06 - 5:55am

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. bahnspedition

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

I really appreciate the fact that you approach these topics from a stand point of knowledge and information. This is the first time, I visited at your site and became your fan. You are bookmarked. PrimoVPN VPN service

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

Dilshad Ara replied on Mon, 2013/06/03 - 5:39am

I really enjoy simply reading all of your weblogs. Simply I wanted to inform you that you have people like me who appreciate your work. Definitely it is a great post. Hats off to you! The information that you have provided is very helpful.GoPro Hero

Dilshad Ara replied on Mon, 2013/06/03 - 8:52am

It took me studying art in college to really learn the fact that all people have different ideas of what art is and of what beauty is.GoPro Hero HD

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.