web service hello world example explained

The following two tabs change content below.
Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Latest posts by Prasad Kharkar (see all)

We have seen how to create a hello world web service example using core java and how to consume them. This article will deal with explanation of previous web service hello world example . Its components and annotations used will be explained.

Web Service Hello World Example Explained:

HelloWorldServer:

  •  @WebService annotation makes this interface a web service interface. The implementing class should also be annotated with @WebService.
  • @SOAPBinding (style = Style.RPC) defines a SOAP styles web service with binding style as RPC.
  • @WebMethod  annotation denotes that this method will be published and used as a web service.The method must be public as per javadoc.

HelloWorldServerImpl:

This is a concrete class implementing HelloWorldServer of web service hello world example.

  •   @WebService(endpointInterface = "com.thejavageek.HelloWorldServer") here the name of service endpoint interface is specified.

HelloWorldServerPublisher:

Web service hello world example needs to publisher class so that web service is published and consumed later.

Endpoint.publish method publishes the  web service. Now this web service hello world example publisher is ready to accept request indefinitely. we have tested it previously and it shows the xml structure as follows when visited with url http://127.0.0.1:9876/hw?wsdl.

This mean web service hello world example has its web service published and it is time we can consume it using a client.

  •  QName is used to create qualified name for HelloWorldServerImplService which maps to the name generated in wsdl.
  • Service.create is used to create service instance where url and qname must uniquely identify web service.
  • service.getPort()  returns the class in which web service is created so that hello world web service can be invoked.

I hope this web service hello world example explanation helped.

 

Share Button

Prasad Kharkar

Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Leave a Reply

Your email address will not be published. Required fields are marked *