How-to consume Global DCC
- Contact Armand Michaud in order to get some credentials
- In your project, install Nuget Package GlobalDcc.Api.Client, newest version
- Use GlobalDcc.Api.Client (see below)
Using GlobalDcc.Api.Client
It is necessary to initialize GlobalDcc.Api.Client. This is done by calling
GlobalDcc.Api.Client.Client.Initialize
with the base url for GlobalDcc (for
development this is https://gdcc-dev.amcsplatform.com/), a username and
password. Once Client
has been initialized request can be sent to GlobalDcc
through a GlobalDcc.Api.Client.Version0Client
.
If GlobalDcc.Api.Client is used in a Microsoft Extensions Dependency Injection
setup, Version0Client
can use a System.Net.Http.IHttpClientFactory
.
Version0Client
can also be constructed without an IHttpClientFactory
in
which case GlobalDcc.Api.Client will take care of creating and persisting an
HttpClient
and recreating it if a DNS change is suspected.
Example
// Initialize Global DCC client
GlobalDcc.Api.Client.Client.Initialize("https://gdcc-dev.amcsplatform.com/",
"MyUsername", "MyPassword");
// Create a Version0Client GlobalDcc.Api.Client.Version0Client client = new
GlobalDcc.Api.Client.Version0Client();
// Prepare a trace request GlobalDcc.Api.Client.TraceRequest traceRequest = new
GlobalDcc.Api.Client.TraceRequest() { Source = new
GlobalDcc.Api.Client.Coordinate() { Latitude = 55.704105M, Longitude =
12.552734M }, Destination = new GlobalDcc.Api.Client.Coordinate() { Latitude =
55.701723M, Longitude = 12.584791M } };
// Call the trace method of Global DCC GlobalDcc.Api.Client.TraceReply
traceReply = client.Trace("DK", traceRequest);
Console.WriteLine($"This trace has {traceReply.Answer.Trace.Count}
coordinates.");
In case of problem
Contact Armand Michaud
Versions
Currently (2023-09-14) the client is build as .NET 6.0 and .NET 7.0. This might change as new version of .NET are introduced.