Contents
In this sample, the TIBCO StreamBase® Web Reader input adapter retrieves the contents of a web page by sending an HTTP GET or HTTP POST request to a specified URL. The calls made by the adapter demonstrate how to get data from REST, JSONP, and SOAP web endpoints.
Thus, this sample retrieves an XML file served as a web page on a particular URL, then uses the XML to Tuple operator to parse
the XML and convert it to tuple format. In the context of a larger application, this sample's ParsedWebPage
output stream would be ready to be processed further by downstream components.
In this sample, the TIBCO StreamBase® Web Reader input adapter retrieves the contents of a web page by sending an HTTP GET request to the specified URL in the adapter HTTP URL property.
-
In the Package Explorer, double-click to open the
webreader.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.
-
For the example, in the Manual Input view, click
to send the defaultnull
tuple. -
In the Application Output view, observe tuples emitted on the
RawWebPage
andParsedWebPage
output streams. -
Select the tuple emitted from the
ParsedWebPage
stream, then use the triangles next to the data fields displayed to analyze and understand their structure. -
Press F9 or click the Stop Running Application button.
-
Back on the EventFlow Editor canvas, double-click the
WebReader
component to edit its properties. Clear the Enable Control Port control, and set the Poll Frequency control to 10,000. Now save the module and run it again. -
The application now retrieves the contents of the specified URL every 10 seconds.
-
When done, press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® Web Reader input adapter sends a JSONP request to the server using the URLParams and
HTTPHeaders input variables. See the defaults
map operator on the canvas of this sample to show how to set up the different types of fields required for this operation.
The TupleToJSON operator is used to convert the input data into a JSON string to send to the server.
-
In the Package Explorer, double-click to open the
webreaderJSONP.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.
-
For the example, in the Manual Input view, event some values into the fields and click
to send the tuple. -
In the Application Output view, observe tuples emitted on the
RawResponse
andParsedResponse
output streams. -
Press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® Web Reader input adapter sends a JSON request to the server via a POST request using
the PostData and HTTPHeaders input variables. See the PostDefaults
map operator on the canvas of this sample to show how to set up the different types of fields required for this operation.
The TupleToJSON operator is used to convert the input data into a JSON string to send to the server.
-
In the Package Explorer, double-click to open the
webreaderPostJSON.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.
-
For the example, in the Manual Input view, event some values into the fields and click
to send the tuple. -
In the Application Output view, observe tuples emitted on the
RawResponse
andParsedResponse
output streams. -
Press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® Web Reader input adapter sends a XML request to the server via a POST request using
the URLParams input variable. See the PostDefaults
map operator on the canvas of this sample to show how to set up the different types of fields required for this operation.
The XMLToTuple operator is used to convert the output string data into a Tuple.
-
In the Package Explorer, double-click to open the
webreaderPostXML.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.
-
For the example, in the Manual Input view, event some values into the fields and click
to send the tuple. -
In the Application Output view, observe tuples emitted on the
RawResponse
andParsedResponse
output streams. -
Press F9 or click the Stop Running Application button.
In this sample, the TIBCO StreamBase® Web Reader input adapter sends a SOAP request to the server via a POST request using
the PostData and HTTPHeaders input variable. See the SOAPDefaults
map operator on the canvas of this sample to show how to set up the different types of fields required for this operation.
The XMLToTuple operator is used to convert the output string data into a Tuple.
-
In the Package Explorer, double-click to open the
webreaderSOAP.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.
-
For the example, in the Manual Input view, event some values into the fields and click
to send the tuple. -
In the Application Output view, observe tuples emitted on the
RawResponse
andParsedResponse
output streams. -
Press F9 or click the Stop Running Application button.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select
→ . -
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_webreader
See Default Installation Directories for the default location of studio-workspace
on your system.