Не удалось выполнить пример ответа на синхронный запрос в сиддхи - PullRequest
0 голосов
/ 22 мая 2019

Я пытаюсь запустить пример кода , указанный в документации WSO2 Сиддхи.

Я повторил то, что там было дано.

@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);

На вкладке «Имитатор событий» я передал значения, указанные в примере, а именно: 154467847759 в поле отметки времени и 5555555555554444 в поле creditCardNo (STRING).

Это ошибка, которая грядет.

[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) 

Ответы [ 2 ]

0 голосов
/ 29 мая 2019

В соответствии с напечатанной ошибкой, запрос, отправленный на https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType, возвращает ответ 500.Поскольку у вас нет источника http-response для принятия 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);
0 голосов
/ 23 мая 2019

В соответствии с ошибкой, я думаю, что вы не подключены к publisher.url в определении потока CreditCardStream.

Убедитесь, что 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}]
...