The example shows how use Oracle Web Service Compiler (wsc.jar) to create a web service application (ear file) directly from a Java Source (.java) file with Web Services Metadata annotation in JavaDoc comments. In the source code example Hello.java we use annotation to indicate rpc-literal message style being used, and we also specify the subset of methods that are to be exposed.
NOTE: In order to process javadoc, wsc.jar has dependency on tools.jar from JDK1.4. If wsc.jar cannot find tools.jar under {ORACLE_HOME}/jdk/lib, execution will exit.
Quick StartEnsure that you have installed the required software and set up your environment. You must have OC4J running. If it is not running on your localhost on port 8888, you'll have to modify the ANT script (build.xml) to use the correct host and port to your server.
Once you have the server configured and running, just type ant. The web service ear file will be generated from the Hello.java source code by wsc.jar, and deployed to OC4J. Then the ant script uses the Web Services Assembler (wsa.jar) to generate aclient-side proxy. After compiling the client proxy, the script runs the client code oracle.demo.metadata.clientHelloClient to invoke the Web Service.
Step By StepTo create a deployable ear from a java source file with Web Service annotation in JavaDoc comments, type:
% ant wsc-Hello
or
% java -jar wsc.jar -output build/Hello.ear Hello.java
This should result in a J2EE Web Services compliant application file:
build/Hello.ear. The -output
% ant deploy-Hello
Visit the http test page by going to http://localhost:8888/Hello/Hello and ensure that the application has been deployed properly.
To run the client, issue:
% ant run-Hello-client
You should see a result like:
HelloClient: Hello WebService Metadata
NOTE: The client code is oracle.demo.metadata.client.HelloClient under client-src directory. In order to compile and run this class, client-side stubs(proxy) needs to be generated and compiled into client's classpath. The ant target run-Hello-client does all of these. The script runs wsa with the config filestub-config.xml to generate client proxy.
/** @oracle.ws.WebService (portTypeName="MyHelloType", typeNamespace="/xsd", * targetNamespace="/index.html") **/
/** @oracle.ws.PortBinding( bindingName = "HelloPortBinding", * style = "rpc", use = "literal" ) */
java -jar wsc.jar options file1.java
...
where possible options include: