JaiswalTraining

Get the online training



Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              
              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com







Corejava
Servlet
Jsp
Php
Hibernate
Ajax
Web Service
Ejb2.1
Ejb3.0
Struts  
Struts2
JPA
Spring
Ibatis
JSF
JSF2.0
CoreJavaDesignPattern
Jquery
Flex
J2EE-Design-Patterns
Jboss7
Maven









Web Service Example In Spring MyEclipse
Bottom Top approach
  • MyEclipse  uses Sun Metro Web Service tool.
  • Metro is an opensource web service tool.
  • This is a part of the GlassFish project.
  • But it can be downloaded and used with tomcat and other server.
  • This can also be used in eclipse.
  • This is deafult part of Netbeans Ide.
  • This can be downloaded from metro.java.net.

    Components Of the Metro
    • JAXB RI,
    • JAX-WS RI,
    • SAAJ RI,
    • StAX (SJSXP implementation) and 
    • WSIT.
  • This is default Web Service Tool in MyEclipse.
  • Create one web service project.




  • Type the name as HelloWebService
  • Select FrameWork as JAX-WS


  • It will create a new web service project
  • Rt Click on the project
  • Select new-->Interface



  • Type the Pacakage name as pack
  • Type the name of the Interface as Hello.



  • Click on Ok .
  • It creates Hello.java interface.

Hello.java

package pack;

public interface Hello {
  
  public String disp(String name);

}

  • Similarly create one class HelloImpl
  • Here implements the Hello interface.
HelloImpl.java

package pack;

public class HelloImpl implements Hello{

  @Override
  public String disp(String name) {
  
    return "welcome "+name;
  }
}


  • Rt. Click on the project.
  • Select New--->Other





  • In this window Select MyEclipse Menu.
  • navigate to down.



  • Select WebService



  • Type the name of the WebService as HelloWebService.
  • Select Create web service from Java Class(Bottom-Up)




  • Select the new java Class
  • Click on the Browse



  • Select the HelloImpl.
  • Click on the OK button.





  • It will create the following files.
  • Select the Generate WSDL in the project.




  • It  creates HelloImplService.wsdl file in wsdl folder.
  • It creates HelloImpleDelegate.java file.
  • The following architecture will get created.



  • Generated file HelloImplDelegate.java has following code.
HelloImplDelegate.java

package pack;

@javax.jws.WebService(targetNamespace = "http://pack/", serviceName = "HelloImplService", portName = "HelloImplPort",
wsdlLocation = 
"WEB-INF/wsdl/HelloImplService.wsdl")
public class HelloImplDelegate {

  pack.HelloImpl helloImpl = new pack.HelloImpl();

  public String disp(String name) {
    return helloImpl.disp(name);
  }

}


Running  the project
  • Rt click on the project
  • Select  Run As-->MyEclipse Server Application



  • It will run the index.jsp on the tomcat
  • Now out webservice project is deployed on the Tomcat.




Testing the WebService program using  WebService Explorer

  • Click on the web service explorer icon.
  • It will launch the web service explorer.




  • In the given page Cick one WSDL page icon.



  • Now In the Open WSDL page click on the Browse link.




  • It will open a new  window.
  • Here select the HelloWebService project
  • Then select the given wsdl file. 
  • Click on the go button.



  • It will come into the previous window.




  • Click on the Go button.



  • It will open the follwoing window.
This window you can also get using following steps.



  • In the right window  Click on the disp operation.



  • In the disp operation Click on the Add link.
  • It will open one text field for it.
  • Add the value as Aamir AlHakim


  • Click on the Go button.
  • It will call the given web service operation.
  • Then the result is displayed on the below screen.




Download the Spring MyEclipse code