Wednesday, April 7, 2010

Web Service Development - generate server code based on .wsdl file

I have to call web service to get some information for a single sign-on project. The user just provided a .wsdl file to me.
This article will describe how to generate source code for service side and create a web service based on a given .wsdl file.

My Environment:
jdk1.5
tomcat 6
Eclipse Java EE IDE for Web Developers v3.2
axis2

Step 1: go to 'windows' - 'Preferences' in eclipse menu and open 'Web Services' - 'Axis2 Preferences' to specify the axis2 location
















Step 2: go to 'windows' - 'Preferences' in eclipse menu and open 'Web Services' - 'Server and runtime' to specify the web server , and web service runtime is apache axis2.
















Step 3: create a new dynamic web project in eclipse.
















Step 4 : key in the project name and click New... button to set target runtime




















Step 5: select your server runtime environment and go to next



















Step 6: specify your web server installation directory, then click finish




















Step 7: the project information will be refreshed. then click finish.




















Step 8: in project root folder, add a new folder named 'wsdl' and put .wsdl file inside.
(take note, sometimes, for some complicated cases,you should put the whole folder and .wsdl files in this 'wsdl' folder. In this example, only put simple one .wsdl file inside)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Step 9 : right click the target .wsdl file and select menu 'New' - 'others'
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Step 10 : select 'Web Services' - 'Web Service' to generate source code for server side.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
Step 11 : ensure web service type is 'Top down Java Bean Web Service'
ervice definition is the location of target .wsdl file
Server: ensure the server is correct, or else click it to reset
Web service runtime: ensure it is axis2
go to next
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Step 12 : go to next
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Step 13 : click start server to launch service runtime server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
Step 14 : right click the project name and select 'Run as' - 'Run on server'
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
Step 15 : eclipse will luanch a browser to show all available services.

1 comment:

  1. This is my first visit here. I found some really interesting stuff in your blog especially this discussion. Keep up the good work.
    It is the same with a website and website development concentrates of these core elements first and then builds upwards.
    India Web Development

    ReplyDelete