Developing WebLogic Web Services 3-9
file=exampleswebserviceswsdlcTemperaturePortTypeImpl.java compiledWsdl=outputcompiledWsdlTemperatureService_wsdl.jar
type=JAXRPC jwsc
target
In the preceding example, the TemperaturePortTypeImpl.java file is the stubbed-out JWS file that you updated to include your business logic. Because the
compiledWsdl attribute is specified and points to a JAR file, the jwsc Ant task does
not regenerate the artifacts that are included in the JAR. To actually run this task, type at the command line the following:
prompt ant build-service
3.6.2 Advanced Uses of jwsc
This section described two very simple examples of using the jwsc Ant task. The task, however, includes additional attributes and child elements that make the tool very
powerful and useful. For example, you can use the tool to:
■
Process multiple JWS files at once. You can choose to package each resulting Web Service into its own Web application WAR file, or group all of the Web Services
into a single WAR file.
■
Specify the transports HTTPHTTPSJMS that client applications can use when invoking the Web Service, possibly overriding any existing WLXXXTransport
annotations.
■
Automatically generate the JAX-RPC client stubs of any other Web Service that is invoked within the JWS file.
■
Update an existing Enterprise Application or Web application, rather than generate a completely new one.
See jwsc in the Oracle Fusion Middleware WebLogic Web Services Reference for Oracle WebLogic Server for complete documentation and examples about the jwsc Ant task.
3.7 Running the wsdlc WebLogic Web Services Ant Task
The wsdlc Ant task takes as input a WSDL file and generates artifacts that together partially implement a WebLogic Web Service. These artifacts include:
■
JWS service endpoint interface SEI that implements the Web Service described by the WSDL file.
■
JWS implementation file that contains a partial stubbed-out implementation of the generated JWS SEI. This file must be customized by the developer.
■
Data binding artifacts used by WebLogic Server to convert between the XML and Java representations of the Web Service parameters and return values.
■
Optional Javadocs for the generated JWS SEI. The wsdlc Ant task packages the JWS SEI and data binding artifacts together into a
JAR file that you later specify to the jwsc Ant task. You never need to update this JAR file; the only file you update is the JWS implementation class.
To run the wsdlc Ant task, add the following taskdef and generate-from-wsdl targets to the build.xml file:
taskdef name=wsdlc
3-10 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
classname=weblogic.wsee.tools.anttasks.WsdlcTask target name=generate-from-wsdl
wsdlc srcWsdl=WSDL_file
destJwsDir=JWS_interface_directory destImplDir=JWS_implementation_directory
packageName=Package_name type=WebService_type
target
where:
■
WSDL_file refers to the name of the WSDL file from which you want to generate
a partial implementation, including its absolute or relative pathname.
■
JWS_interface_directory refers to the directory into which the JAR file that
contains the JWS SEI and data binding artifacts should be generated. The name of the generated JAR file is WSDLFile_wsdl.jar, where WSDLFile
refers to the root name of the WSDL file. For example, if the name of the WSDL file you specify to the file attribute is MyService.wsdl, then the generated JAR file is
MyService_wsdl.jar .
■
JWS_implementation_directory refers to the top directory into which the
stubbed-out JWS implementation file is generated. The file is generated into a subdirectory hierarchy corresponding to its package name.
The name of the generated JWS file is PortTypeImpl.java, where PortType refers to the name attribute of the portType element in the WSDL file for
which you are generating a Web Service. For example, if the port type name is MyServicePortType
, then the JWS implementation file is called MyServicePortTypeImpl.java
.
■
Package_name refers to the package into which the generated JWS SEI and
implementation files should be generated. If you do not specify this attribute, the wsdlc
Ant task generates a package name based on the targetNamespace of the WSDL.
■
WebService_type specifies the type of Web Service. This value can be set to
JAXWS or JAXRPC. The required taskdef element specifies the full class name of the wsdlc Ant task.
Only the srcWsdl and destJwsDir attributes of the wsdlc Ant task are required. Typically, however, you generate the stubbed-out JWS file to make your programming
easier. Oracle recommends you explicitly specify the package name in case the targetNamespace
of the WSDL file is not suitable to be converted into a readable package name.
The following build.xml excerpt shows an example of running the wsdlc Ant task against a WSDL file:
taskdef name=wsdlc classname=weblogic.wsee.tools.anttasks.WsdlcTask
target name=generate-from-wsdl wsdlc
srcWsdl=wsdl_filesTemperatureService.wsdl destJwsDir=outputcompiledWsdl
destImplDir=impl_output packageName=examples.webservices.wsdlc
type=JAXRPC target
Developing WebLogic Web Services 3-11
In the example:
■
The existing WSDL file is called TemperatureService.wsdl and is located in the wsdl_files subdirectory of the directory that contains the build.xml file.
■
The JAR file that will contain the JWS SEI and data binding artifacts is generated to the outputcompiledWsdl directory; the name of the JAR file is
TemperatureService_wsdl.jar .
■
The package name of the generated JWS files is examples.webservices.wsdld
.
■
The stubbed-out JWS file is generated into the impl_ outputexampleswebserviceswsdlc
directory relative to the current directory.
■
Assuming that the port type name in the WSDL file is TemperaturePortType, then the name of the JWS implementation file is
TemperaturePortTypeImpl.java .
■
A JAX-RPC Web Service is generated. To actually run this task, type the following at the command line:
prompt ant generate-from-wsdl See wsdlc in Oracle Fusion Middleware WebLogic Web Services Reference for Oracle
WebLogic Server for more information.
3.8 Updating the Stubbed-out JWS Implementation Class File Generated By wsdlc