I am new to webservices and i want to implement webservices by using java in my eclipse project.
So can anyone tel me how to implement and creating a project please
Thanks
I am new to webservices and i want to implement webservices by using java in my eclipse project.
So can anyone tel me how to implement and creating a project please
Thanks
As defined by W3C web service is a software system to support interoperable machine-to-machine interaction over a network. More elaborately a system consumes service from other software system.
Web services has two major classes:
To implement web service one need to choose one category on the basis of his/her requirement. Java has bunch APIS to implement web services on both category.
Requirements before implementing web service is :
REST based is bit easy to implement compare to other category. So it's better to start with REST complaint web services.
How web service works :
WS works as request-response paradigm , there is an entity which will request for some service to it's specific counterpart namely service provider entity. Upon request, service provider will respond with a response message. So there are two message involved hear one Request message (XML)and one Response message (XML). There are bunch of ways to achieve these. Detail can be found at web service architecture
Beginner can start with JERSEY jsr311 standard reference implementation to build RESTful web services.
Example (jersey specific):
Step One : Creating root resources
// The Java class will be hosted at the URI path "/helloworld"
@Path("/helloworld")
public class HelloWorldResource {
@GET
@Produces("text/plain")
public String getClichedMessage() {
return "Hello World";
}
}
Step Two : Deploying
public class Main {
private static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost/").port(8080).build();
}
public static final URI BASE_URI = getBaseURI();
protected static HttpServer startServer() throws IOException {
System.out.println("Starting ...");
ResourceConfig resourceConfig = new PackagesResourceConfig("com.sun.jersey.samples.helloworld.resources");
return GrizzlyServerFactory.createHttpServer(BASE_URI, resourceConfig);
}
public static void main(String[] args) throws IOException {
HttpServer httpServer = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...",
BASE_URI, BASE_URI));
System.in.read();
httpServer.stop();
}
}
Webservice is some program interface, which uses SOAP protocol for communication. Using soap, you can communicate with any program, no matter on which language it is written.
SOAP is an XML-based communication protocol and encoding format for inter-application communication. Originally conceived by Microsoft and Userland software, it has evolved through several generations; the current spec is version, SOAP 1.2, though version 1.1 is more widespread. The W3C's XML Protocol working group is in charge of the specification. SOAP is widely viewed as the backbone to a new generation of cross-platform cross-language distributed computing applications, termed Web Services.
Here is some examples:
One of the easiest and best ways is to develop webservice using Apache Axis. Eclipse SOA toolkit supports Axis.
More information regarding sample project can be found here!
© 2022 - 2024 — McMap. All rights reserved.