|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top 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
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"> 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 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; 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.
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" Reader Feedback: Page 1 of 1
Your Feedback
Enterprise Open Source Magazine Latest Stories . . .
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 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||