YOUR FEEDBACK
Who Will Buy Larry Ellison's (World's Largest) Megayacht?
mrs. j wrote: mr. david geffin bought half of the boat...larry ellison sti...
Did you read today's front page stories & breaking news?

AJAXWorld Call For Papers!

SYS-CON.TV

2007 East

  Diamond Sponsor:  
Laszlo
The Browser, the Portal, and the Desktop

  Platinum Sponsors:  

Adobe
'HDUX' - High Definition User Experience with Flex & Apollo
Cynergy
It Takes A Village: Building a World Class RIA Development Group
JackBe
The User is the Killer App. Empower Them!
Tibco
AJAX RIAs and the Service-Oriented Platform

      Gold Sponsors:     
Backbase
AJAX Best Practices
Helmi
Helmi Open Source RIA Platform
ICESoft
Secure Enterprise AJAX with ICEfaces
JetBrains
Is An IDE the Fifth Wheel or Sixth Sense?
Kapow
Serving Mashups from the Long Tail of the Web
Nexaweb
Enterprise Web 2.0 - Programming with Levers, Dials and maybe Switches
Click For 2006 Event Webcasts

TOP THREE LINKS YOU MUST CLICK ON


JDJ Feature — Java API for XML Web Services (JAX-WS)
Creating a JAX-WS 2.0 Web Service in WebLogic Server 10

Digg This!

age 1 of 3   next page »

WebLogic Server 10 Technology Preview supports JEE 5. A feature of JEE 5 is the Java API for XML Web Services (JAX-WS) used to create Web Services and Web Service clients. WebLogic Server 10 provides the jwsc task to create the Web Service artifacts and the clientgen task to create the artifacts for Web Service clients. In this article we'll create an example JAX-WS 2.0 Web Service in WebLogic Server 10 Technology Preview.

JAX-WS is an API to create Web applications and Web Services using the XML-based Web Services functionality. To create a Web Service first create a Service Endpoint Implementation (SEI) class. The implementation class is annotated with javax.jws.WebService annotation. The implementation class must not be abstract or final, and must contain a default public constructor.

A Web Service provides operations that are made available to Web Service clients. So add business methods to the Web Service class. The business methods are public and must not be static or final and may be annotated with the javax.jws.WebMethod annotation. By default all public methods are made available as Web Service operations.

Preliminary Setup
Download and install the WebLogic Server 10 Technical Preview. Download and install Apache Ant, which is required to run Ant tasks to create Web Service and client classes. Download and install JDK 5 if not already installed. It's required to run Apache Ant.

Using the WebLogic server Configuration Wizard create a WebLogic domain, base_domain.

Creating a Web Service
We'll create a JAX-WS 2.0 Web Service. First, set the WebLogic server environment by running the setDomainEnv command script.

C:\BEA\user_projects\domains\base_domain\bin> setDomainEnv

Next, create a project directory in the C:\BEA\user_projects directory with the mkdir command. The directory names should be separated with backslashes instead of forward slashes for the mkdir command to run.

C:\BEA\user_projects> mkdir webservices\hello_webservice

Create an src directory under the project directory that contains subdirectories corresponding to the package name of the Java Web Service class.

C:\BEA\user_projects\webservices\hello_webservice>mkdir src\webservices\hello_webservice

Create a Java Web Service (JWS) file for implementing a JAX-WS Web Service. Annotate the Web Service implementation class HelloWsImpl with the @WebService annotation. JSR 181: Web Services Metadata for the Java Platform defines the standard annotations that can be used in a Java Web Service. The javax.jws.WebService annotation specifies that a class implements a Web Service. The attributes that may be specified in the javax.jws.WebService annotation are discussed in Table 1. All of them are optional.

Add a Web Service method that returns a Hello message. By default all public methods are exposed as Web Service operations. Web Service methods may be annotated with the @WebMethod annotation. Attributes operationName and action may be specified in the WebMethod annotation. The operationName attribute specifies the name of the operation as mapped to the wsdl:operation element in the WSDL. Default value is the method name. For SOAP bindings, the action attribute maps to the SoapAction header in the SOAP messages.

The HelloWsImpl Web Service implementation class is listed below.

package webservices.hello_webservice;
import javax.jws.WebService;

@WebService()
public class HelloWsImpl {

     public String hello(String name) {

         return "Hello "+name +" Welcome to Web Services!";

     }

}

Copy the HelloWsImpl.java class to the C:\BEA\user_projects\webservices\hello_webservice\src\webservices\hello_webservice directory.

WebLogic Server 10 provides WebLogic Web Services Ant tasks to create Web Services and client classes. The jwsc Ant task takes an annotated JWS file as input and generates all the artifacts required to create a WebLogic Web Service.
The generated files include the following.

  1. Java Source files that implement a standard JSR-921 Web Service, such as the Service Endpoint Interface (SEI). For a JWS class HelloWsImpl an SEI HelloWsImplPortType.java gets created.
  2. Standard and WebLogic-specific deployment descriptors. The standard webservices.xml deployment descriptor and the JAX-RPC mapping files get created. The WebLogic-specific Web Services deployment descriptor weblogic-webservices.xml also gets created.
  3. The WSDL file that describes the Web Service.
  4. The XML Schema representation of any Java user-defined types used as parameters or return values of Web Service methods.
A jws sub-element of the jwsc element specifies a JWS file. By default jwsc generates a JAX-RPC 1.1 Web Service. To generate a JAX-WS 2.0 Web Service specify the type attribute of the jws element as type="JAXWS".

Subsequent to generating the Web Service artifacts, jwsc compiles the JWS and Java files and packages the generated artifacts and classes into a Web application WAR file. Jwsc also creates an enterprise application directory structure. The Web Service may be deployed as a WAR file or packaged into an EAR file and deployed. Jwsc generates a WAR file corresponding to each jws element that's a direct sub-element of the jwsc element. JWS files may be grouped by adding the jws elements to a module element, which is a direct sub-element of the jwsc element. If a module element is specified only one WAR file is generated.



Page 1 of 3   next page »
About Deepak Vohra
Deepak Vohra is a Sun Certified Java 1.4 Programmer and a Web developer.

About Ajay Vohra
Ajay Vohra is a senior solutions architect with DataSynapse Inc.

  Subscribe to our RSS feeds now and receive the next article instantly!
In It? Reprint It! Contact advertising(at)sys-con.com to order your reprints!
TODAY'S LATEST JAVA STORIES
The Evolution of Java
Mike Milinkovich, executive director of the Eclipse Foundation, has been kind enough to answer some questions for Java Developer's Journal. Rather than rattle off the usual ones about the name, about why Swing wasn't used, or how much influence IBM still has, Mike has fielded questions
JDJ Feature — Introduction to Maven 2
Maven is a promising application development lifecycle management framework coming from Apache's armory of open source tools. Maven was originally developed as a framework to manage and mitigate the complexities of building the Jakarta Turbine project and soon became a core entity of t
SOA, RIA and the Human Factor
While delivering a talk on SOA I've asked the audience the following question, 'What do you think is the driving force for implementing any technology or architecture in a decent size Enterprise?' The answers were typical: better code re-usability, accessibility? But I was looking for
JDJ Feature — Java API for XML Web Services (JAX-WS)
WebLogic Server 10 Technology Preview supports JEE 5. A feature of JEE 5 is the Java API for XML Web Services (JAX-WS) used to create Web Services and Web Service clients. WebLogic Server 10 provides the jwsc task to create the Web Service artifacts and the clientgen task to create the
What If I Actually Like HTML, CSS, and JavaScript?
I actually find the development experience between a modern web-application framework, Firebug, and current JavaScript libraries more than just bearable, I find it downright pleasant. Even more so because it's born out of the pragmatism of not needing to be perfect. It has evolved over

FEATURED WHITE PAPERS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
Receive Breaking i-Technology News as it Happens...
AJAX Newsletter
Java Newsletter
Open Source/Linux Newsletter
Microsoft .NET Newsletter
Flex Newsletter
Internet TV Newsletter
IT Solution's Guide Newsletter
 
SOA/Web Services Newsletter
Virtualization Newsletter
Web 2.0 Newsletter
ColdFusion Newsletter
PowerBuilder Newsletter
XML Newsletter
Eclipse Newsletter
Your E-Mail: 
State: 
Zip Code: 




TODAY'S TOP LINKS YOU MUST CLICK ON !
ADS BY GOOGLE