Create SOAP based Web Service from JAVA Class

Here in this article, I will discuss how to create web service from java class. Here are the steps as mentioned below to create SOAP web service from java class.

  1. Create a custom application and enter application name XXTestWSApp. Choose your own local directory to save the application.Java_Web_Service_1
  2. Click on Next and enter project name XXTestWSPrjJava_Web_Service_2
  3. Click on Next and select Use JDevelopera��s default build toolsJava_Web_Service_3
  4. Now create a java class within the project. Right click on project -> New -> From Gallery. Select Java Class under General categories.Java_Web_Service_4 Java_Web_Service_5
  5. Create Java Class wizard will open. Enter class name, package name and select public as access modifiers. Check the below screenshot for other options.Java_Web_Service_6
    1. Click on OK and enter the below methodA�in the java class

     

    public String sayHello(String name){

    return “Hello “+name+”!”;

    }
    Java_Web_Service_7

  6. Right click on java and select Create Web ServiceJava_Web_Service_8
  7. Select Java EE 6, with support for JAX-WS Annotations as deployment platformJava_Web_Service_9
  8. Click on Next and enter web service name and port name.Java_Web_Service_10
  9. Click on Next and select SOAP 1.2Bindiing as message formatJava_Web_Service_11
  10. Select method in the next wizardJava_Web_Service_12
  11. Click on NextJava_Web_Service_13
  12. Select No Policies optionA�in the Configure Policies wizardJava_Web_Service_14
  13. Select the default options in the next wizardJava_Web_Service_15
  14. Click on Next and then Finish. Web service will be createdJava_Web_Service_16
  15. xxtestws.java file will look like below screenshotJava_Web_Service_17
  16. Test the web service in JDeveloper itself. Right click on xxtestws.java and select Test Web ServiceJava_Web_Service_18
  17. Enter input string under Request HTTP Headers. Click on Send RequestJava_Web_Service_19
  18. Response is as expected.Java_Web_Service_20
  19. Check the WSDL and XML schema. Right click on java class and select Show WSDL for Web Service AnnotationsJava_Web_Service_21
  20. Check the below screenshotsJava_Web_Service_22
  21. Click on Imports and select schema fileJava_Web_Service_23
  22. Check both design and source of XML schema fileJava_Web_Service_24 Java_Web_Service_25
  23. Copy the URL of the web service and browse the URL in the web browser. You can test the web service in the browser also. Click on Test.Java_Web_Service_26 Java_Web_Service_27
  24. Enter parameter arg0 as LeenaJava_Web_Service_28
  25. Enter user name and password and click on InvokeJava_Web_Service_29
  26. Test Result will be like the below screenshotJava_Web_Service_30

Leave a Reply

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

Show my latest post here