Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Creating a top-down Axis2 Web service"
Line 1: | Line 1: | ||
− | + | {| width="100%" cellspacing="5" cellpadding="2" | |
− | + | | valign="top" | | |
− | | width="60%" align="left" | <font class="indextop" size="5">'''Eclipse WTP Tutorials - Creating Top Down Web Service via Apache Axis2''' </font> | + | {| width="100%" cellspacing="5" cellpadding="2" |
+ | | width="60%" align="left" | <font class="indextop" size="5"> '''Eclipse WTP Tutorials - Creating Top Down Web Service via Apache Axis2''' </font> | ||
| width="40%" | | | width="40%" | | ||
− | [[Image:wtplogosmall.jpg | + | [[Image:wtplogosmall.jpg]] |
+ | | <br /> | ||
|} | |} | ||
|- | |- | ||
Line 9: | Line 11: | ||
{| width="100%" cellspacing="5" cellpadding="2" | {| width="100%" cellspacing="5" cellpadding="2" | ||
| valign="top" | | | valign="top" | | ||
− | '''[mailto:sandakith@wso2.com By Lahiru Sandakith] '''<br />[http://www.wso2.org WSO2 Inc.]<br /> June 29, 2007 <br /><br /> | + | ''' [mailto:sandakith@wso2.com By Lahiru Sandakith] '''<br />[http://www.wso2.org WSO2 Inc.]<br /> June 29, 2007 <br /><br /> |
|- | |- | ||
− | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica">Introduction </font>''' | + | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica"> Introduction </font> ''' |
|- | |- | ||
| valign="top" | | | valign="top" | | ||
− | <br /> This tutorial is meant to demonstrate the use of the newly introduced ''' Axis2''' Web Services tools in the Web Tools Platform Project using the '''WTP 2.0''' drivers. Also this tutorial shows how to create a simple top-down Web service from a WSDL file and test that with the WSE (Web Service Explorer). The WSDL file in this scenario calculates the area of an rectangle and its the same WSDL that used in the Axis web services tutorials.<br /> | + | <br /> This tutorial is meant to demonstrate the use of the newly introduced '''Axis2''' Web Services tools in the Web Tools Platform Project using the '''WTP 2.0''' drivers. Also this tutorial shows how to create a simple top-down Web service from a WSDL file and test that with the WSE (Web Service Explorer). The WSDL file in this scenario calculates the area of an rectangle and its the same WSDL that used in the Axis web services tutorials.<br /> |
|- | |- | ||
− | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica">Set Up </font>''' | + | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica"> Set Up </font> ''' |
|- | |- | ||
| valign="top" | | | valign="top" | | ||
Before creating the Web service, there are two prerequisites: | Before creating the Web service, there are two prerequisites: | ||
# [http://www.eclipse.org/webtools/releases/2.0/ Install Latest Eclipse WTP 2.0 integration driver] | # [http://www.eclipse.org/webtools/releases/2.0/ Install Latest Eclipse WTP 2.0 integration driver] | ||
− | # [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/InstallTomcat/InstallTomcat.html | + | # [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/InstallTomcat/InstallTomcat.html Configure Apache Tomcat inside Eclipse WTP] |
|- | |- | ||
− | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica">Creating a top down Java bean Web service and Web service client using Axis2 WTP Tools </font> ''' | + | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica"> Creating a top down Java bean Web service and Web service client using Axis2 WTP Tools </font> ''' |
|- | |- | ||
| valign="top" | | | valign="top" | | ||
This tutorial need a Axis2 runtime. You can download the latest axis2 binary distribution from [http://ws.apache.org/axis2/download.cgi here] . <br />'''Note :''' Currently Axis2 version 1.2 is the supported version for the Web Services Scenarios. | This tutorial need a Axis2 runtime. You can download the latest axis2 binary distribution from [http://ws.apache.org/axis2/download.cgi here] . <br />'''Note :''' Currently Axis2 version 1.2 is the supported version for the Web Services Scenarios. | ||
− | # Download the latest Axis2 runtime from the above link and extract it. <br /> | + | # Download the latest Axis2 runtime from the above link and extract it.<br /> |
− | # Now we point Eclipse WTP to downloaded Axis2 Runtime. Open ''' Window -> Preferences -> Web Services -> Axis2 Emitter'''<br />[[Image:1_n.png | + | # Now we point Eclipse WTP to downloaded Axis2 Runtime. Open '''Window -> Preferences -> Web Services -> Axis2 Emitter'''<br />[[Image:1_n.png]]<br />Select the Axis2 Runtime tab and point to the correct Axis2 runtime location. Alternatively at the Axis2 Preference tab you can set the default setting that will come up on the Web Services Creation wizards. For the moment we will accept the default settings. |
# Click OK. <br /><br /> | # Click OK. <br /><br /> | ||
− | # Next we need to create a project with the support of Axis2 features. Open '''File -> New -> Other... -> Web -> Dynamic Web Project'''<br />[[Image:a1.png | + | # Next we need to create a project with the support of Axis2 features. Open '''File -> New -> Other... -> Web -> Dynamic Web Project'''<br />[[Image:a1.png]]<br />Click next |
− | # Select the name Axis2WSTest as the Dynamic web project name(You can specify any name you prefer), and select the configured tomcat runtime as the target runtime <br />[[Image:a2.png | + | # Select the name Axis2WSTest as the Dynamic web project name(You can specify any name you prefer), and select the configured tomcat runtime as the target runtime<br />[[Image:a2.png]]<br />Click next |
− | # Select the Axis2 Project Facet <br />[[Image:a3_n.png | + | # Select the Axis2 Project Facet<br />[[Image:a3_n.png]]<br />Click next |
− | # Select the Axis2 Project Facet <br />[[Image:a4.png | + | # Select the Axis2 Project Facet<br />[[Image:a4.png]]<br />Click Finish |
− | # This will create a dynamic web project in the workbench <br />[[Image:b1.png | + | # This will create a dynamic web project in the workbench<br />[[Image:b1.png]]<br /><br /><br /> |
− | # Create a folder called WSDL on the Axis2WSTest project. Import the file [ | + | # Create a folder called WSDL on the Axis2WSTest project. Import the file [code/AreaService.wsdl AreaService.wsdl] into Axis2WSTest/wsdl.<br />[[Image:g1.png]]<br />Build the Project, if its not auto build. |
− | # Now we are going to invoke the web service creation wizard with respect to the newly imported WSDL. By selecting AreaService.wsdl source the Open File -> New -> Other... -> Web Services -> Web Service <br />[[Image:g3.png | + | # Now we are going to invoke the web service creation wizard with respect to the newly imported WSDL. By selecting AreaService.wsdl source the Open File -> New -> Other... -> Web Services -> Web Service<br />[[Image:g3.png]]<br />Click next |
− | # Because of the wizard was invoked related to a correct WSDL the correct web services scenario will be picked automatically with the correct service definition. Also the configuration must be automatically set to the correct server, web service runtime and the service project. Make sure that you have selected the scale until to the start service. Also make sure you have the exact same items for the Server, Web Service Runtime and Service Project. Else make appropriate changes to select them as displayed below. <br />[[Image:g4.png | + | # Because of the wizard was invoked related to a correct WSDL the correct web services scenario will be picked automatically with the correct service definition. Also the configuration must be automatically set to the correct server, web service runtime and the service project. Make sure that you have selected the scale until to the start service. Also make sure you have the exact same items for the Server, Web Service Runtime and Service Project. Else make appropriate changes to select them as displayed below.<br />[[Image:g4.png]]<br />Click next |
− | # This page is the skeleton JAVA bean configuration page. if you have a custom preferences you can edit the configuration as needed, for the moment default will do. <br />[[Image:g5_n.png | + | # This page is the skeleton JAVA bean configuration page. if you have a custom preferences you can edit the configuration as needed, for the moment default will do.<br />[[Image:g5_n.png]]<br />Click next |
− | # This page is the start server page. Click on the start server. This will start the server runtime. <br />[[Image:g6.png | + | # This page is the start server page. Click on the start server. This will start the server runtime.<br />[[Image:g6.png]]<br />Click next |
− | # This page is the web services publication page, accept the defaults. <br />[[Image:g7.png | + | # This page is the web services publication page, accept the defaults.<br />[[Image:g7.png]]<br />Click Finish. You will see the newly created skeleton page gets pop up in the Editor. If you need you can edit the skeleton to include your area service logic. But for the moment We will accept the defaults settings.<br /> |
− | # Here after the skeleton generation the user need to fill the nessesary parts of the service skeleton with the bussiness logic. In this example the CalculatedRectArea method TODO plus the exception must be replace with appropriate logic. For that we need some changes in the build system to auto reflect the change in the deployed service. One thing is we need to make sure that Build Automatically is enabled in the Project Menu. Then we need to change the output location of the project to the location where the service is deployed in the local web service runtime attached to the project. As in this example to the folder WebContent -> axi2-web -> WEB-INF -> services -> Axis2TestWs directory. <br />[[Image:sk_1.png | + | # Here after the skeleton generation the user need to fill the nessesary parts of the service skeleton with the bussiness logic. In this example the CalculatedRectArea method TODO plus the exception must be replace with appropriate logic. For that we need some changes in the build system to auto reflect the change in the deployed service. One thing is we need to make sure that Build Automatically is enabled in the Project Menu. Then we need to change the output location of the project to the location where the service is deployed in the local web service runtime attached to the project. As in this example to the folder WebContent -> axi2-web -> WEB-INF -> services -> Axis2TestWs directory.<br />[[Image:sk_1.png]]<br /><br /> |
− | # So now we have done the nessesary thing to auto deploy our TD created web service. Now we go ahead and implement the skeleton. Replave the TODO plus the exception with the following logic foe calculating the Area. org.tempuri.areaservice.Area area = new org.tempuri.areaservice.Area(); area.setArea( parameters.getParameters().getHeight() * parameters.getParameters().getWidth(); return area;<br />[[Image:sk_2.png | + | # So now we have done the nessesary thing to auto deploy our TD created web service. Now we go ahead and implement the skeleton. Replave the TODO plus the exception with the following logic foe calculating the Area. org.tempuri.areaservice.Area area = new org.tempuri.areaservice.Area(); area.setArea( parameters.getParameters().getHeight() * parameters.getParameters().getWidth(); return area;<br />[[Image:sk_2.png]]<br />Tigger a auto build after saving. You will notice in the console that the service getting re deployed in the server.<br /> |
− | # Now we can run the Dynamic Web Project on the server to see our top down created web service running on axis2 server. For that Select the Axis2WSTest dynamic web project and select Run -> Run As -> Run on Server <br />[[Image:d1.png | + | # Now we can run the Dynamic Web Project on the server to see our top down created web service running on axis2 server. For that Select the Axis2WSTest dynamic web project and select Run -> Run As -> Run on Server<br />[[Image:d1.png]]<br />Click Next. |
− | # Make sure you have the Axis2WSTest dynamic web project on the Configured project. <br />[[Image:d2.png | + | # Make sure you have the Axis2WSTest dynamic web project on the Configured project.<br />[[Image:d2.png]]<br />Click Next. |
− | # This page is the web services publication page, accept the defaults. <br />[[Image:d3.png | + | # This page is the web services publication page, accept the defaults.<br />[[Image:d3.png]]<br />Click Finish. |
− | # By doing the above test the Axis2 server webapp will be automatically deployed on the configured servlet container and will display the axis2 home page. <br />[[Image:d5.png | + | # By doing the above test the Axis2 server webapp will be automatically deployed on the configured servlet container and will display the axis2 home page.<br />[[Image:d5.png]]<br /><br /> |
− | # By selecting services can view the available services. The newly created AreaService will be available there. <br />[[Image:g8.png | + | # By selecting services can view the available services. The newly created AreaService will be available there.<br />[[Image:g8.png]]<br /><br /> |
− | # If you need to test the newly creating AreaService with the WSE. at the first page of the skeleton scenario you can increase the slider to the test lever so that the created service can be tested against the Web Services Explorer. <br />[[Image:wse_1.png | + | # If you need to test the newly creating AreaService with the WSE. at the first page of the skeleton scenario you can increase the slider to the test lever so that the created service can be tested against the Web Services Explorer.<br />[[Image:wse_1.png]]<br /><br /> |
− | # So after the normal pagers it will add another additional page to select the test facility. Select the Web Service Explorer <br />[[Image:wse_2.png | + | # So after the normal pagers it will add another additional page to select the test facility. Select the Web Service Explorer<br />[[Image:wse_2.png]]<br /><br /> |
− | # Now For testing of the newly created AreaService with the WSE, at the end of the scenario it will launch the Web Services Explorer with the nessesary configuration loaded so that user can invoke the service easily. <br />[[Image:wse_3.png | + | # Now For testing of the newly created AreaService with the WSE, at the end of the scenario it will launch the Web Services Explorer with the nessesary configuration loaded so that user can invoke the service easily.<br />[[Image:wse_3.png]]<br /><br /> |
− | # Please refer the [http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/WebServiceExplorer/WebServiceExplorer.html | + | # Please refer the [http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/WebServiceExplorer/WebServiceExplorer.html Using Web Service Explorer to test a Web service] for more details. <br /><br /><br /><br /> |
|- | |- | ||
− | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica">Summary </font>''' | + | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica"> Summary </font> ''' |
|- | |- | ||
| valign="top" | | | valign="top" | | ||
Line 61: | Line 63: | ||
* You choose New -> Other... -> Web Services -> Web Service Client to generate a Web service client. | * You choose New -> Other... -> Web Services -> Web Service Client to generate a Web service client. | ||
|- | |- | ||
− | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica">Resources </font>''' | + | | colspan="2" bgcolor="#0080c0" align="left" valign="top" | ''' <font color="#ffffff" face="Arial,Helvetica"> Resources </font> ''' |
|- | |- | ||
| valign="top" | | | valign="top" | | ||
You can also refer the Axis web services creation wizards. | You can also refer the Axis web services creation wizards. | ||
− | * [http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/WebServiceExplorer/WebServiceExplorer.html | + | * [http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/WebServiceExplorer/WebServiceExplorer.html Using Web Service Explorer to test a Web service] |
− | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/BottomUpWebService/BottomUpWebService.html | + | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/BottomUpWebService/BottomUpWebService.html Creating Bottom Up Web Service via Axis] |
− | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/TopDownWebService/TopDownWebService.html | + | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/TopDownWebService/TopDownWebService.html Creating Top Down Web Service via Axis] |
− | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html | + | * [http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html Consuming Web service using Web Service Client via Axis] |
|} | |} | ||
|} | |} |
Revision as of 23:21, 29 January 2008
| ||||||||||||||||
|