Selerix Developer Tools
C# .NET Library Source Code
Enrollment Integrations > Enrollment Integration Details > Developer Walkthroughs > Web Services (SOAP) > Selerix .NET Library > C# .NET Library Source Code

The C# source below uses the Selerix .NET library and web services to prepare a Selerix data Transmittal and post it to BenSelect using the Selerix Upload web service.  Once the data is uploaded to BenSelect, the UniqueID found in the upload response XML is passed in a call to GetLoginGUID to obtain the unique identifier used to launch the enrollment.  Values in orange indicate data fields that differ by applicant/family.

Since enrollment rules differ from case to case, please check with your BenSelect site administrator to see if additional data is required by your specific enrollment case.

using System;

using System.IO;

using System.Net;

using System.Text;              // Encoding

using System.Xml;               // For parsing XML

using Selerix.Foundation;       // Selerix Web Services API

using Selerix.BusinessObjects;  // Selerix General Purpose Objects

using Selerix.Foundation.Data;  // Selerix Data Model

 

// The Transmittal object encapsulates all possible data used by Selerix Web Services

theTransmittalObj = new Transmittal();

 

// All properties below are required except the Version property

theTransmittalObj.SenderID = Guid.NewGuid();

theTransmittalObj.Group = new Group();

theTransmittalObj.PortfolioID = new Guid("87902A63-3EF7-43FA-ADA2-D9C9C9B4E0FE");

theTransmittalObj.Type = TransmittalType.UploadApplicants;

theTransmittalObj.Version = "1.2 2017-03-30"; // optional

 

// This example uses the same address for all family members. Address is optional.

Address theAddress = new Address()

{

    Line1 = "123 Circle Drive", // Same as "Address 1" in census template

    Line2 = "#345",

    City = "Seattle",

    State = "WA",

    Zip = "98118"

};

 

// Add the employee and family members to be offered coverages.

theTransmittalObj.Applicants = new ApplicantCollection();

theTransmittalObj.Applicants.Add(new Applicant()

{

    Relationship = Relationship.Employee,

 

    // The ID must be unique to each family being uploaded.

    ID = "987654321",    

 

    // The system needs a way to identify the employee in the transmittal.

    // This can be accomplished using either an Employee ID, a Social Security

    // Number, or First or Last Name and Date of Birth. EmployeeIdent is the

    // same as the Employee ID shown in the Employee's Employment page.

 

    // Option 1: use employee ID

    EmployeeIdent = "Employee_12345",

 

    // Option 2: use employee SSN

    SSN = "465465465",

 

    // Option 3, at least a first or last name and birthdate

    FirstName = "Douglas",

    LastName = "Fir",

    BirthDate = new DateTime(1980, 1, 15),

 

    // The Employee applicant must contain an Employment object that describes the

    // employee's job in the company.  This information is required where indicated and

    // is used by BenSelect business rules processing.  Because all string values below

    // are FREE FORM text, they must exactly match values defined in case setup. Remember

    // to check with the case builder to see if other rules dictate additional data here.

    Employment = new Employment(null)

    {

        Department = "Product Development",  // Required

        HireDate = new DateTime(2012, 1, 1), // Required

        JobClass = "Salary",                // Required

        Location = "JAX",                   // Required

 

        AsOfDate = DateTime.UtcNow,

        DeductionFrequency = 24,

        EligibilityDate = new DateTime(2012, 1, 1),

        HoursPerWeek = 40,

        PayGroup = "Bi-Weekly",

        PayrollFrequency = 26,

        Salary = 60000,                      // 'Gross Salary' in census

        Status = EmployeeStatus.Active,

        Title = "Integration Engineer"

    }

});

 

// Add the employee's spouse

theTransmittalObj.Applicants.Add(new Applicant()

{

    DependentNumber = "1",

    ID = "8675309",                   // Only useful when debugging XML

    EmployeeID = "987654321",         // Required. Ties dependent back to the employee

    EmployeeIdent = "Employee_12345", // Called Employee ID on admin site

    Relationship = Relationship.Spouse,

    FirstName = "Luxy",

    LastName = "Fir",

    SSN = "999887777",

    BirthDate = new DateTime(1985, 3, 31),

    Sex = Gender.Female,

    Address = theAddress

});

 

// Add the employee's daughter

theTransmittalObj.Applicants.Add(new Applicant()

{

    DependentNumber = "2",

    ID = "1248163264128",             // Only useful when debugging XML

    EmployeeID = "987654321",         // Required. Must match employee

    EmployeeIdent = "Employee_12345",

    Relationship = Relationship.Child,

    FirstName = "Curly",

    LastName = "Fir",

    SSN = "222334444",

    BirthDate = new DateTime(2012, 2, 29),

    Sex = Gender.Female,

    Address = theAddress

});

 

// Agents may be needed if policy requires licensed agents, or commission is involved.

// Otherwise the agent information below is optional.

Address agentAddr = new Address()

{

    Line1 = "2112 Rush Road",

    City = "Seattle",

    State = "WA",

    Zip = "98110"

};

 

// Agent licenses apply when agents are licensed by state. Add two examples.

License agentLicenseWA = new License()

{

    State = "WA",

    StateLicense = "WA590X10"

};

 

License agentLicenseTX = new License()

{

    State = "TX",

    StateLicense = "TX590X10"

};

 

LicenseCollection licenses = new LicenseCollection();

licenses.Add(agentLicenseTX);

licenses.Add(agentLicenseWA);

 

theTransmittalObj.Agents = new AgentCollection();

theTransmittalObj.Agents.Add(new Agent() {

    FirstName = "Polly",

    LastName = "Ester",

    Address = agentAddr,

    StateLicense = licenses,

    Organization = "National Insurance Sales, Inc.",

    EnrollerType = EnrollerType.FaceToFace,

    EffectiveDate = new DateTime(2017, 1, 1),

    PhoneMobile = "2066842489",

    PhoneWork = "2066845600",

    Email = "pollyanna@NationalInsuranceSales.com",

    Number = "12345",

    Split = (decimal)3.141592

});

 

// Serialize the Transmittal object to XML using Selerix helper

string outboundXML = SerializationHelper.SerializeToString(theTransmittalObj);

 

// Instantiate an Enrollment object which handles communication over SOAP

SelerixWS.Enrollment enrollment = new SelerixWS.Enrollment();

 

// Set the URL to the value provided by Selerix. This will likely differ from the example.

enrollment.Url = "https://benselect.com/qx/enrollment.asmx";

 

// Set security protocol to match by BenSelect expectation

System.Net.ServicePointManager.SecurityProtocol =

    SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls |

    SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

 

// Transmit the XML using the Upload method which handles the HTTP Post, passing

// the ID and password of the user setup on the case with the QX Enroller role

string returnedXML = enrollment.Upload("testcaseqxenroller", "thePassword", outboundXML);

 

// Here's an easy way to check for an error in the received transmittal

if (returnedXML.ToUpperInvariant().Contains("ERROR")

    throw new Exception("Upload failed: refer to XML returned for error reason");

 

// Parse the XML to get the UniqueID attribute of the Employee Applicant node

XmlDocument xdoc = new XmlDocument();

xdoc.LoadXml(returnedXML);

 

// Check for any other issues in the XML

XmlNode result = xdoc.DocumentElement.SelectSingleNode("/Transmittal/TransmittalResult");

if (result.Attributes["Status"].Value != "OK")

    throw new Exception("Upload failed: did not receive an 'OK' return status");

 

// Since we're only working with one family, the first UniqueID we find in the

// the XML returned by BenSelect identifies the employee to the system.

XmlNode applicant =

    xdoc.DocumentElement.SelectSingleNode("/Transmittal/Applicants/Applicant");

string uniqueID = applicant.Attributes["UniqueID"].Value;

 

if (_UniqueID == null || _UniqueID.Trim().Length == 0)

    throw new Exception("Error: Unable to find UniqueID in return XML");

 

// Lastly, obtain a login GUID which is used as part of the final enrollment URL

Guid loginGuid = enrollment.GetLoginGUID(

  "testcaseqxenroller", "thePassword", "87902A63-3EF7-43FA-ADA2-D9C9C9B4E0FE", uniqueID

);

 

// At minimum the enrollment URL contains the main BenSelect URL provided to you by

// Selerix followed by a question mark and the login_guid. This takes you to the

// Welcome page of the BenSelect enrollment. The remaining arguments in the code

// example are useful when embedding the BenSelect enrollment in an IFrame.

string enrollmentURL =

    "https://benselect.com/Enroll/Login.aspx?login_guid=" + loginGuid.ToString() +

    "&personalinfo=no" +     // Don't show employee personal info page

    "&welcome=no" +          // Don't show the welcome page

    "&benefitsnapshot=no" +  // Don't show the benefit snapshot page

    "&review=no" +           // Don't show the benefits review page

    "&header_footer=no" +    // Don't show the BenSelect top UI

    "&topmenu=no" +          // Don't show the main menu UI

    "&sidebar=&no";          // Don't show the BenSelect sidebar UI

 

// The test code below launches BenSelect starting with the first enrollment using the

// default browser.  In practice, the URL would be embedded in a HTML IFrame within

// your own enrollment application for seamless integration with BenSelect.

System.Diagnostics.Process.Start(enrollmentURL);

 

 

See Also