Apama 10.3 | Apama Documentation | Connecting Apama Applications to External Components | Standard IAF Plug-ins | The Web Services Client IAF Adapter | Using EPL to interact with web services
Using EPL to interact with web services
Apama applications that interact with web services need to use specific Apama Event Processing Language (EPL) code to do so.
Define the Apama events that are to be used specifically to interact with the web services. If the application will use a convention-based approach to mapping, design Apama events such that the event fields correspond to the elements of the associated web service messages. Note that fields that correspond to attributes in the web service messages should be prefixed with an underscore character (_). For more information on convention-based mapping, see Convention-based XML mapping.
For example:
event GetStockDailyValue{
string strStockExchange;
string strStock;
string strDate;
event Stock{
string stockexchange;
string stock;
string date;
event StockValue{
string response;
The com.apampa.ws and com.apama.statusreport packages define events that are helpful when invoking web services. For convenience, specify using statements for the events you want to use so that you do not need to specify their full paths. For example:
using com.apama.statusreport.Status;
using com.apama.ws.WSError;
using com.apama.ws.SetupContextListeners;
using com.apama.statusreport.SubscribeStatus;
Define a listener for an AdapterUp event that indicates that the Web Services Client adapter instance is available to pass your application's service requests to the web service. In this listener, be sure to specify the name of the adapter instance as it appears in the EPL file that Software AG Designer generates. Also, in the body of the listener, enqueue an event to subscribe to the web service. For example:
on com.apama.adapters.AdapterUp(adapterName = service_id) {
enqueue SubscribeStatus(service_id,"","","");
Define a listener for an event that indicates that the web service is available to respond to requests. When the web service is available set up a listener for an event that you specified as the output event for an operation, that is, a listener for response messages from the web service. If the application depends on a correlation ID, this listener needs to test the value of the field specified as the correlation field. You can then invoke the web service by routing an event you specified as the input event for a particular operation. For example:
on Status(available=true, serviceID = service_id) as stat{
send Stock("NASDAQ","MSFT","2011-07-12") to "" ;
action listenResponse() {
on all StockValue() as stockRes {
log stockRes.toString() at INFO;
on all WSError() as wsError {
print "At service " + wsError.extraParams["serviceId"];
// wsError always contains service id
print "For the requested event " + wsError.requestEvent ;
print " got the error message as " + wsError.errorMsg ;
print " Failure message is " + wsError.failureType ;
// See WSConstants event for types of failure

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.