} }
Files Prepare Run Troubleshooting Related Topics
This example shows how to use the wsdlc and jwsc Ant tasks in combination to create a WebLogic Web Service based on an existing WSDL file.
For the sake of clarity, the WSDL file (and resulting Web Service) is very simple. The Web service is called Temperature, and it contains a single operation getTemp that takes as input a String value and returns a hard-coded temperature float value.
The example shows how to first execute the wsdlc Ant task, which takes as input the WSDL file, and, based on the operations, parameters, return values, and so on in the WSDL, generates a set of artifacts that together provide a partial implementation of the Web Service described by the WSDL file. These components include:
The wsdlc task generates this JWS implementation file in the directory specified by the destImplDir attribute; the subdirectory hierarchy corresponds either to the packageName attribute, or to the targetNamespace URL of the WSDL if the packageName attribute is not specified. The name of the JWS file is PortTypeNameImpl.java, where PortTypeName refers to the value of the name attribute of the appropriate <portType> element in the WSDL file. The name of the methods and parameters in the JWS file is the same as the name of the operations and input parmeters in the WSDL file.
After running the wsdlc Ant task and updating the wsdlc-generated JWS file, the example shows how to run the jwsc Ant task the JWS file to create a deployable Web Service. The only additional attribute specify in this case is the compiledWsdl attribute of the <jws> child element, which points to the wsdlc-generated JAR file that contains the JWS interface file and the data binding artifacts.
The example then deploys the Web Service to the examplesServer as usual, and generates a standalone Java client application that invokes the getTemp operation of the Temperature Web Service. The TemperatureClient.java application uses the JAX-RPC Stubs generated by the clientgen WebLogic Web Service Ant task, based on the WSDL of the Temperature Web Service.
Directory Location:
MW_HOME/wlserver_10.3/samples/server/examples/src/examples/webservices/wsdl2service/
(where MW_HOME is the directory containing your WebLogic Server installation)
File Click source files to view code. |
Description |
---|---|
build.xml | Ant build file that contains targets for building and running the example. |
client/TemperatureClient.java | Standalone client application that invokes the deployed TemperatureService Web Service. Uses the JAX-RPC Stubs generated by clientgen, based on the WSDL of the Web Service. |
wsdl_files/TemperatureService.wsdl | Existing WSDL file from which the wsdl2service Ant task generates the needed components, including the JWS interface that represents the TemperatureService Web Service that has a single method, getTemp. |
Before working with this example:
No special configuration is required for this example
Change to the SAMPLES_HOME\server\examples\src\examples\webservices\wsdl2service directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.
This simulates adding business logic to the JWS implementation file.public float getTemp(java.lang.String zipcode) { return 101.0f; }
To run the example, follow these steps:
prompt> ant run
http://host:port/soap/servlet/rpcrouter?WSDL
where
This URL is the same as the value of the location attribute of the <soap:address> element in the original WSDL, except that the host and port of the hosting server is obviously changed to that of WebLogic Server.
If your example runs successfully, you will get the following message in the command shell from which you ran the client application:
Buildfile: build.xml
run:
[java] Got resut: 101.0BUILD SUCCESSFUL
Total time: 6 seconds
(Internet connection required.)