|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Feature JDJ Feature — Java API for XML Web Services (JAX-WS)
Creating a JAX-WS 2.0 Web Service in WebLogic Server 10
By: Deepak Vohra; Ajay Vohra
Jun. 27, 2007 03:00 PM
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.
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 Using the WebLogic server Configuration Wizard create a WebLogic domain, base_domain.
Creating a Web Service 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; 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.
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. YOUR FEEDBACK
LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK SPONSORED BY INFRAGISTICS
BREAKING JAVA NEWS |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||