Deploying Web services from the command line

This section describes the command-line options for deploying J2EE Web services using the deploy command located in the bin subdirectory of your EAServer installation. See Chapter 12, “Command Line Tools” for more information about this, and other command line tools.

Command line:

deploy 
[options] 
entity
[-contextpath path]

The most simple form of the deploy command for the various archive files is:

Where:

Option

Description

-ws

There are three ws options that define how a Web service is exposed:

  • -ws – expose any Stateless Session Beans with a Remote Interface as a Web service.

  • -ws:<ejbName> – expose the Stateless Session Bean ejbName as a Web service.

  • -ws:<jarFileInEar>:<ejbName> – expose the Stateless Session Bean ejbName located in an application EAR file jarFileInEar as a Web service.

-wsClientAddress

Use this syntax to overwrite the <soap:address location> in the WSDL file referred to by <service-ref-name> in the web.xml, ejb-jar.xml or application-client.xml and the <port name> in the WSDL file:

-wsClientAddress:<serviceRefName>: <portComponentName> <address>

-wsContextPath <contextpath>

Use this syntax to specify the context path for an EJB Web service in an application EAR file:

-wsContextPath:<jarFileInEar>:<contextpath>

Use this syntax to specify the context path for an EJB Web Service:

-wsContextPath <contextpath>

-wsEndpointAddressURI

Specify the endpoint address URI for an EJB Web service using this syntax:

-wsEndpointAddressURI <ejbName>:<endpoint-address-uri>

Specify the endpoint address URI for an EJB Web service in an Application EAR file using this syntax:

-wsEndpointAddressURI:<jarFileInEar>:<ejbName>: <endpoint-address-uri>

-wsStyle

Specify the Web service style ( DOCUMENT, RPC or WRAPPED) of the generated WSDL binding used when exposing an EJB as a Web service using this syntax:

-wsStyle <style>

Specify the Web service style ( DOCUMENT, RPC or WRAPPED) of the generated WSDL binding used when exposing an EJB as a Web service contained in an application EAR file using this syntax:

-wsStyle:<jarFileInEar>:<style>

-wsUse

Specify the use (LITERAL or ENCODED) of items in the generated WSDL binding when exposing an EJB as a Web service using this syntax:

-wsUse <use>

Specify the use (LITERAL or ENCODED) of items in the generated WSDL binding when exposing an EJB as a Web service in an application EAR file using this syntax:

-wsUse:<jarFileInEar>:<use>

-wsWebAppName

Override the default name for the Web application generated from an EJB Web Service using this syntax:

-wsWebAppName <webappname>

Override default name for the Web application generated from an EJB Web Service in an application EAR file using this syntax:

-wsWebAppName:<jarFileInEar>:<webappname>

-entity

The file that you are deploying. entity should be located in the current directory, or provide the full path using the contextpath option.

-contextpath path

Specify the contextPath for Web application deployment. The default is the name of the WAR file. If -package is specified, then the package is the context path.

-help

Enter deploy -help to display all command line options

Examples

This example uses the deploy and undeploy commands located in EAServer’s bin subdirectory to demonstrate using default context path and default end point addresses for stateless EJB Web Services by deploying a Web service contained in the HiWS.jar file, and the client that is contained in the HiWSClient.war file.

  1. Deploy the HiWS.jar file:

    deploy.bat C:\WebSvcSample\setA\HiWS.jar (Windows)
    deploy.sh WebSvcSample/setA/HiWS.jar (Unix)
    
  2. Verify the EJB Web Service URL location from your browser:

    http://localhost:8000/hiws/HiWS?WSDL

    The WSDL of HiWS EJB Web service displays

  3. Deploy the HiWSClient.war file by entering this command from EAServer’s bin subdirectory:

    deploy.bat C:\WebSvcSample\setA\HiWSClient.war (Windows)
    deploy.sh WebSvcSample/setA/HiWSClient.war (Unix)
    
  4. Test the servlet by entering this URL in your browser:

    http://localhost:8000/HiWSClient/HiServlet

    Enter a name (e.g., John) and click Enter

    Result: Hi John!

  5. Undeploy the EJB and Web applications by entering these commands from EAServer’s bin subdirectory

    undeploy ejbjar-hiws

    undeploy webapp-hiwsclient

This example uses the deploy command to specify the context path and end point address for a stateless EJB Web service by matching the context path and end point address to the SOAP address specified in the HiWSClient.war’s hiWS.wsdl file. This typically happens when one organization provides the Web service and another organization uses/consumes the Web service. The set of published URIs (e.g., webservice/sayHi) serves as a contract between Web service provider and Web service consumer.

  1. Deploy the HiWS.jar file:

    deploy.bat -wsContextPath webservice -wsEndpointAddressURI HiWS:sayHi C:\WebSvcSample\setB\HiWS.jar (Windows)

    deploy.sh -wsContextPath webservice -wsEndpointAddressURI HiWS:sayHi WebSvcSample/setB/HiWS.jar (Unix)

  2. Verify the EJB Web service URL location by entering this in your browser:

    http://localhost:8000/\b webservice/sayHi\b0 ?WSDL

    The WSDL of HiWS EJB Web service displayes

  3. Deploy the HiWSClient.war file:

    deploy.bat C:\WebSvcSample\setB\HiWSClient.war (Windows)

    deploy.sh WebSvcSample\setB\HiWSClient.war (Unix)

  4. Test the servlet by entering this URL in your browser:

    http://localhost:8000/HiWSClient/HiServlet

    Enter a name (e.g., John) and click Enter

    Result: Hi John!

  5. Undeploy the EJB and Web applications:

    undeploy ejbjar-hiws

    undeploy webapp-hiwsclient