Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Creating a bottom-up Axis2 Web service"
m (adding the modifications to suit axis2 1.3 and later) |
(Update the wiki to show Axis2 1.3 changes in tutorial) |
||
Line 50: | Line 50: | ||
# Back on the Web Services Client wizard, make sure the Web service runtime is set to Axis2 and the server is set correctly. Click Next. <br />[[Image:Ws_buAxis2ClientWizardFirstPage.png|alt]]<br /><br /><br /> | # Back on the Web Services Client wizard, make sure the Web service runtime is set to Axis2 and the server is set correctly. Click Next. <br />[[Image:Ws_buAxis2ClientWizardFirstPage.png|alt]]<br /><br /><br /> | ||
# Next page is the Client Configuration Page. Accept the defaults and click Finish. <br />[[Image:Ws_buAxis2ClientWizardConfigPage.png|alt]]<br /><br /><br /> | # Next page is the Client Configuration Page. Accept the defaults and click Finish. <br />[[Image:Ws_buAxis2ClientWizardConfigPage.png|alt]]<br /><br /><br /> | ||
− | # The Clients stubs will be generated to your Dynamic Web project ''' Axis2WSTestClient'''. Following screen shot depicts the source files created when prior versions of axis2 1.3 is used.<br />[[Image:Ws_buAxis2ClientJavaStub.png|alt]]<br /> | + | # The Clients stubs will be generated to your Dynamic Web project ''' Axis2WSTestClient'''. Following screen shot depicts the source files created when prior versions of axis2 1.3 is used.<br />[[Image:Ws_buAxis2ClientJavaStub.png|alt]]<br />axis2 ver. 1.3 or later screenshot< br />[[Image:Ws_buAxis2ClientJavaStub_1.3.png|alt]]<br /><br /><br /> |
− | # Now we are going to write Java main program to invoke the client stub. Import the [http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/code/ConverterClient.java ConverterClient.java] file (if you are using axis2 version 1.3 or later use [http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/code/ | + | # Now we are going to write Java main program to invoke the client stub. Import the [http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/code/ConverterClient.java ConverterClient.java] file (if you are using axis2 version 1.3 or later use [http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/code/ConverterClient.java.zip ConverterClient.java.zip]) to the workspace into the wtp package in the src folder of '''Axis2WSTestClient'''. <br />[[Image:Ws_buAxis2TestClientJava.png|alt]]<br />Click to view axis2 ver. 1.3 or later screenshot<br />[[Image:Ws_buAxis2TestClientJava_1.3.png|alt]]<br /><br /><br /> |
− | # Then select the ConverterClient file, right-click and select Run As -> Java Application. Here's what you get on the server console: <br />[[Image:Ws_buAxis2RunTestClientJava.png|alt]]<br /> | + | # Then select the ConverterClient file, right-click and select Run As -> Java Application. Here's what you get on the server console: <br />[[Image:Ws_buAxis2RunTestClientJava.png|alt]]<br />Click to view axis2 ver. 1.3 or later screenshot<br />[[Image:Ws_buAxis2RunTestClientJava_1.3.png|alt]]<br /><br /><br /> |
# Another way to test and invoke the service is to select '''Generate test case to test the service''' check box on the Axis2 Client Web Service Configuration Page when going through the Web Service Client wizard. <br />[[Image:Ws_buAxis2ChooseUnitTest.png|alt]]<br /><br /> | # Another way to test and invoke the service is to select '''Generate test case to test the service''' check box on the Axis2 Client Web Service Configuration Page when going through the Web Service Client wizard. <br />[[Image:Ws_buAxis2ChooseUnitTest.png|alt]]<br /><br /> | ||
− | # If that option is selected, the Axis2 emitter will generate JUnit testcases matching the WSDL we provide to the client. These JUnit testcases will be generated to a newly added source directory to the ''' Axis2WSTestClient''' project called '''test'''. <br />[[Image:Ws_buAxis2UnitTestFile.png|alt]] <br /> | + | # If that option is selected, the Axis2 emitter will generate JUnit testcases matching the WSDL we provide to the client. These JUnit testcases will be generated to a newly added source directory to the ''' Axis2WSTestClient''' project called '''test'''. <br />[[Image:Ws_buAxis2UnitTestFile.png|alt]] <br />Axis2 ver. 1.3 or later screenshot<br />[[Image:Ws_buAxis2UnitTestFile_1.3.jpg|alt]]<br /><br /> |
# Next thing we need to do is to insert the testcase with the valid inputs as the Web servivce method arguments. In this case, let's test the ConverterConverterSOAP11Port_httpTest.java (or ConverterTest.java for axis2 ver. 1.3 or later) by provide values for Celsius and Farenheit for the temperature conversion. As an example, replace the generated TODO statement in each test method to fill in the data with values as: | # Next thing we need to do is to insert the testcase with the valid inputs as the Web servivce method arguments. In this case, let's test the ConverterConverterSOAP11Port_httpTest.java (or ConverterTest.java for axis2 ver. 1.3 or later) by provide values for Celsius and Farenheit for the temperature conversion. As an example, replace the generated TODO statement in each test method to fill in the data with values as: | ||
testfarenheitToCelsius() -> farenheitToCelsius8.setFarenheit(212); | testfarenheitToCelsius() -> farenheitToCelsius8.setFarenheit(212); | ||
Line 64: | Line 64: | ||
testStartcelsiusToFarenheit() -> celsiusToFarenheit10.setCelsius(100); | testStartcelsiusToFarenheit() -> celsiusToFarenheit10.setCelsius(100); | ||
Here the testcases were generated to test both the synchronous and asynchronous clients. <br /> | Here the testcases were generated to test both the synchronous and asynchronous clients. <br /> | ||
− | # After that, select the testcase, right-click, select Run As -> JUnit Test. You will be able to run the unit test successfully invoking the Web service. <br />[[Image:Ws_buAxis2RunUnitTest.png|alt]]<br /> | + | # After that, select the testcase, right-click, select Run As -> JUnit Test. You will be able to run the unit test successfully invoking the Web service. <br />[[Image:Ws_buAxis2RunUnitTest.png|alt]]<br />Axis2 ver. 1.3 or later screenshot<br />[[Image:Ws_buAxis2RunUnitTest_1.3.jpg|alt]]<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>''' |
Revision as of 07:03, 2 June 2008
Eclipse WTP Tutorials - Creating Bottom Up Web Service via Apache Axis2 |
By Lahiru Sandakith | |
Introduction | |
| |
Set Up | |
Before creating the Web service, there are two prerequisites: | |
Creating a bottom up JAVA bean Web service and Web service client using Axis2 WTP Tools | |
This tutorial need a Axis2 runtime. You can download the latest axis2 binary distribution from here.
testfarenheitToCelsius() -> farenheitToCelsius8.setFarenheit(212); testStartfarenheitToCelsius() -> farenheitToCelsius8.setFarenheit(212); testcelsiusToFarenheit() -> celsiusToFarenheit10.setCelsius(100); testStartcelsiusToFarenheit() -> celsiusToFarenheit10.setCelsius(100); Here the testcases were generated to test both the synchronous and asynchronous clients. | |
Summary | |
In this example, we show using the Web Services wizard followed by using the Web Service client wizard. You could also choose to generate both service and client using the Web Services wizard:
| |
Resources | |
You can also refer to the Axis Web services tutorials: |