Connection Configuration For National Weather Service

For the sample National Weather Service Connector project, review the Connection configuration code generated by the Integration Framework Wizard. Below we modify the connection configuration code to control what happens when the Connector is connected to the API. Two changes are required: 

  • Generate a call to indicate whether the connection succeeded.
  • Set the information used for all of the subsequent calls using this Connector.
 protected override Func<WeatherConnectionInfo, IConnectionConfiguration> ConnectionConfiguration()
 {
     return this.Connection.Configure("GET", connInfo => connInfo.BaseUrl + "/UrllHere")
          .ConnectionInfoToBaseUrl(info => info.BaseUrl) // Set the BaseUrl for subsequent calls
 .End(); // Finish the configuration
 }

The code sample above has been altered from the original output to fit the sample project. The signature of this method is necessary, but the details exceed the scope of this document.

We are using some fluent API classes to generate the necessary configurations to drive the connection.

The return this.Connection.Configure section of the code above starts the verification process.

("GET", connInfo => connInfo.BaseUrl + "/UrllHere") is declaring the call made during connection, sometimes referred to as the login function. In this case we are saying that we want an HTTP Request with HTTP method GET, and then we are using lambda syntax to create a function that takes the connection and returns the URL for this call. One of the reasons for the signature above is that it provides typing information for this connection so that Intellisense in Visual Studio works.

The .ConnectionInfoToBaseUrl(info => info.BaseUrl) section configures the BaseUrl with the value entered by the user on the Connection dialog.

.End(); packages everything up and turns it into the type that the Integration Framework needs.

The code sample above calls the URL BaseUrl + “UrlHere”, and uses that BaseUrl in subsequent calls. In many cases you must set up HTTP Headers or Query Parameters that have access or common information. In this case, HTTP Headers or Query Parameters are not required, but we need to correct the relative URL to validate the connection.

There are two options for the relative URL.

  • Include specific query parameters in the relative URL as shown below:

    /xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?zipCodeList=03104&format=24+hourly&numDays=7

  • Use a simpler URL and then hard code the three Query Parameters as shown below: 

    /xml/sample_products/browser_interface/ndfdBrowserClientByDay.php

     protected override Func<WeatherConnectionInfo, IConnectionConfiguration> ConnectionConfiguration()
     {
        return this.Connection.Configure("GET", connInfo => connInfo.BaseUrl + 
        "/ndfdBrowserClientByDay.php")
             .ConnectionInfoToBaseUrl(info => info.BaseUrl) // Set the BaseUrl for subsequent calls
             .ToQuery("zipCodeList", "03104")
             .ToQuery("Format", "24+hour")
             .ToQuery("numDays", "7")
     .End(); // Finish the configuration
     }

The sample code above is the finished connection configuration.

To validate the BaseUrl that was entered, we call GET.

{BaseUrl}/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?zipCodeList=03104&format=24+hourly&numDays=7

We use the {BaseUrl} entered by the user in the Connection dialog in subsequent calls.

See Also

Building A TIBCO Scribe® Connector For National Weather Service

Analyzing The National Weather Service Connection

Starting The National Weather Service Project

Generating The National Weather Service Connector Code

Reviewing Sample National Weather Service Connector Generated Code

Connection Information For National Weather Service

Query Configuration For National Weather Service