Search code examples
siddhisendasynchronousrequestwso2-streaming-integrator

Not able to execute the Synchronous Request Response example in Siddhi


I'm trying to run the sample code given in the WSO2 Siddhi documentation.

I've replicated what was given there.

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

In the Event Simulator tab, I passed the values given in the example namely: 154467847759 in the timestamp field and 5555555555554444 in the creditCardNo(STRING).

This is the error that's coming.

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

Solution

  • As per the error printed, the request sent to https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType returns a 500 response. As you don't have an http-response source to accept 500 responses, the response payload will be dropped.

    The behavior you are observing is not reproducable from our end. The tutorial works correctly as demonstrated.

    Below is an amended version of the tutorial sample with a dummy endpoint. You can try it.

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