Wednesday, July 13, 2016

Working with SOAP Receiver Sample in WSO2 CEP

Introduction to WSO2 CEP SOAP Receiver

Events are received by WSO2 CEP server using event receivers, which manage the event retrieval process. WSO2 CEP receives events via multiple transports in JSON, XML, Map, Text, and WSO2Event formats, and converts them into streams of canonical WSO2Events to be processed by the server. SOAP event receiver is used to receive events in XML format via HTTP, HTTPS, and local transports.

Doing the soap sample already available

WSO2 CEP has samples for every Event Receivers it has. You can run the sample very easily like below.
Steps
  • Start the CEP Server sample by going <CEP_HOME>/bin by specifying this command ./wso2cep-samples.sh -sn 0014
    We specify sample number as 0014 because of soap sample receiver is in that. you can view that by going <CEP_HOME>/samples/artifacts/0014/eventreceivers
The receiver is like this.

<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="soapReceiver" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
    <from eventAdapterType="soap">
        <property name="transports">all</property>
    </from>
    <mapping customMapping="disable" type="xml"/>
    <to streamName="org.wso2.event.sensor.stream" version="1.0.0"/>
</eventReceiver> 
  • After starting the CEP server, you can see the stream named as "org.wso2.event.sensor.stream" and receiver "soapReceiver" in your CEP management console.
  • As the next step, you need to produce soap events which can be receive by CEP. There is sample java soap producer available in <CEP_HOME>/samples/producers/soap. So you just want to ant build it. For that in terminal, you have to go to above mentioned directory and use below Ant command.

    ant -Durl=http://localhost:9763/services/soapReceiver/receive -Dsn=0014

    Here http://localhost:9763/services/soapReceiver/receive means http location of the receiver. Then we specify the  the sample number. The xml format input data is taken from <CEP_HOME>/samples/artifacts/0014/soapReceiver.txt
  • After this ant command you can see the output in the terminal of CEP started like below.

 Thats All, now you have successfully ran the sample. In my next blog, we will focus on creating own Soap receiver, stream and sending soap request to that. Keep in touch :)




No comments:

Post a Comment