Step 9: Deployment and Security

Your web service is one that sends sensitive information across the internet, so it would be a good idea to insure that your service is a secure one. In this step of the tutorial you will modify your web service so that is it exposed through HTTPS (Secure HTTP) instead of HTTP.

Note that the web services you build with WebLogic Workshop compiled as EAR files, and then are ultimately deployed to WebLogic Server as web applications. When finally deployed on WebLogic Server, your web service is contained within a web application and exposed through that web application. It is the containing web application that is exposed through an HTTPS-enabled port of WebLogic Server, so a web service is secure because it is contained in a web application that is exposed through a HTTPS-enabled port.

The tasks in this step are:

- To configure the web service to be exposed on HTTPS

- To change the default namespace of your web service

- To package the web application as an EAR file

- To deploy the web application on a production server

To Configure the Web Service to Be Exposed on HTTPS

You configure the exposure protocol of your web service by editting the weblogic-jws-config.xml file that resides in the samples project's WEB-INF directory.

1. In the Project pane, open the WEB-INF directory.

2. Open the file weblogic-jws-config.xml.

3. Edit weblogic-jws-config.xml to look like the following. Make sure to remove the comment tags (<!-- and -->) to activate the XML elements:

    <config>
     <protocol>http</protocol>
     <hostname>localhost</hostname>
     <http-port>7001</http-port>
     <https-port>7002</https-port>
     <jws>
      <class-name>HelloWorld</class-name>
      <protocol>http</protocol>
     </jws>
     <jws>
      <class-name>financialservices.Investigate</class-name>
      <protocol>https</protocol>
     </jws>
     <transaction-isolation-level>TRANSACTION_READ_COMMITTED</transaction-isolation-level>
     <ejb-concurrency-strategy>Exclusive</ejb-concurrency-strategy>
    </config>

To Change the Default Namespace of your Web Service

Before you deploy your web service, you should first define the web service within a unique namespace. This will ensure that there are no namespace conflicts with other web services.

1. In the Project Tree, double-click Investigate.jws (Note: there are two files called Investigate.jws in the samples project. Double-click the Investigate.jws file that resides in the financialservices folder, ignore the Investigate.jws file that resides in the tutorials folder.)

2. If you are not already in Design View, click the Design View tab.

3. Select the Investigate web service as a whole. To select the whole web service click the title of the web service as it appears in Design View. See the illustration below.

4. In Properties, under target-namespace, select the text box directly to the right of namespace. See the illustration below.

5. Type a unique value in the text box. The value you enter should be something that isn't likely to be chosen by other users of the tutorial. We suggest that you type your first pet's name plus your middle name.

To Package the Web Application as an EAR File

1. Stop WebLogic Server and close WebLogic Workshop.

2. Open a command prompt window.

3. Determine the directory where you installed WebLogic Server 7.0. If you did not explicitly specify an installation directory when you installed WebLogic Server 7.0, then your installation directory is C:\bea.

4. At the command prompt, type the following command. Make sure to substitute the installation directory in place of [BEA installation directory]. For example, if you installed WebLogic Server 7.0 to C:\bea, then you would type set BEA_HOME=C:\bea

    set BEA_HOME=[BEA installation directory]

5. Press enter.
6. At the command prompt, type the following command.

    set PATH=%PATH%;%BEA_HOME%\weblogic700\server\bin

This command insures that your machine can find the program used to compile your web service into an EAR file.

7. Press Enter.
8. In the same command prompt window, type the following command:

    mkdir C:\EARS

This command creates a new directory, EARS, on the C drive. This directory is used to store the EAR file generated from your web service.

9. Press Enter

10. In the same command prompt window, type the following command:

    cd %BEA_HOME%\weblogic700\samples\workshop\applications\samples\financialservices

This command changes the command prompt directory to point to the directory where your web service resides.

11. Press Enter.

12. Type the following command:

    jwsCompile -ear C:\EARS\MyFirstWebService.ear -app MyFirstWebService Investigate.jws

This command compiles your web service as an EAR file, and stores that EAR file in C:\EARS.

13. Press Enter.

14. When you receive a message that the compilation is successful, close the command prompt window.

To Deploy the Web Application on a Production Server

1. Open a new command window.

2. Determine the directory where you installed WebLogic Server 7.0. If you did not explicitly specify an installation directory when you installed WebLogic Server 7.0, then your installation directory is C:\bea.

3. At the command prompt, type the following command. Make sure to substitute the installation directory in place of [BEA installation directory]. For example, if you installed WebLogic Server 7.0 to C:\bea, then you would type set BEA_HOME=C:\bea

    set BEA_HOME=[BEA installation directory]

4. Press Enter.

5. At the command prompt, type the following command.

    %BEA_HOME%\weblogic700\samples\workshop\startWebLogic.cmd production nodebug

Do not close this command window. Once the server has finished its start routine, move on to the next step.

6. Open a new command window.
7. At the command prompt, type the following command. Make sure to substitute the installation directory in place of [BEA installation directory]. For example, if you installed WebLogic Server 7.0 to C:\bea, then you would type set BEA_HOME=C:\bea

    set BEA_HOME=[BEA installation directory]

8. Press Enter.
9. At the command prompt, type the following command.

    set PATH=%PATH%;%BEA_HOME%\jdk131_03\bin

This command ensures that your machine can find the program that will deploy the EAR file to WebLogic Server.

10. Press Enter.

11. At the command prompt, type the following command.

    java -cp %BEA_HOME%\weblogic700\server\lib\weblogic.jar weblogic.Deployer -password installadministrator -source C:\EARS\MyFirstWebService.ear -targets cgServer -name MyFirstWebService -activate

This command deploys the EAR file to WebLogic Server.

12. Press Enter. When you receive conformation that deployment was successful, move to the next step.

13. Open an internet browser, and enter the following address:

    http://localhost:7001/console

14. Logon to WebLogic Server using the username "installadministrator" and password "installadministrator".

15. Navigate to workshop/Deployments/Applications/MyFirstWebService, using the navigation pane on the left-hand side of the screen.

16. Note the two files contained in MyFirstWebService: MyFirstWebService.war and financialservices.InvestigateEJB.jar

17. Open another internet browser, and enter the following address:

    https://localhost:7002/MyFirstWebService/financialservices/Investigate.jws

18. The server will present you with a digital certificate. Press Yes to accept the certificate. A summary of the Investigate web service will appear.

19. Modify the address to look like the following:

    https://localhost:7002/MyFirstWebService/financialservices/Investigate.jws?WSDL

A WSDL file will appear. This is the WSDL that clients to your web service will use to learn how to operate your service.

You now have a complete and deployed web service ready to take requests from clients.