# Creating a Web service from a Java bean using the Apache Axis1 runtime environment

The Web Service wizard assists you in creating a new Web service, configuring it for deployment, and deploying the Web service to a server. Once your Web service is deployed, the wizard assists you in generating the client proxy and sample application to test the Web service. When you have completed testing, you can publish your Web service to a UDDI Business Registry using the Export wizard.

Prerequisites:

1. If you are using the Apache Jakarta Tomcat servlet container as your server, you must install it, configure an instance of it, and create a Web project targeted to it as described in Creating an Apache Tomcat server and Web project
2. Create or import a bean into the Java™ source folder of the Web project. To import, select the Java Resources: src folder, and from the file menu select Import > General > File System and browse to where your package is.

To create a Web service from a bean using the Apache Axis1 runtime environment:

1. Switch to the Java EE perspective (Window > Open Perspective > Java EE).
2. In the Project Explorer view, select the bean that you created or imported into the source folder of your Web project.
3. Click File > New > Other. SelectWeb Services in order to display the various Web service wizards. Select the Web Service wizard. Click Next.
4. Web Services page: select Bottom up Java bean Web service as your Web service type, and enter the URI to the WSDL, WSIL, or HTML file that will be used to generate the service.
   1. Select the stages of Web services development that you want to complete using the slider:
      - Develop: this will develop the WSDL definition and implementation of the Web service. This includes such tasks as creating the modules which will contain the generated code, WSDL files, deployment descriptors, and Java files when appropriate.
      - Assemble: this ensures the project that will host the Web service or client gets associated to an EAR when required by the target application server.
      - Deploy: this will create the deployment code for the service.
      - Install: this will install and configure the Web module and EARs on the target server.
      - Start: this will start the server once the service has been installed on it. The server-config.wsdd file will be generated.
      - Test: this will provide various options for testing the service, such as using the Web Service Explorer or sample JSPs.
   2. Select your server: the default server is displayed. If you want to deploy your service to a different server click the link to specify a different server.
   3. Select your runtime: the default runtime is displayed. If you want to deploy your service to a different runtime click the link to specify a different runtime.
   4. Select the service project: the project containing the project selected in your workspace is displayed. To select a different project and EAR click on the project link. Ensure that the project selected as the Client Web Project is different from the Service Web Project, or the service will be overwritten by the client's generated artifacts.
   5. If you want to create a client, select the type of proxy to be generated and repeat the above steps for the client.
   6. Publish the Web service: this will launch the Web Services Explorer to publish your Web service to a UDDI registry.
   7. Monitor the Web service: this will send the Web service traffic through the TCP/IP Monitor, which allows you to watch the SOAP traffic generated by the Web service and to test this traffic for WS-I compliance. Alternately you can manually set up a TCP/IP monitor as described in Using the TCP/IP Monitor to test Web services
5. Web Service Java Bean Identity page: the Web service WSDL name will be listed. You have the following options:
   - Select the methods to expose.
   - Select the encoding style. RPC/Encoded is the recommended encoding style for the Axis runtime environment. This encoding method is not WS-I compliant.
   - Select if you want to customize the package to namespace mappings.
   Click Next
6. Web Service Package to Namespace Mappings page: if you selected Define custom mapping for package to namespace on the previous panel, you can enter your custom mapping pairs on this panel by clicking Add. Alternately, you can click Import to import custom mapping pairs from a `.properties` file. The content of the properties file must be of the format `package=namespace`. You will need to escape some special characters in the properties files. For example `somePackage=http://someNamespace` should be `somePackage=http\://someNamespace`. Otherwise, the colon (:) would be treated as delimiter resulting in trying to map `somePackage` to `http`.
7. Web Service Test page: If you selected to test the Web service, select the test facility for the generated Web service. This will open the Web service in the Web Services Explorer. Select the operation you want to test, enter the required information, and clickGo. The result will display in the Status pane. Click Next.
8. Web Service Proxy page: if you have selected to generate a proxy, select if you want to customize the package to namespace mappings.
9. Web Service Client Test page: Use this page to select the following options:
   1. Select your test facility. You can test the generated proxy in the Web Service Explorer, or you can generate a sample Web service JSP.
   2. If you selected to test the proxy through a JSP, you can select the folder where the JSP will be located, and you can select the methods that will be included in the JSP.
   3. Select Run test on server to start the server for you automatically.
10. Web Service Publication page: Select whether or not you want to publish this Web service to a UDDI registry. Click Finish. Note: you may see a warning stating `Error in generating WSDL from Java. ClassNotFound: <bean name>`. This error can be safely ignored.

After the Web service has been created, the following may occur depending on the options you selected:

- If you have selected to test the generated proxy using Web service JSPs, the proxy is launched in a Web browser at the following URL: http://localhost: port/ WebProjectClient/sampleBeanName/ WebServiceName/TestClient.jsp You can use this sample application to test the Web service by selecting a method, entering a value for the method, and clicking Invoke. The result of the method will display in the results pane.
- If you have selected to test the Web service using the Web Services Explorer, the Explorer will open. Select the operation you want to test, enter the required information, and click Go. The result will display in the Status pane.
- If you have selected to publish the Web service, the Web Services Explorer is launched displaying the page required to publish your Web service. Follow the instructions in Publishing the Web service to complete this task.

Important: If your methods contain types, not supported by the sample, such as arrays, indexed properties, and collections, the methods will be omitted from the sample and you will receive a warning message.

Related concepts
Creating Web services with the Apache Axis1 runtime environment
Related Concepts
Tools for Web services development
Web services development
Related Tasks
Developing Web services
Using the Web Services Explorer
Related Reference
WSDL documents