Programming Guidelines for the Callback Interface

Using Callbacks to Notify Clients of Events 7-7 } The preceding code also shows how to use the optional CallbackRolesAllowed annotation to further restrict the security roles that are allowed to invoke this particular callback method. See JWS Annotation Reference in WebLogic Web Services Reference for Oracle WebLogic Server for additional information about the WebLogic-specific JWS annotations discussed in this section.

7.6 Programming Guidelines for the Callback Interface

The callback interface is also a JWS file that implements a Web service, except for one big difference: instead of using the standard javax.jws.WebService annotation to specify that it is a standard Web service, you use the WebLogic-specific weblogic.jws.CallbackService to specify that it is a callback service. The attributes of CallbackService are a restricted subset of the attributes of WebService . Follow these restrictions on the allowed data types and JWS annotations when programming the JWS file that implements a callback service: ■ You cannot use any WebLogic-specific JWS annotations other than weblogic.jws.CallbackService . ■ You can use all standard JWS annotations except for the following: – javax.jws.HandlerChain – javax.jws.soap.SOAPMessageHandler – javax.jws.soap.SOAPMessageHandlers ■ You can use all supported data types as parameters or return values except Holder classes user-defined data types that implement the javax.xml.rpc.holders.Holder interface. The following example shows a simple callback interface file that implements a callback Web service. The target Web service, described in Section 7.4, Programming Guidelines for Target Web Service , explicitly invokes a method in this interface. The jwsc -generated implementation of the callback interface then automatically sends a message back to the client Web service that originally invoked the target Web service; the client service is described in Section 7.5, Programming Guidelines for the Callback Client Web Service . See the explanation after the example for coding guidelines that correspond to the Java code in bold. package examples.webservices.callback; import weblogic.jws.CallbackService; import javax.jws.Oneway; import javax.jws.WebMethod; CallbackService public interface CallbackInterface { WebMethod Oneway public void callbackOperation String msg; } 7-8 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server Follow these guidelines when programming the JWS interface file that implements the callback Web service. Code snippets of the guidelines are shown in bold in the preceding example. ■ Import the required JWS annotation: import weblogic.jws.CallbackService; ■ Annotate the interface declaration with the CallbackService annotation to specify that the JWS file implements a callback service: CallbackService public interface CallbackInterface { ■ Create a method that the target Web service explicitly invokes; this is the method that automatically sends a message back to the client service that originally invoked the target Web service. Because this is a Java interface file, you do not provide an implementation of this method. Rather, the WebLogic Web services runtime generates an implementation of the method via the jwsc Ant task. public void callbackOperation String msg; See JWS Annotation Reference in WebLogic Web Services Reference for Oracle WebLogic Server for additional information about the WebLogic-specific JWS annotations discussed in this section.

7.7 Updating the build.xml File for the Client Web Service