简体   繁体   中英

Web Services in Siddhi

I have a web services (REST). I want to call the WS every time an event comes to my stream.

I have to create an extension of Siddhi and call the web service from java?

If I need java to invoke the Web service, should I extend "Aggregate Function" ?.

In Siddhi exists any instruction that I can use to call the web service?

The next is a sample of my WS:

http://72.37.125.125:3000/phishing?url=www.innerjoin.co

thanks for your comments

You will be able to use HTTP event publisher[1] to achieve this OOTB without writing custom code. Using this publisher you can send PUT/POST requests to pre-defined URL with custom payload. Create a HTTP publisher as mentioned in the shared documentation. Then you can use a custom json mapping to create the accepted payload for your web service. When you are creating custom mapping you can refer event attributes inside curly braces as follows.

{
   "payload_name_for_webservice":{{attribute_name_in_event}},
}

[1] https://docs.wso2.com/display/CEP400/HTTP+Event+Publisher

Thank you.

but i have a receiver and other publisher.

i want call my WS from siddhi when arrive a new event to "org.wso2.event.sensor.stream:1.0.0", the input parameter to the web service is "meta_sensorName"

how i can make it?

My code is this:

/* Enter a unique ExecutionPlan */
@Plan:name('ExecutionPlan')

/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')

/* define streams/tables and write queries here ... */

@Import('org.wso2.event.sensor.stream:1.0.0')
define stream sensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, humidity float, sensorValue double);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM