Package examples.webservices.basic.javaclass
Class Summary
Client Client.java Class that illustrates how to use the JAX-RPC API to statically invoke the HelloWorld WebLogic Web Service, implemented with a Java class. HelloWorld HelloWorld.java Simple Java class that implements the HelloWorld Web service.
Package examples.webservices.basic.javaclass Description
This example shows how to create a WebLogic Web service based on a custom Java class backend component.
The Java class is a classic HelloWorld program that defines a single method called sayHello. The method takes only built-in data types as its parameters and return value. In particular, the sayHello method takes as input an int and a String parameter and returns a String return value.
When the Java class is converted into a Web service, the sayHello method becomes the public operation specified in the WSDL of the Web service.
The build.xml file compiles, assembles, packages, deploys, and runs the example. The file calls the servicegen WebLogic Ant task that automatically generates:
- A client JAR file that contains all the classes and interfaces needed by client applications that invoke the Web service.
- the Web services deployment descriptor file, web-services.xml, that describes how to deploy the Web service on WebLogic Server
After servicegen generates these components, it packages them, along with the Java class, into an EAR file that can be deployed on WebLogic Server.
The build.xml file then calls the clientgen Ant task that creates another client JAR file used by a client application to invoke the Web service. This client JAR file is created locally rather than the one that's created as part of the servicegen Ant task that ends up on WebLogic Server. Typically users that need the client JAR file either use the clientgen Ant task or download it from the Web services Home Page.
Client.java is a static client application that directly uses the Web service interfaces to invoke the sayHello operation. It uses JAX-RPC style APIs to invoke the Web service.
Additional Resources for examples.webservices.basic.javaclass
The Java Ant build script that creates the Java class JAR file, creates the EAR file using the servicegen Ant task, creates the client JAR file using the clientgen Ant task, compiles the client application, deploys the EAR file, and runs the application.
Build the Example
To build the example, follow these steps:
- Set up your development shell.
- Go to the code:
cd $SAMPLES_HOME/server/examples/src/examples/webservices/basic/javaclass
- Assemble and compile the example by executing the Java ant utility at the command line:
prompt> ant- Start the examples WebLogic Server.
- In your development shell, run the Client Java application using the following command:
prompt> ant run- After building and running the example, you can view the Web Service Home Page using the following URL:
http://www.setgetweb.com:7001/basic_javaclass/HelloWorldFrom the Web Service Home Page you can view the generated WSDL and test the Web service to make sure it's working correctly.
Check the Output
If your example runs successfully, you will get the following message in the command shell from which you started WebLogic Server:sayHello in webservices.basic.javaclass webservice has been invoked with arguments A and 4And the following output in your client window:Buildfile: build.xml run: [java] The client passed the Values 4 and A to the webservice, and got back this result: [java] This message brought to you by the letter A and the number 4 BUILD SUCCESSFUL
See Also
Read more about:
- WebLogic Web services in Programming WebLogic Web Services.
- Additional Web Service Examples on the dev2dev Web site or from the