iam using TEDA aApplication in my context i call rest url to call java adapter to post data i have this error , any support to solve this issue : javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.ibm.jsse2.a.c(a.java:67) at com.ibm.jsse2.a.a(a.java:275) at com.ibm.jsse2.as.a(as.java:3) at com.ibm.jsse2.as.i(as.java:822) at com.ibm.jsse2.as.a(as.java:392) at com.ibm.jsse2.as.startHandshake(as.java:507) at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:184) at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:21) at com.ibm.net.ssl.www2.protocol.https.b.connect(b.java:100) at rechargeplatformgrouping.context.custom.RTMWrapper.process(RTMWrapper.java:169) at com.ibm.streams.operator.internal.runtime.api.OperatorAdapter.processTuple(OperatorAdapter.java:1465) at com.ibm.streams.operator.internal.runtime.api.OperatorAdapter$1.tuple(OperatorAdapter.java:803) at com.ibm.streams.operator.internal.runtime.api.OperatorAdapter$1.tuple(OperatorAdapter.java:796) at com.ibm.streams.operator.internal.network.DeserializingStream.tuple(DeserializingStream.java:76) at com.ibm.streams.operator.internal.network.DeserializingStream.processRawTuple(DeserializingStream.java:65) at com.ibm.streams.operator.internal.runtime.api.InputPortsConduit.processRawTuple(InputPortsConduit.java:100) at com.ibm.streams.operator.internal.jni.JNIBridge.process(JNIBridge.java:316) Exception: Unrecognized SSL message, plaintext connection?
Answer by BryanMiller (309) | Nov 09, 2018 at 07:41 PM
Can you post your code or a snippet? What libraries are you using to support REST inside Streams? It is almost impossible to tell without seeing some code.
I typically use:
use com.ibm.streamsx.inet.http::HTTPPost ;
use com.ibm.streamsx.inet.http::HTTPResponse ;
use this classes in my java adapter ? and how import this toolkit com.ibm.streamsx.inet in my teda project ? please check my question in the url : https://developer.ibm.com/answers/questions/478970/view.html
how to add toolkits to ITE application is described here: https://www.ibm.com/support/knowledgecenter/en/SSCRJU_4.2.1/com.ibm.streams.toolkits.doc/spldoc/dita/tk$com.ibm.streams.teda/tk$com.ibm.streams.teda$131.html
@BryanMiller where i should use this use com.ibm.streamsx.inet.http::HTTPPost ; use com.ibm.streamsx.inet.http::HTTPResponse ; in my context ?
Answer by BryanMiller (309) | Nov 17, 2018 at 09:28 PM
I am using HTTPResponse() to post to Cloundant on Bluemix like this:
(stream<HTTPResponse> Post) as PostToCloudantDB = HTTPPost(EvictTS_6_out0 as
inPort0Alias)
{
param
url :
"https://url-secret-bluemix.cloudant.com/greatoutdoors" ;
authenticationType : "basic" ;
headerContentType : "application/json" ;
authenticationProperty :
"userid=my-secret-bluemix",
"password=anothersecret" ;
config
tracing : info ;
}
I'll see if I have a pure REST example as well.
@BryanMiller Ok thanks a lot, i am waiting your Rest example , can i use the above code in my context in teda application ?
Is your teda application running in Streams? If so, yes, you can use the above code.
This page has an example of using REST to call a web service and retrieve a JSON payload:
https://developer.ibm.com/streamsdev/docs/example-using-rest-apis-chart-streaming-data/
@BryanMiller if i use the above code the receiver server will receive json request by using this headerContentType : "application/json" ; ? if no how send json data in HTTPPost operator
Yes, it will send JSON data.
If you want to experiment you can download a free VM of Streams Studio and upload your SPL files to Streams on Bluemix to test them out. It is a good method of quickly testing out ideas.
@BryanMiller after my run my application the below error appeared how solve this ??
{data="java.lang.ClassCastException: java.lang.String cannot be cast to org.json.simple.JSONAware",errorMessage="",responseCode=500,dataSize=333}
Answer by BryanMiller (309) | Nov 19, 2018 at 04:34 PM
@khloud You will need to convert your data payload to JSON before calling POST.
Since you have not shared any details of what you are attempting I can only make guesses. You can either convert your data manually to JSON or you can use some of the existing libraries to convert to JSON. Here is one set of libraries I have used for Java and Python tuple data:
com.ibm.streamsx.json::JSONToTuple ;
com.ibm.streamsx.json::TupleToJSON ;
@BryanMiller iam usin version 4.0.1 this version cannot support this toolkit com.ibm.streamsx.json i am using the below code and i have the above error also how solve this issue
rstring jsonString={\"extKeys\":{\"customerKey":\"111111\"}};
(stream Post) as PostTrtim = HTTPPost(jsonString as SMSStreamPort) { param url : "httpUrl"; authenticationType : "basic" ; headerContentType : "application/json" ; authenticationProperty : "userid=test", "password=2018" ;