Web service is a concept that can be used for exposing the functionality of an application which can be utilized by other application, instead of creating the new functionality.
Let us discuss with a practical example:
Now workspace will look like given below in Project Explorer:
Now add the below code in HelloMessage:
public String sayHello(String name) { return "Hello "+name; }
Now code will look like below:
Now click next
Now click next
Now click finish.
Server will be created like shown above.
Now add the class HelloMessage created earlier by browsing it. Once selected the HelloMessage class then it will become like given below:
Once clicked on the Finish button then web service will automatically be deployed on server created in earlier step as we added our project in that server.
Now check HelloMessage.wsdl folder as highlighted above.
Now expand the HelloMessageSoapBinding and click sayHello as shown below:
Now enter developerbook in the input field highlighted above in Action window and click go button. Now check Status window for response (here response that we are getting is Hello developerbook) .
If you are able to see then congratulations you successfully created your first web service. If you face any difficulty while creating first web service then you can write your problem in comment section.
Thanks for reading the blog post, your comments and suggestions are always welcome. Soon we will discuss about creating client which will consume the web service and wsdl file also.