Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Java IoT, Weblogic

Java IoT: Article

JDJ Feature — Java API for XML Web Services (JAX-WS)

Creating a JAX-WS 2.0 Web Service in WebLogic Server 10

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.

  1. The client-side copy of the WSDL file.
  2. The Java source code for the Stub and Service interface implementations for the Web Service.
  3. Java classes for any user-defined XML Schema data types defined in the WSDL file.
  4. JAX-RPC deployment descriptor that describes the mapping between the Java data types and the corresponding XML Schema types in the WSDL file.
The only required attribute of the clientgen task is one of destDir or destFile and wsdl. Some of the commonly used attributes of the clientgen task are discussed in Table 4.

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" />


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.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
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.

IoT & Smart Cities Stories
Cloud computing delivers on-demand resources that provide businesses with flexibility and cost-savings. The challenge in moving workloads to the cloud has been the cost and complexity of ensuring the initial and ongoing security and regulatory (PCI, HIPAA, FFIEC) compliance across private and public clouds. Manual security compliance is slow, prone to human error, and represents over 50% of the cost of managing cloud applications. Determining how to automate cloud security compliance is critical...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
"MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound e...
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...