Contents
In this sample, the TIBCO StreamBase® HTTP Client input adapter handles HTTP requests to a specified URL. The calls made by the adapter demonstrate how to get data from HTTP endpoints.
The samples with this adapter show how to perform various HTTP request calls include Server-Sent Events and Chunked Response type of calls.
REST, SOAP, WEB, SSE (Server-Sent Events), CHUNKED, GET, POST, PUT
In this sample, the TIBCO StreamBase® HTTP Client input adapter retrieves the contents of a web page by sending an HTTP GET request to the specified URL via the input tuple. The input tuple can override almost any property of the adapter. This sample will input a few different tuples to demonstrate this at runtime.
-
In the Project Explorer, double-click to open the
HTTPClient.sbapp
, and make sure the application is the currently active tab in the EventFlow Editor. -
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
-
In the Manual Input view select
BasicControl
from the Stream drop down. -
Enter
https://www.google.com
into the url field. -
Click
to send the command to the adapter.
-
-
In the Application Output view, observe tuples emitted on the
Status
andOutput
output streams. -
Select the tuple emitted from the
Output
stream, then use the triangles next to the data fields displayed to analyze and understand their structure. Notice the data field holds the contents of the web page. -
-
In the Manual Input view select
FullControl
from the Stream drop down. -
Enter
https://www.google.com
into the url field. Enter 'file download' into the 'settings\requestType' field. -
Click
to send the command to the adapter.
-
-
In the Application Output view, observe tuples emitted on the
Status
andOutput
output streams. -
Select the tuple emitted from the
Output
stream, then use the triangles next to the data fields displayed to analyze and understand their structure. Notice the binary field holds the contents of the web page. -
-
In the Manual Input view select
FullControl
from the Stream drop down. -
Enter
https://www.google.com
into the url field. -
Enter 'file download' into the 'settings\requestType' field.
-
Enter an absolute file name and path into the 'settings\downloadPath' field, for instance 'c:/tmp/google.html'.
-
Click
to send the command to the adapter.
-
-
In the Application Output view, observe tuples emitted on the
Status
andOutput
output streams. -
Select the tuple emitted from the
Output
stream, then use the triangles next to the data fields displayed to analyze and understand their structure. Notice the data field holds the filename of the file the web page was stored into. -
Press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® HTTP Client input adapter connects to the WikiMedia recent changes feed via Server-Sent Events which streams all recent changes and converts that data into a usable StreamBase structure via JSONToTuple operator.
When this sample starts it automatically sends a connection command into the HTTP Client adapter to connect to the WikiMedia
recent changes. Select the DefaultWikiEvents
map operator to see the definition of the command sent.
-
In the Project Explorer, double-click to open the
HTTPServerSentEvents.sbapp
, and make sure the application is the currently active tab in the EventFlow Editor. -
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Application Output view, observe tuples emitted on the
SSEData
andSSEStatus
output streams. -
To disconnect, in the Manual Input view select
SSECommand
from the Stream drop down, enterdisconnect
into thecommand
field and click to send the command to the adapter. -
Press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® HTTP Client input adapter connects to the https://dweet.io/ server and subscribes to changes to a IOT item. The sample then sends a new sensor reading value to the tibco-streambase-demo-thing item on the dweet system which in turn is sent back to our adapter which has subscribed to that item.
When this sample starts it automatically sends a connection command into the HTTP Client adapter to connect to the https://dweet.io/
server and subscribe to item tibco-streambase-demo-thing and sends a value. Select the Default
map operator to see the definition of the command sent.
This sample also checks for the status of the adapters status port for disconnects and reconnects automatically.
-
In the Project Explorer, double-click to open the
HTTPChunkedResponse.sbapp
, and make sure the application is the currently active tab in the EventFlow Editor. -
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Application Output view, observe tuples emitted on the output streams.
-
To disconnect, in the Manual Input view select
ChunkedCommand
from the Stream drop down, enterdisconnect
into thecommand
field and click to send the command to the adapter. -
Press F9 or click the Stop Running Application button.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select
> . -
Enter
webre
to narrow the list of options. -
Select
r from the category. -
Click
.
StreamBase Studio creates a single project containing the sample files.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
studio-workspace
/sample_adapter_embedded_httpclient
See Default Installation Directories for the default location of studio-workspace
on your system.