| By Deepak Vohra, Ajay Vohra | Article Rating: |
|
| June 27, 2007 03:00 PM EDT | Reads: |
22,589 |
In addition to the standard attributes some WebLogic specific attributes may be specified in the jwsc ant task. Only the srcdir and destdir attributes are required. The WebLogic specific jwsc attributes are discussed in Table 2.
A jws element specifies a JWS file to compile. A jws element may be specified as a direct sub-element of the jwsc element or be included in a module element, which is a direct sub-element of the jwsc element. The only required attribute of the jws element is file, which specifies the JWS file. Some of the other attributes that may be specified in the jws element are discussed in Table 3.
Next, create a build.xml file to generate the artifacts for a Web Service from the example JWS file. To the build.xml file add a taskdef element for the jwsc task that specifies the class for the jwsc task. Add a target to build the Web Service. Specify a jwsc task with srcdir as src and destdir as output/HelloWsEar. Using a jws element specify the JWS file to be compiled. Specify the type attribute of the jws element as JAXWS as the Web Service is a JAX-WS 2.0 Web Service. The build.xml file is listed below.
<project name="webservices-hello" default="all">
<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<target name="build-service">
<jwsc srcdir="src" destdir="output/HelloWsEar">
<jws file="webservices/hello_webservice/HelloWsImpl.java" type="JAXWS" />
</jwsc></target></project>
Next, we shall run the build-service target to generate the Web Service artifacts. Run the build-service target with the following command.
C:\BEA\user_projects\webservices\hello_webservice>ant build-service
The artifacts for a Web Service get generated and packaged into a WAR file HelloWsImpl.war in the directory C:\BEA\user_projects\webservices\hello_webservice\output\HelloWsEar\webservices\hello_webservice. An exploded directory structure for an EAR application including the application.xml and weblogic-application.xml also get generated. The output from the ant command is shown in Figure 1.
To deploy the Web Service copy the WAR file HelloWsImpl.war to the C:\BEA\user_projects\domains\base_domain\autodeploy directory. Start WebLogic with the command script C:\BEA\user_projects\domains\base_domain\bin\startWebLogic.
When the Web application is deployed the application server and the JAX-WS runtime generate the WSDL file and any additional artifacts required to invoke the Web Service from a client. The WSDL may be accessed with URL http://localhost:7001/HelloWsImpl/HelloWsImplService?WSDL. (Figure 2)
Creating a Client
In this section we'll create a
JAX-RPC Java client for the Web Service created in the previous
section. We'll use the clientgen Ant task to generate the client
component files. First, create a project directory for the client
application.
C:\BEA\user_projects> mkdir \webservices\simple_client
Create an src directory under the project directory. The sub-directories of the src directory should correspond to the package name of the Java client class, which we'll create next
C:\BEA\user_projects\webservices\simple_client> mkdir src\webservices\jaxws\client
Create a Java client application Main.java in package webservices.jaxws.client. In the Java client application create an instance of the HelloWsImplService service.
HelloWsImplService service = new HelloWsImplService();
Obtain a proxy to the service from the service using the getHelloWsImplPort() method.
HelloWsImpl port = service.getHelloWsImplPort();
Invoke the hello(String) method of the service.
result = port.hello("Deepak");
The Java client application Main.java class is listed below.
package webservices.jaxws.client;
public class Main {
public static void main(String[] args) {
HelloWsImplService service = new HelloWsImplService();
HelloWsImpl port = service.getHelloWsImplPort();
String result = null; result = port.hello("Deepak");
System.out.println(result);
}
}
Next, we'll generate the client application artifacts required to invoke the Web Service using the clientgen task. The clientgen task generates the following artifacts.
- The client-side copy of the WSDL file.
- The Java source code for the Stub and Service interface implementations for the Web Service.
- Java classes for any user-defined XML Schema data types defined in the WSDL file.
- JAX-RPC deployment descriptor that describes the mapping between the Java data types and the corresponding XML Schema types in the WSDL file.
Create a build.xml file in the C:\BEA\user_projects\webservices\simple_client directory. Specify the class name for the clientgen task with the taskdef element.
<taskdef name="clientgen"
classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
Published June 27, 2007 Reads 22,589
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Deepak Vohra
Deepak Vohra is a Sun Certified Java 1.4 Programmer and a Web developer.
More Stories By Ajay Vohra
Ajay Vohra is a senior solutions architect with DataSynapse Inc.
![]() |
nayanj 10/26/07 02:49:39 PM EDT | |||
The example give in this article is too simple. Information given in this article can even be found in weblogic documentation.. so what additional value does this article? to me NIL. I would have appreciated a more realistic example where webservice is used along with other libraries like beehive controls and then see how you can jwsc to package this application into an .ear or .war. There are a bunch of cases in which jwsc gives warnings and errors and none of them seem to be discussed/explained in this article. |
||||
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?





































