Welcome!

Java IoT Authors: Pat Romanski, Stackify Blog, Elizabeth White, Liz McMillan, Mamoon Yunus

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

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.


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.

@ThingsExpo Stories
Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
"We're a cybersecurity firm that specializes in engineering security solutions both at the software and hardware level. Security cannot be an after-the-fact afterthought, which is what it's become," stated Richard Blech, Chief Executive Officer at Secure Channels, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. Jack Norris reviews best practices to show how companies develop, deploy, and dynamically update these applications and how this data-first...
Intelligent Automation is now one of the key business imperatives for CIOs and CISOs impacting all areas of business today. In his session at 21st Cloud Expo, Brian Boeggeman, VP Alliances & Partnerships at Ayehu, will talk about how business value is created and delivered through intelligent automation to today’s enterprises. The open ecosystem platform approach toward Intelligent Automation that Ayehu delivers to the market is core to enabling the creation of the self-driving enterprise.
The question before companies today is not whether to become intelligent, it’s a question of how and how fast. The key is to adopt and deploy an intelligent application strategy while simultaneously preparing to scale that intelligence. In her session at 21st Cloud Expo, Sangeeta Chakraborty, Chief Customer Officer at Ayasdi, will provide a tactical framework to become a truly intelligent enterprise, including how to identify the right applications for AI, how to build a Center of Excellence to ...
SYS-CON Events announced today that Massive Networks will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Massive Networks mission is simple. To help your business operate seamlessly with fast, reliable, and secure internet and network solutions. Improve your customer's experience with outstanding connections to your cloud.
Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution and join Akvelon expert and IoT industry leader, Sergey Grebnov, in his session at @ThingsExpo, for an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
Because IoT devices are deployed in mission-critical environments more than ever before, it’s increasingly imperative they be truly smart. IoT sensors simply stockpiling data isn’t useful. IoT must be artificially and naturally intelligent in order to provide more value In his session at @ThingsExpo, John Crupi, Vice President and Engineering System Architect at Greenwave Systems, will discuss how IoT artificial intelligence (AI) can be carried out via edge analytics and machine learning techn...
SYS-CON Events announced today that Datera, that offers a radically new data management architecture, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Datera is transforming the traditional datacenter model through modern cloud simplicity. The technology industry is at another major inflection point. The rise of mobile, the Internet of Things, data storage and Big...
Consumers increasingly expect their electronic "things" to be connected to smart phones, tablets and the Internet. When that thing happens to be a medical device, the risks and benefits of connectivity must be carefully weighed. Once the decision is made that connecting the device is beneficial, medical device manufacturers must design their products to maintain patient safety and prevent compromised personal health information in the face of cybersecurity threats. In his session at @ThingsExpo...
In his session at @ThingsExpo, Arvind Radhakrishnen discussed how IoT offers new business models in banking and financial services organizations with the capability to revolutionize products, payments, channels, business processes and asset management built on strong architectural foundation. The following topics were covered: How IoT stands to impact various business parameters including customer experience, cost and risk management within BFS organizations.
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
From 2013, NTT Communications has been providing cPaaS service, SkyWay. Its customer’s expectations for leveraging WebRTC technology are not only typical real-time communication use cases such as Web conference, remote education, but also IoT use cases such as remote camera monitoring, smart-glass, and robotic. Because of this, NTT Communications has numerous IoT business use-cases that its customers are developing on top of PaaS. WebRTC will lead IoT businesses to be more innovative and address...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics ...
SYS-CON Events announced today that App2Cloud will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. App2Cloud is an online Platform, specializing in migrating legacy applications to any Cloud Providers (AWS, Azure, Google Cloud).
Recently, IoT seems emerging as a solution vehicle for data analytics on real-world scenarios from setting a room temperature setting to predicting a component failure of an aircraft. Compared with developing an application or deploying a cloud service, is an IoT solution unique? If so, how? How does a typical IoT solution architecture consist? And what are the essential components and how are they relevant to each other? How does the security play out? What are the best practices in formulating...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infrastructure throu...