8.2.  Create a web service starting from a Java source using JAX-WS.

8.2.1.  Use wsgen tool to generate artifacts in Java EE5 (optional in Java EE6 - as artifacts are generated at run time)

The wsgen command-line tool generates the necessary portable artifacts required for Java API for XML Web Services (JAX-WS) applications when starting from Java code. This tool will generate a WSDL file only when requested.

When using a bottoms-up approach to develop JAX-WS web services and you are starting from a service endpoint implementation, use the wsgen tool to generate the required JAX-WS portable artifacts.

The wsgen tool accepts a properly annotated service endpoint implementation using the @WebService annotation as input and generates the following portable artifacts:

  • any additional Java Architecture for XML Binding (JAXB) classes that are required to marshal and unmarshal the message contents.

  • a WSDL file if the optional -wsdl argument is specified. The wsgen tool does not automatically generate the WSDL file.

The command line syntax is:

wsgen [options] service_implementation_class
						

The service_implementation_class name is the only parameter that is required. The following parameters are optional for the wsgen command:

  • -classpath <path>

    Specifies the location of the service implementation class.

  • -cp <path>

    This is the same as -classpath <path>.

  • -d <directory>

    Specifies where to place the generated output files.

  • -extension

    Specifies whether to allow custom extensions for functionality not specified by the JAX-WS specification. Use of the extensions can result in applications that are not portable or do not interoperate with other implementations.

  • -keep

    Specifies whether to keep the generated source files.

  • -r <directory>

    This parameter is only used in conjunction with the -wsdl parameter. Specifies where to place the generated WSDL file.

  • -s <directory>

    Specifies the directory to place the generated source files.

  • -wsdl [:protocol]

    By default, wsgen does not generate a WSDL file. This optional parameter causes wsgen to generate a WSDL file and is typically only used to allow a developer to review a WSDL file before the endpoint is deployed. The protocol is optional and specifies the protocol used in the wsdl:binding. Valid values for protocol are soap 1.1 and Xsoap 1.2. The default value is soap 1.1. The Xsoap 1.2 value is not standard and can only be used in conjunction with the -extension option.

  • -servicename <name>

    This parameter is only used in conjunction with the -wsdl option. Specifies a wsdl:service name to be generated in the WSDL file. For example:

    -servicename "{http://mynamespace/}MyService"
    									

  • -portname

    This parameter is only used in conjunction with the -wsdl option. Specifies a wsdl:port name to be generated in the WSDL file. For example:

    -portname "{http://mynamespace/}MyPort"
    									

Note that you must run wsgen against a Java class that has already been compiled (not against the source program), and if you specify a directory in which the tool should place generated files such as the WSDL, that directory must exist before you run the program. Also, you must run the tool against an implementation class, and not an interface.

8.2.2.  Use Endpoint API to configure and deploy it in Java SE 6 platform.

blah-blah

Professional hosting         'Oracle Certified Expert Web Services Developer 6' Quiz     Free SCDJWS 5.0 Guide