Using HTTP to Send and Receive Dynamic Headers

A request is sent to the server by the client. The server accepts the request and the HTTP connection is then closed by the response activity. Dynamic headers are added on both the client request and server's response.

The server process listens for requests and sends a response from the server.



The client process sends a request to the server.



Procedure

  1. In the samples directory, select palette > http > DynamicHeaders and double-click tibco.bw.sample.palette.http.DynamicHeaders. For more information, see Accessing Samples.
  2. In Project Explorer expand the tibco.bw.sample.palette.http.DynamicHeaders project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. Fully expand the Processes directory and double-click DynamicHeadersClientProcess.bwp.
  5. Click Run > Debug Configurations.
  6. At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  7. Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.palette.http.DynamicHeaders.application.
  8. Click Debug.
    This runs the sample in Debug mode.
  9. Click the Terminate icon to stop the process.

Result

A DynamicHeaders.log file is created at c:\tmp\DynamicHeaders with the following output:

Headers Received at the Server Side are:

content-type:text/plain

content-type1found_ContentType1_firstTime

content-type1found_ContentType1_SecondTime

arraydata2

arraydata1

arraydata3

Headers Received at the Client Side are:

HTTP/1.1 200 OK

Content-Type: text/plain

Content-Length: 12

server: Jetty(8.1.16.v20140903)

testing-mydata: Done Setting data

testing-mydata: Done Setting Dynamic Value

company: TIBCO India Pvt Ltd

company: TIBCO Inc, USA

Understanding the Configuration

The ListeningHTTPConnection and the RequestingHTTPConnection is defined to listen on port 13009. To change the port, specify a new Port value in the Module Properties dialog. You can also change the default location of the OUTPUT_FILE file, by specifying it in the Module Properties dialog.

The Incoming HTTP Request process starter listens on the connection specified by the ListeningHTTPConnection shared resource.

In the DynamicHeadersClientProcess, the ArrayData element in the Input Editor of the Send HTTP Request activity has Cardinality defined as Repeating. The dynamic header value for the same is provided from the Input tab under the DynamicHeaders element. The dynamic headers Content-Type1 and Content-Type are defined under the same.

In DynamicHeadersServerProcess, the Testing-MyData element in the Input Editor of the Send HTTP Response activity has Cardinality defined as Repeating. The dynamic header value for the same is provided from the Input tab under the DynamicHeaders element. The dynamic headers StatusLine and Company are defined under the same.

The Send HTTP Request activity sends the request to the server. The HTTP Receiver activity accepts the request. The Send HTTP Response activity closes the HTTP connection that has been established by the Incoming HTTP Request process starter.