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 StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select → .
-
Enter
webrto narrow the list of options. -
Select webreader from the StreamBase Standard Adapters category.
-
Click .
StreamBase Studio creates a single project containing the sample files.
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 Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select → from the context menu.
-
Open the
src/main/eventflow/folder.packageName -
Open the
webreader.sbappfile and click the
Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, click to send the default
nulltuple. -
In the Output Streams view, observe tuples emitted on the
RawWebPageandParsedWebPageoutput streams. -
Select the tuple emitted from the
ParsedWebPagestream, then use the triangles next to the data fields displayed to analyze and understand their structure. -
Press F9 or click the
Terminate EventFlow Fragment button.
-
Back on the EventFlow Editor canvas, double-click the
WebReadercomponent 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
Terminate EventFlow Fragment 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.
-
Continuing in this sample project, open the
webreaderJSONP.sbappfile. -
Click the
Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, enter some values into the fields and click to send the tuple.
-
In the Output Streams view, observe tuples emitted on the
RawResponseandParsedResponseoutput streams. -
Press F9 or click the
Terminate EventFlow Fragment 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.
-
Continuing in this sample project, open the
webreaderPostJSON.sbappfile. -
Click the
Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, enter some values into the fields and click to send the tuple.
-
In the Output Streams view, observe tuples emitted on the
RawResponseandParsedResponseoutput streams. -
Press F9 or click the
Terminate EventFlow Fragment 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.
-
Continuing in this sample project, open the
webreaderPostXML.sbappfile. -
Click the
Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, enter some values into the fields and click to send the tuple.
-
In the Output Streams view, observe tuples emitted on the
RawResponseandParsedResponseoutput streams. -
Press F9 or click the
Terminate EventFlow Fragment button.
In this sample, the Web Reader input adapter sends a SOAP request to the server via a POST request using the PostData and
HTTPHeaders input variables. 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.
-
Continuing in this sample project, open the
webreaderSOAP.sbappfile. -
Click the
Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, enter some values into the fields and click to send the tuple.
-
In the Output Streams view, observe tuples emitted on the
RawResponseandParsedResponseoutput streams. -
Press F9 or click the
Terminate EventFlow Fragment button.
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_webreaderSee Default Installation Directories for the default location of studio-workspace on your system.
