Cliente dll
Si se desea utilizar esta DLL, hay que solicitarla a un administrador de SDH.
Autenticación basada en certificados accesibles por la aplicación de terceros
SDHAuthorization auth = new ()
{
// Instancia de tipo Certificate
// para obtener el certificado del que se ha facilitado
// a los administradores de SDH el Thumbprint
//
//new Certificate(x509Certificate2)
//new Certificate(serialNumberOrHash)
//new Certificate(fromFileName, passwordFromFileName)
};
var client = new ControlDocumentsClient();
client.Set(companyId: "00000000-0000-0000-0000-000000000000",
url: "https://decatest.solmicrosdh.com",
sdhAuth: auth);
var response = client.Create(new CreateControlDocumentRequest
{
ContractualCharger = new ContractualCharger { BusinessName = "...", TaxIdentificationNumber = "...", Address = "..." },
ActualCarrier = new ActualCarrier { BusinessName = "...", TaxIdentificationNumber = "..." },
Shipments = new List<Shipment> { new Shipment { Origin = "...", Destination = "...", GoodsNature = "...", WeightKg = 1000 } },
Vehicle = new Vehicle { LicensePlate = "1234ABC" },
TransportDate = DateTime.Today
});
client.Update(response.Id, new UpdateControlDocumentRequest { /* ... */ });
client.ResendNotification(response.Id, new ResendNotificationRequest { Channel = NotificationChannel.Email, Address = "destinatario@dominio.com" });
client.Delete(response.Id);
Autenticación basada en Azure
SDHAuthorization authAzureOption1 = new ()
{
clientId = "", // Identificador del cliente en Azure
clientSecret = "" // Secreto del cliente en Azure
};
SDHAuthorization authAzureOption2 = new ()
{
clientId = "", // Identificador del cliente en Azure
certificate =
// Instancia de tipo Certificate
//
//new Certificate(x509Certificate2)
//new Certificate(serialNumberOrHash)
//new Certificate(fromFileName, passwordFromFileName)
};
var client = new ControlDocumentsClient();
client.Set(companyId: "00000000-0000-0000-0000-000000000000",
url: "https://decatest.solmicrosdh.com",
sdhAuth: authAzureOptionX);
var response = client.Create(new CreateControlDocumentRequest
{
ContractualCharger = new ContractualCharger { BusinessName = "...", TaxIdentificationNumber = "...", Address = "..." },
ActualCarrier = new ActualCarrier { BusinessName = "...", TaxIdentificationNumber = "..." },
Shipments = new List<Shipment> { new Shipment { Origin = "...", Destination = "...", GoodsNature = "...", WeightKg = 1000 } },
Vehicle = new Vehicle { LicensePlate = "1234ABC" },
TransportDate = DateTime.Today
});
client.Update(response.Id, new UpdateControlDocumentRequest { /* ... */ });
client.ResendNotification(response.Id, new ResendNotificationRequest { Channel = NotificationChannel.Email, Address = "destinatario@dominio.com" });
client.Delete(response.Id);
Clase Certificate
Mediante la clase Certificate se obtiene el certificado. Admite constructores con:
X509Certificate2: Un objeto de la clase X509Certificate2.serialNumberOrHash: Un string con el SerialNumber o el Thumbprint para localizar el certificado instalado en el almacén personal del usuario en el equipo que consume la integración. Tiene que estar instalado como exportable.fromFileNameypasswordFromFileName: Ruta a un archivo cuyo contenido es un certificado, y la contraseña de dicho certificado.