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
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.
In the Project pane, open the WEB-INF directory.
Open the file weblogic-jws-config.xml.
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.
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.)
If you are not already in Design View, click the Design View tab.
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.
In Properties,
under target-namespace, select
the text box directly to the right of namespace.
See the illustration below.
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
Stop WebLogic Server and close WebLogic Workshop.
Open a command prompt window.
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.
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]
This command insures that your machine can find the program used to compile your web service into an EAR file.set PATH=%PATH%;%BEA_HOME%\weblogic700\server\bin
mkdir C:\EARSThis command creates a new directory, EARS, on the C drive. This directory is used to store the EAR file generated from your web service.
Press Enter
In the same command prompt window, type the following command:
This command changes the command prompt directory to point to the directory where your web service resides.cd %BEA_HOME%\weblogic700\samples\workshop\applications\samples\financialservices
Press Enter.
Type the following command:
This command compiles your web service as an EAR file, and stores that EAR file in C:\EARS.jwsCompile -ear C:\EARS\MyFirstWebService.ear -app MyFirstWebService Investigate.jws
Press Enter.
When you receive a message that the compilation is successful, close the command prompt window.
To Deploy the Web Application on a Production Server
Open a new command window.
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.
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]
Press Enter.
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.
set BEA_HOME=[BEA installation directory]
This command ensures that your machine can find the program that will deploy the EAR file to WebLogic Server.set PATH=%PATH%;%BEA_HOME%\jdk131_03\bin
Press Enter.
At the command prompt, type the following command.
This command deploys the EAR file to WebLogic Server.java -cp %BEA_HOME%\weblogic700\server\lib\weblogic.jar weblogic.Deployer -password installadministrator -source C:\EARS\MyFirstWebService.ear -targets cgServer -name MyFirstWebService -activate
Open an internet browser, and enter the following address:
http://localhost:7001/console
Logon to WebLogic Server using the username "installadministrator" and password "installadministrator".
Navigate to workshop/Deployments/Applications/MyFirstWebService, using the navigation pane on the left-hand side of the screen.
Note the two files contained in MyFirstWebService: MyFirstWebService.war and financialservices.InvestigateEJB.jar
Open another internet browser, and enter the following address:
https://localhost:7002/MyFirstWebService/financialservices/Investigate.jws
The server will present you with a digital certificate. Press Yes to accept the certificate. A summary of the Investigate web service will appear.
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.