简体   繁体   English

Siddhi中的Web服务

[英]Web Services in Siddhi

I have a web services (REST). 我有一个Web服务(REST)。 I want to call the WS every time an event comes to my stream. 我想在事件流中每次调用WS。

I have to create an extension of Siddhi and call the web service from java? 我必须创建Siddhi的扩展并从Java调用Web服务吗?

If I need java to invoke the Web service, should I extend "Aggregate Function" ?. 如果需要Java来调用Web服务,是否应该扩展“聚合函数”?

In Siddhi exists any instruction that I can use to call the web service? 在Siddhi中,我可以使用任何指令来调用Web服务吗?

The next is a sample of my WS: 接下来是我的WS的样本:

http://72.37.125.125:3000/phishing?url=www.innerjoin.co 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. 您将可以使用HTTP事件发布器[1]实现此OOTB,而无需编写自定义代码。 Using this publisher you can send PUT/POST requests to pre-defined URL with custom payload. 使用此发布者,您可以将PUT / POST请求发送到带有自定义有效负载的预定义URL。 Create a HTTP publisher as mentioned in the shared documentation. 如共享文档中所述,创建一个HTTP发布器。 Then you can use a custom json mapping to create the accepted payload for your web service. 然后,您可以使用自定义json映射为Web服务创建可接受的有效负载。 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 [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" 我想在到达新事件“ org.wso2.event.sensor.stream:1.0.0”时从siddhi调用我的WS,Web服务的输入参数是“ 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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