Handling Web Service Callback Messages

This topic explains how a web service control handles callback messages sent from a web service and passes them on to a control client.

A Web Service Callback Scenario

Suppose you have a web service that sends callback messages back to the client through a service control.

The following diagram shows how the client, service control, and web service are related. The client is a web service named HelloWorldClient.java, the service control is HelloWorldControl.java, and the target web service is HelloWorldService.java.

Arrows pointing the right are ordinary methods. Arrows pointing to the left depict an event handler method (onMessage_handler on the client), an event set method (onMessage on the service control), and a callback method (onMessage on the target web service).

Setting up a Callback Message Handler

Assume that the source code for the callback method onMessage on HelloWorldWebService.java is as follows:

HelloWorldWebService.java

@WebService
public class HelloWorldWebService {
  
    ...
   
    @CallbackService
    public interface CallbackSvc {
        @WebMethod
        public void onMessage(String aMessage);
    }
}

To handle this callback message in a service control, add an event set interface that includes a method with the same name as the callback method, decorated with the annotation @ServiceControl.ExternalCallbackEvent.

HelloWorldControl.java

    @EventSet(unicast=true)
    public interface Callback
    {
        @ServiceControl.ExternalCallbackEvent
        public void onMessage(java.lang.String aMessage_arg);
    }

For information on using a service control in a client, see Creating and Using a Service Control.

For information on setting up a callback interface in a web service see Web Service Callbacks.

Automatically Generating a Service Control

You can automatically generate a service control with the appropriate event set methods by right-clicking on the target web service's WSDL and selecting Web Service > Generate Service Control. A service control will be generated with event set methods corresponding to all of the callback methods in the target web service.

Related Topics

Creating and Using a Service Control

Web Service Callbacks


Still need help? Post a question on the Workshop newsgroup.