簡體   English   中英

無法在Siddhi中執行同步請求響應示例

[英]Not able to execute the Synchronous Request Response example in Siddhi

我正在嘗試運行WSO2 Siddhi文檔中給出的示例代碼。

我已經復制了那里給出的內容。

@App:name("Http_Request_Response_Tutorial")
@App:description("This app demonstrate the usage of http request sink and http response source")

@source(type='http-response' ,sink.id='cardTypeSink',
@map(type='xml', namespaces = "xmlns=http://localhost/SmartPayments/",
@attributes(creditCardNo = 'trp:creditCardNo',creditCardType = ".")))
@sink(type='log')
define stream EnrichedCreditCardStream (creditCardNo string,creditCardType string);

@sink(type='http-request',publisher.url='https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType',method='POST', headers="'Content-Type:application/x-www-form-urlencoded'",
sink.id="cardTypeSink",
@map(type='keyvalue', @payload(CardNumber='{{creditCardNo}}')))
define stream CreditCardStream (creditCardNo string);

在“事件模擬器”選項卡中,我傳遞了示例中給出的值:在timestamp字段中為154467847759,在creditCardNo(STRING)中為5555555555554444。

這是即將到來的錯誤。

[2019-05-22_14-59-14_632] ERROR {org.wso2.extension.siddhi.io.http.source.HttpResponseMessageListener} - No source of type 'http-response' for status code '500' has been defined. Hence dropping the response message. (Encoded) 

根據打印的錯誤,發送到https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType的請求將返回500響應。 由於您沒有http響應源來接受500個響應,因此響應有效負載將被丟棄。

從我們的角度來看,您觀察到的行為不可復制。 該教程可以正常運行,如演示所示。

以下是帶有虛擬端點的教程示例的修訂版。 你可以試試。

@App:name("Http_Request_Response_Tutorial")
@App:description("This app demonstrate the usage of http request sink and http response source")

@source(type='http-response' ,sink.id='cardTypeSink',
@map(type='xml', namespaces = "xmlns=http://localhost/SmartPayments/",
@attributes(creditCardNo = 'trp:creditCardNo',creditCardType = ".")))
@sink(type='log')
define stream EnrichedCreditCardStream (creditCardNo string,creditCardType string);

@sink(type='http-request',publisher.url='http://www.mocky.io/v2/5cee2fa1300000013a6e9961',method='POST', headers="'Content-Type:application/x-www-form-urlencoded'",
sink.id="cardTypeSink",
@map(type='keyvalue', @payload(CardNumber='{{creditCardNo}}')))
define stream CreditCardStream (creditCardNo string);

根據錯誤,我認為您沒有連接到CreditCardStream的流定義中的Publisher.url。

在模擬事件之前,請確保CreditCardStream已連接到https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType

如果連接成功,您將獲得如下日志。

[2019-05-23 12:19:36,713]  INFO {org.wso2.extension.siddhi.io.http.sink.HttpSink} - Http_Request_Response_Tutorial:@sink( type = "http-request", publisher.url = "https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType", method = "POST", headers = "'Content-Type:application/x-www-form-urlencoded'", sink.id = "cardTypeSink", @map( type = "keyvalue", @payload( CardNumber = "{{creditCardNo}}")))define stream CreditCardStream (creditCardNo string) has successfully connected to https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType
[2019-05-23 12:19:55,597]  INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - Http_Request_Response_Tutorial : EnrichedCreditCardStream : [Event{timestamp=1558594195597, data=[5555555544444, ], isExpired=false}]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM