Updating a Stand-Alone Java Client to Invoke a Conversational Web Service

4-10 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server 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 ConversationalService 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 ConversationalClientImpl JWS file imports and uses one of the generated classes.

4.7 Updating a Stand-Alone Java Client to Invoke a Conversational Web Service

The following example shows a simple stand-alone Java client that invokes the conversational Web service described in Section 4.3, Programming Guidelines for the Conversational JWS File . See the explanation after the example for coding guidelines that correspond to the Java code in bold. package examples.webservices.conv_standalone.client; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import javax.xml.rpc.Stub; import weblogic.wsee.jaxrpc.WLStub; stand-alone client that invokes and converses with ConversationlService. public class Main { public static void mainString[] args throws ServiceException, RemoteException{ ConversationalService service = new ConversationalService_Implargs[0] + ?WSDL; ConversationalPortType port = service.getConversationalServicePort; Set property on stub to specify that client is invoking a Web service that uses advanced features; this property is automatically set if the client runs in a WebLogic Server instance. Stub stub = Stubport; stub._setPropertyWLStub.COMPLEX, true; Invoke start operation to begin the conversation String result = port.start; System.out.printlnstart method executed.; System.out.printlnThe message is: + result; Invoke continue operation result = port.middlemiddle ; System.out.printlnmiddle method executed.; System.out.printlnThe message is: + result; Creating Conversational Web Services 4-11 Invoke finish operation result = port.finishfinish ; System.out.printlnfinish method executed.; System.out.printlnThe message is: + result; } } Follow these guidelines when programming the stand-alone Java client that invokes a conversational Web service. Code snippets of the guidelines are shown in bold in the preceding example. ■ Import the weblogic.wsee.jaxrpc.WLStub class: import weblogic.wsee.jaxrpc.WLStub; ■ Set the WLStub.Complex property on the JAX-RPC stub of the ConversationalService using the _setProperty method: Stub stub = Stubport; stub._setPropertyWLStub.COMPLEX, true; This property specifies to the Web services runtime that the client is going to invoke an advanced Web service, in this case a conversational one. This property is automatically set when invoking a conversational Web service from another WebLogic Web service. ■ Invoke the start operation of the conversational Web service to start the conversation: String result = port.start; ■ Optionally invoke the continue methods to continue the conversation: result = port.middlemessage ; ■ Once the conversation is completed, invoke the finish operation so that the conversational Web service can free up the resources it used for the current conversation: result = port.finishmessage ;

4.8 Example Conversational Web Service .NET Client