5-6 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server
how the operation is going to be invoked, consider creating two flavors of the operation: synchronous and asynchronous.
See Chapter 2, Invoking a Web Service Using Asynchronous Request-Response,
and Chapter 6, Using the Asynchronous Features Together.
5.5 Programming the JWS File That Invokes the Buffered Web Service
You can invoke a buffered Web service from both a stand-alone Java application if not using asynchronous request-response and from another Web service. Unlike other
WebLogic Web services asynchronous features, however, you do not use the ServiceClient
JWS annotation in the client Web service, but rather, you invoke the service as you would any other. For details, see Invoking a Web Service from
Another Web Service in Getting Started With JAX-RPC Web Services for Oracle WebLogic Server.
The following sample JWS file shows how to invoke the sayHelloNoReturn operation of the BufferedService Web service:
package examples.webservices.buffered; import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException; import javax.jws.WebService;
import javax.jws.WebMethod; import weblogic.jws.WLHttpTransport;
import examples.webservices.buffered.BufferedPortType; import examples.webservices.buffered.BufferedService_Impl;
import examples.webservices.buffered.BufferedService;
WebServicename=BufferedClientPortType, serviceName=BufferedClientService,
targetNamespace=http:examples.org
WLHttpTransportcontextPath=bufferedClient, serviceUri=BufferedClientService,
portName=BufferedClientPort
public class BufferedClientImpl { WebMethod
public String callBufferedServiceString input, String serviceUrl throws RemoteException {
try { BufferedService service = new BufferedService_ImplserviceUrl + ?WSDL;
BufferedPortType port = service.getBufferedPort; Invoke the sayHelloNoReturn operation of BufferedService
port.sayHelloNoReturninput; return Invoke went okay;
} catch ServiceException se {
Creating Buffered Web Services 5-7
System.out.printlnServiceExcpetion thrown; throw new RuntimeExceptionse;
} }
}
5.6 Updating the build.xml File for a Client of the Buffered Web Service
To update a build.xml file to generate the JWS file that invokes a buffered Web service operation, add taskdefs and a build-clientService targets that look
something like the following example. See the description after the example for details.
taskdef name=jwsc classname=weblogic.wsee.tools.anttasks.JwscTask
target name=build-clientService jwsc
enableAsyncService=true srcdir=src
destdir={clientService-ear-dir}
jws file=exampleswebservicesbufferedBufferedClientImpl.java clientgen
wsdl=http:{wls.hostname}:{wls.port}bufferedBufferedService?WSDL packageName=examples.webservices.buffered
jws jwsc
target Use the taskdef Ant task to define the full classname of the jwsc Ant tasks.
Update the jwsc Ant task that compiles the client Web service to include a clientgen
child element of the jws element so as to generate and compile the JAX-RPC stubs for the deployed BufferedService Web service. The jwsc Ant task
automatically packages them in the generated WAR file so that the client Web service can immediately access the stubs. You do this because the BufferedClientImpl
JWS file imports and uses one of the generated classes.
5-8 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server
6
Using the Asynchronous Features Together 6-1