By: Emiley J in WebServices Tutorials on 2013年07月11日 [フレーム]
In this tutorial you will learn how to write a simple web service in Java using Netbeans IDE and deploy it to Tomcat.
If you have followed the steps in tutorial 1 and tutorial 2, you probably know how to develop java web service without using any IDE and to deploy using a standalone java application. However, that manual approach is not suitable for a production system or to develop complex web services. For developing advanced web services, you will have to use an IDE such as NetBeans and then deploy the web service in a Server such as GlassFish or Tomcat. In this tutorial, I will show you how easy it is to develop and deploy a simple webservice using Netbeans.
package com.javasamples; // time server
import java.util.Date;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService(serviceName = "TimeServer")
// more on this later
public class TimeServer {
@WebMethod(operationName = "getTimeAsString")
public String getTimeAsString() { return new Date().toString(); }
@WebMethod(operationName = "getTimeAsElapsed")
public long getTimeAsElapsed() { return new Date().getTime(); }
}Congratulate yourself. You have just developed a web service in netbeans and published it to Tomcat.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in WebServices )
Java WebService connected to Database
Java Webservices using Netbeans and Tomcat
Java WebService - Create your first web service in Java
package javax.jws does not exist
Returning multiple values from a web service
How to Deploy a Java Web Service
Preventing your PDF files to be displayed inside other website IFrames
Prevent other websites from displaying content from your website in an iframe
Content-Security-Policy: object-src, script-src, base-uri and report-uri
Latest Articles (in WebServices)
Content-Security-Policy: object-src, script-src, base-uri and report-uri
Preventing your PDF files to be displayed inside other website IFrames
Prevent other websites from displaying content from your website in an iframe
Returning multiple values from a web service
Java Webservices using Netbeans and Tomcat
How to Deploy a Java Web Service
Java WebService connected to Database
package javax.jws does not exist
Content-Security-Policy: object-src, script-src, base-uri and report-uri
Preventing your PDF files to be displayed inside other website IFrames
Prevent other websites from displaying content from your website in an iframe
Returning multiple values from a web service
Java Webservices using Netbeans and Tomcat
How to Deploy a Java Web Service
Java WebService connected to Database
package javax.jws does not exist
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate