<diffmk:wrapper>In this chapter we provide you with the necessary steps to create a Web Service using JBossWS runtime. First you need to create a Dynamic Web project:</diffmk:wrapper>
Before creating a web service, you should have a Dynamic Web Project created:
Create a Web project by selecting New > Project... > Dynamic Web project. Enter the following information:
Project Name: enter a project name
Target runtime: any server depending on your installation. If it is not listed, click New and browse to the location where it is installed to. You may set Target Runtime to None, in this case, you should add JBoss Web Service facet to the project.
Configure Web Module values:
Click on the Finish<diffmk:wrapper> button. Next you will need to add JBoss Web Service facet to the project:</diffmk:wrapper>
<diffmk:wrapper>If you have already created a new Dynamic Web project, the next step is to add JBoss Web Service facet to the project. Right-click on the project, select its </diffmk:wrapper><diffmk:wrapper>Properties</diffmk:wrapper><diffmk:wrapper> and then find </diffmk:wrapper><diffmk:wrapper>Project Facets</diffmk:wrapper><diffmk:wrapper> in the tree-view on the left-side of the project properties dialog. Tick on the check box for JBoss Web Services and open additional configuration for it, having clicked on the </diffmk:wrapper><diffmk:wrapper>Further configuration required...</diffmk:wrapper><diffmk:wrapper> link. In the opened window</diffmk:wrapper>
Server Supplied JBossWS Runtime: If you have already set a JBoss runtime to the project's target runtime, you may choose Server Supplied JBossWS Runtime and then click Ok to finish the configuration of JBoss Web Service facet.
If the project has no Target Runtime settings, you should check the second radio button and specify a JBossWS runtime from the list. You also can create a new JBossWS runtime, click on the New... button will bring you to another dialog to configure new JBossWS runtime.
See how to configure a new JBossWS runtime here<diffmk:wrapper>.</diffmk:wrapper>
In this chapter we provide you with the necessary steps to create a Web Service from a WSDL document using JBossWS runtime.
At first, please make sure that you have already created a dynamic Web project with JBoss Web Service facet installed.
See how to make it here<diffmk:wrapper> and </diffmk:wrapper>here.
To create a Web Service using JBossWS runtime select File > New > Other > Web Services > Web Service to run Web Service creation wizard.
Let's get through the wizard step-by-step:
First, please select Top down Java bean Web Service<diffmk:wrapper> from the Web Service type list, and select a WSDL document from workspace, click on the Server name link on the page will bring you to another dialog. Here you can specify the server to a JBoss Server and Web Service runtime to JBossWS runtime:</diffmk:wrapper>
Click on the Finish button to see the next wizard view opened:
Click on the Next button to proceed:
On this page, the default package name comes from the namespace of the WSDL document, you also can change it to any valid package name you want. JAX-WS specification should be set to 2.0 if your JBossWS runtime in JBoss Server is JBossWS native runtime. You can specify a catalog file and binding files if you have them. If you want the wizard to generate empty implementation classes for the Web Service, check the Generate default Web Service implementation classes check box. If you want to update the default Web.xml file with the Web Service servlets configured, check the Update the default Web.xml check box. Click on the Next or on the Finish button to generate code.
Once the Web Service code is generated, you can view the implementation class and add business logic to each method.
View the Web.xml file:
<diffmk:wrapper>In the next chapter you will find out how to create a Web service from a Java bean.</diffmk:wrapper>
The Web Service wizard assists you in creating a new Web service, configuring it for deployment, and then deploying it to the server.
To create a Web service from a bean using JBoss WS:
Setup JBoss WS and development environment.
Create a Dynamic Web project.
Add JBossWS Facet to Web project.
Create a Web Service from a java bean:
Switch to the Java EE perspective Window > Open Perspective > Java EE.
In the Project Explorer view, select the bean that you created or imported into the source folder of your Web project.
Click File > New > Other. Select Web Services in order to display various Web service wizards. Select the Web Service wizard. Click on the Next button.
On the first Web Service wizard page: select Bottom up Java bean Web service as your Web service type, and select the Java bean from which the service will be created:
Select the stages of Web service 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 modules that will contain 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.
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.
Select your runtime: ensure the JBoss WS runtime is selected.
Select the service project: the project selected in your workspace is displayed. To select a different project click on the project link. If you are deploying to JBoss Application Server you will also be asked to select the EAR associated with the project. 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.
If you want to create a client, select the type of proxy to be generated and repeat the above steps for the client. The better way is to create a web service client project separately.
Click on the Next button.
On the JBoss Web Service Code Generation Configuration page, set the following values:
Generate WSDL file: select it, you will get a generated WSDL file in your project. But this wsdl's services' address location values are not a real address.
After the Web service has been created, the following option can become available depending on the options you selected: Update the default web.xm file. If selected, you may test the web service by Explorer.
Click on the Next button.
On this page, the project is deployed to the server. You can start the server and test the web service. If you want to publish the web service to a UDDI registry, you may click the Next button to publish it. If not, you may click the Finish button.
After the Web Service has been created, the following options may become available depending on the options selected:
the generated web services code
If you selected to generate a WSDL file, you will get the file in your project's wsdl folder.
Figure 2.17. <diffmk:wrapper>The Generated HelloWorldService.wsdl File in the wsdl Folder</diffmk:wrapper>
If you selected to update the default web.xml, you will test the web service in the browser. Open the Explorer, input the url for the web service according to web.xml plus ?wsdl., you will get the WSDL file from Explorer.
<diffmk:wrapper>In the next chapter you will be able to create a Web Service Client from a WSDL document using JBoss WS.</diffmk:wrapper>