Describes how to send an event through the Whatsnexx.TicketBus from a Console application in Visual Studio.
The whatsnexx ticketbus handles REST and SOAP Web Service request to send events. In this example, we will demonstrate how to send and event to the Whatsnexx ticketbus using a WCF client. If you are not familiar with WCF, the MSDN documentation can be found here. You will need following to send a request to the ticketbus service.
Attribute | Type | Description |
---|---|---|
Account Id | GUID | Provided by Whatsnexx. |
Username: | GUID | Provided by Whatsnexx. |
Password: | GUID | Provided by Whatsnexx. |
TermName: | string | This is the name of the event that is to be triggered by the send event. |
SubjectCode: | string | The unique identifier for your [subject](). This usually represents who you would like to send the event to. |
SubjectTypeId: | GUID | A unique identitfier for the subject type. The subject type defines the context under which events are sent. |
ExecutionEnvironment: | TicketBusService.ExecutionEnvironments | Specifies the Whatsnexx environment you are sending the event request. A Constellation must exist in the chosen environment for the event to be triggered. The available Environments are: Test, Stage, and Production. |
Attributes: | TicketBusService.Attributes[] | A list of attributes that are used by the event. |
- Open Visual Studio and create a new Console Application.
- In the File menu point to New and click Protect. A New Project dialog box will appear.
- In the New Project dialog box, select Visual C# from the Installed Templates box, and select Console Application from the list provided
- Enter the 'CSharpExample' in the Name box and enter the location you would like to save the project in the Location box.
- Click OK
- Add a Service Reference for the Whatsnexx TicketBusService
- In the Solution Explorer right click on References in the project CSharpExample and left click on Add Service Reference. The Add Service Reference dialog box will open.
- Enter 'https://ticketbus.whatsnexx.com/TicketBusService.svc' in the Address box and click Go. TicketBusService will appear shortly.
- Enter 'TicketBusService' in the Namespace box and click OK. The Service Model reference will be added to the the project References and the Service References will appear with TicketBusService added as a service.
- To view the service API, double click on TicketBusService under Service References. The Object Browser will appear.
- Expand CSharpExample.TicketBusService and select objects in the explorer to view the methods available.
- Modify Program.cs as follows and run the application. A console window will appear showing the service was called successfully.
using System;
using Attribute = CSharpExample.TicketBusService.Attribute;
using CSharpExample.TicketBusService;
namespace CSharpExample
{
public class SendEvent
{
public static void Main(string[] args)
{
//AccountId: GUID Provided by Whatsnexx.
//Username: GUID Provided by Whatsnexx.
//Password: GUID Provided by Whatsnexx.
//TermName: String This is the name of the event that is to be triggered by the send event.
//SubjectCode: (Hash value)The unique identifier for your subject(). This usually represents who you would like to send the event to.
//SubjectTypeId: GUID A unique identitfier for the subject type. The subject type defines the context under which events are sent.
//ExecutionEnvironment: TicketbusService.ExecutionEnvironment Specifies the Whatsnexx environment you are sending the event request. A <code>Constellation</code> must exist in the chosen environment for the event to be triggered. The available Environments are: Test, Stage, and Production.
//Attributes: TicketBusService.AttributeList A list of attributes that are used by the event.
const string userName = "{Your Username}";
const string password = "{Your Password}";
const string accountId = "{Your Account Id}";
const string subjectTypeId = "{Your Subject Id}";
const string termName = "{Your TermName}";
//create out objects
TicketBusResponse response;
string transactionId;
var ticketBusSendEvent = new TicketBusSendEvent
{
Attributes = new[] {
new Attribute {Name = "Test", Value = "Value1"},
new Attribute {Name = "Email", Value = "[email protected]"}},
SubjectCode = "TestCode"
};
var client = new TicketBusServiceClient
{
ClientCredentials =
{
UserName =
{
UserName = userName,
Password = password
}
}
};
var success = client.SendEvent( accountId, ExecutionEnvironments.Stage,
subjectTypeId, termName, ticketBusSendEvent, out response, out transactionId);
Console.WriteLine("Worked: " + success + Environment.NewLine + "TransactionId: " + transactionId);
Console.ReadKey();
}
}
}
Whatsnexx Full Documentation
MSDN: Windows Communication Foundation (WCF)