Deploying Web Services

# Development Mode and Production Mode

WebLogic Server can be run in two modes with respect to web services: development mode and production mode.

The default mode of the server is development mode, which provides support for iterative development. Your web service application source files are stored on disk in exploded directory format. Changes to those source files are dynamically noted by the server and affect the running service. Developers of web services should run the server in development mode.

At some point you may want to deploy a web service onto a different server than the one you developed it on. The most common reason for this is to make the service available on a publicly accessible server, which is usually not a server that is used for development. Such a server should be run in production mode. WebLogic Workshop web services must be packaged as EAR files when deployed on a WebLogic Server running in production mode. It is not possible to modify an application that is running on a production mode server. However, an application can be updated (on a development server) and then redeployed to a production mode server.

WebLogic Server and WebLogic Workshop provide command line tools to perform tasks related to taking a application developed on one server and deploying it to another. These command line tools are:

- JwsCompile -- used to generate an EAR that contains all the code for a Web Service application and that can be deployed on another machine.

- weblogic.Deployer -- used to deploy an EAR onto a production mode server.

# Deploying Web Services to a Production Server

When you deploy WebLogic Workshop web services to a production mode server, you deploy all or part of a WebLogic Workshop project. A deployed project may contain a single web service or multiple web services. A WebLogic Workshop project is deployed to the production server as a web applications.

To deploy a WebLogic Workshop project to a production mode server you must:

- Generate an EAR file from the WebLogic Workshop project on the development server

- Start the target server in production mode

- Deploy the EAR file to the production server

## Generate an EAR from the Workshop Project

Let’s say you have finished developing a Workshop project and are ready to deploy it to a production mode server. The first step is to use the JwsCompile command line tool to generate an EAR for that project. For a full description of the JwsCompile tool see JwsCompile Command in the Reference section.

If the root of your project is C:\bea\weblogic700\samples\workshop\applications\foo, and you want to create an EAR for that application called foo.ear and place that EAR in the directory C:/myEARS/, run the following:

JwsCompile –p C:\bea\weblogic700\samples\workshop\applications\foo –a –ear C:\myEARS\foo.ear

JwsCompile configures the web services to run on a particular hostname and port. The default hostname is whatever machine JwsCompile is run on, and the default port is 7001 (WebLogic Server default). In order to specify that the deployed web services are to run on a different host and port, you may either:

- create a configuration file named weblogic-jws-config.xml in the project’s WEB-INF directory

- use the -hostname and -http-port parameters of JwsCompile at compile-time

Note that the values in weblogic-jws-config.xml will be overridden by the -hostname and -http-port parameters specified when running JwsCompile. The following sample shows a weblogic-jws-config.xml file for deploying the web service HelloWorld to a machine named ProductionServer:

    <config>
     <protocol>http</protocol>
     <hostname>ProductionServer</hostname>
     <http-port>7001</http-port>
     <https-port>7002</https-port>
     <jws>
      <class-name>HelloWorld</class-name>
      <protocol>http</protocol>
     </jws>
    </config>

By default, JwsCompile will package all of the web services within a project into the EAR file. If you wish to deploy only some of the web services within a project, you can specify that JwsCompile perform a partial compilation of project. For example, if your project contains two web services, called WebService1 and WebService2, but you only want to deploy WebService1, then specify that JwsCompile should compile only WebService1 into the EAR file. To specify that JwsCompile should only compile WebService1, explicitly name WebService1 when you run JwsCompile as shown here:

JwsCompile –p C:\bea\weblogic700\samples\workshop\applications\foo –a –ear C:\myEARS\foo.ear WebService1.jws

The EAR file that is produced will contain only WebService1, so WebService2 will not be deployed.

For a complete description of the syntax for weblogic-jws-config.xml see weblogic-jws-config.xml Configuration File in the Reference section.

## Start WebLogic Server in Production Mode

The mode that the server is running in is determined at startup time. By default, the server runs in development mode. To make the server run in production mode, include the production parameter when calling the startWebLogic script. It is also recommended that you include a nodebug parameter when starting in production mode. For example, if you have installed WebLogic Server on the C: drive, the following command will start WebLogic Server in production mode:

C:\bea\weblogic700\samples\workshop\startWebLogic.cmd production nodebug

Note: Running WebLogic Workshop while WebLogic Server is running in production mode is not recommended.

## Deploy the EAR file to the Production Mode Server

A server must be running in production mode in order for you to be able to deploy applications to it. Use the weblogic.Deployer command line tool to deploy an EAR to a production mode server. For example, to deploy an EAR file named foo.ear which resides on your local machine at C:/myEARs/, run the following.

C:\>java weblogic.Deployer -password installadministrator -source C:\myEARS\foo.ear -targets cgServer -name foo -activate

To run weblogic.Deployer, you need weblogic.jar in you classpath.

For a complete description of weblogic.Deployer syntax, see weblogic.Deployer in the WebLogic Server 7.0 documentation.

Alternatively, you can deploy through the WebLogic Server console. For instructions on deploying an EAR by either of these methods, see How Do I: Deploy WebLogic Workshop Web Services to a Production Server .

Related Topics

How Do I: Deploy WebLogic Workshop Web Services to a Production Server?