Below example describes how to expose a java method as a Web service.
- Step1 : Create a generic application as 'JavaDemoApp' in Jdev. Create a generic project as 'MyProject' with webservices include.
- Right click on the Myproject and add new -> select a java class. Give class name as Greetings.
- Create a method as 'getGreetings' inside the class which returns a String as output. Save and build the project.
package myproject;
public class Greetings {
public Greetings() {
super();
}
public String getGreetings(String s)
{return "Welcome "+s;}
}
- Now right click on MyProjects and select the BusinessTier->Web services->JavaWeb Service.
- Go next to wizard as shown in below snaps.
- Give the component name, service name and serice port.
- Click next choose SOAP 1.1 binding. then next check the getGreetings method.
- Go next in the wizard until you get finish button. Now save the project and rebuild it.
- Now right click on the project and click on deploy. In the deployment wizard go next and on server page choose the weblogic admin server. Go to next till finish the deployment wizard.
- Now the Web service deployed to weblogic server. For testing login to the weblogic console with url http://localhost:7001/console.
- Goto deployment tab.Choose the JavaWSDemoApp-MyProject-context-root web application. Expand it you will get the GreetingService web service.
- Click on the GreetingsSerice it will navigate to separate page. Select Testing tab from the menu.
- In the Test Point column Test client redirect to testing the web serice page. ?wsdl redirect to the wsdl of the web service.
- Click on test client it will redirect to the below page. Give your input and click on getGritings button.
- Below is the response got from the web service invocation.
Give your comments on this post. Happy Coding :)
No comments:
Post a Comment