This sample demonstrates how to publish a stateful Java web service
and a stateless Java web service.
If you have already build and deployed the stateful Java web service example then
you can skip steps 1 to 10 and directly go to step 11 for JSP based web service client.

Instructions:

0. cd $ORACLE_HOME/j2ee/home/demo/web_services/java_services

1. Compile the Java classes to be exposed as iAS Web Services.

% javac -d src/ src/oracle/j2ee/ws_example/*.java

2. Packaging the iAS Web Services Archive file.

% java -jar $ORACLE_HOME/j2ee/home/WebServicesAssembler.jar -config ./config.xml

This generates the ws_example.ear file which contains the following
files when expanded --

ws_example.ear
|---META-INF
| `---application.xml
`---ws_example.war
|---index.html
`---WEB-INF
|------web.xml
`------classes
`------oracle
`-----j2ee
`---ws_example
|---StatefulExample.java
|---StatefulExample.class
|---StatefulExampleImpl.java
`---StatefulExampleImpl.class
|---StatelessExample.java
|---StatelessExample.class
|---StatelessExampleImpl.java
`---StatelessExampleImpl.class
|---BeanExample.java
|---BeanExample.class
|---BeanExampleImpl.java
`---BeanExampleImpl.class
BeanExample.java is an Java interface class which defines
the Java methods to be exposed as an Stateful web service
dealing with JavaBeans.

BeanExampleImpl.java is an implementation of the BeanExample
interface.

StatefulExample.java is an Java interface class which defines
the Java methods to be exposed as an Stateful web service.

StatefulExampleImpl.java is an implementation of the StatefulExample
interface.

StatelessExample.java is an Java interface class which defines
the Java methods to be exposed as an Stateless web service.

StatelessExampleImpl.java is an implementation of the StatelessExample
interface.

web.xml contains the required configurations to publish
StatefulExample and StatelessExample as Java web services.

3. Deploy the iAS Web Services Archive file.

% cd $ORACLE_HOME/j2ee/home

- In an iAS environment ,use the following command to deploy the ear file :

% dcmctl deployApplication -file demo/web_services/java_services/ws_example.ear -a ws_example

(it will deploy the application to the 'home' instance ,refer to 'OC4J - Users Guide' for more details on dcmctl)

4. If you have mod_oc4j.conf file, add a mount line --

Oc4jMount /web_services.

5. Access the WSDL.

For the stateless service, point your browser to
http://localhost:port/webservices/statelessTest?wsdl
and save the file under wsdl directory.

For the stateful service, point your browser to
http://localhost:port/webservices/statefulTest?wsdl
and save the file under wsdl directory.

6. Access the client side stub files.

For the stateless service, point your browser to
http://localhost:port/webservices/statelessTest?proxy_jar
and save the file (statelessTest_proxy.jar) under ./client directory.

For the stateful service, point your browser to
http://localhost:port/webservices/statefulTest?proxy_jar
and save the file (statefulTest_proxy.jar) under ./client directory.

7. Build your Web Services client.for Stateful Web Service

Create a Client.java file under ./client directory as follows --

public class Client
{
public static void main(String[] argv) throws Exception
{
StatefulExampleProxy proxy = new StatefulExampleProxy();
System.out.println(proxy.helloWorld("Scott"));
System.out.println(proxy.count());
System.out.println(proxy.count());
System.out.println(proxy.count());
}
}

StatefulExampleProxy class is included in the jar file(s)
downloaded above. It is the Web Services stub file generated by
iAS.

8. Compile/execute your client.
Make sure your class path contains the following jar files --

$ORACLE_HOME/soap/lib/wsdl.jar:$ORACLE_HOME/lib/xmlparserv2.jar:$ORACLE_HOME/soap/lib/soap.jar:

For stateful service client --

% cd client
% javac -classpath .:statefulTest_proxy.jar:$CLASSPATH Client.java
% java -classpath .:statefulTest_proxy.jar:$CLASSPATH Client

You will see result like "Hello World, Scott 0 1 2".

9) For stateless service client use StatelessClient.java

% cd client
% javac -classpath .:statelessTest_proxy.jar:$CLASSPATH StatelessClient.java
% java -classpath .:statelessTest_proxy.jar:$CLASSPATH StatelessClient

You will see result like "Hello World, Scott" and "Hello World, Wendy".

10) For stateful service with bean example
javac -classpath ./bean_proxy.jar:${CLASSPATH} Client.java
java -classpath ./bean_proxy.jar:${CLASSPATH} Client
You will see result like "DEMO PASSED";
Once you deploy the application and copy the proxy jar files to the client
directly, you can make use of the build.xml file provided by simply running "ant".

11) For Stateful Service client using JSP
Add library statefulTest_proxy.jar file path (Downloaded Proxy file in Step 6) to $ORACLE_HOME/j2ee/home/config/application.xml file in library element.
e.g. Add following element line
<library path="../demo/web_services/java_services/client/statefulTest_proxy.jar"/>
Now you can go to the OJSP demo web page and run wsclient.jsp .