private static async Task <DynamicDiscoveryResult> DynamicDiscoverSendingPModeAsync( SendingProcessingMode sendingPMode, IDynamicDiscoveryProfile profile, AS4Party toParty) { try { var clonedPMode = (SendingProcessingMode)sendingPMode.Clone(); clonedPMode.Id = $"{clonedPMode.Id}_SMP"; XmlDocument smpMetaData = await RetrieveSmpMetaDataAsync(profile, clonedPMode.DynamicDiscovery, toParty); if (smpMetaData == null) { Logger.Error($"No SMP meta-data document was retrieved by the Dynamic Discovery profile: {profile.GetType().Name}"); throw new InvalidDataException( "No SMP meta-data document was retrieved during the Dynamic Discovery process"); } DynamicDiscoveryResult result = profile.DecoratePModeWithSmpMetaData(clonedPMode, smpMetaData); if (result == null) { Logger.Error($@"No decorated SendingPMode was returned by the Dynamic Discovery profile: {profile.GetType().Name}"); throw new InvalidDataException( "No decorated SendingPMode was returned during the Dynamic Discovery"); } ValidatePMode(result.CompletedSendingPMode); return(result); } catch (Exception ex) { Logger.Error( $"An exception occured during the Dynamic Discovery process of the profile: {profile.GetType().Name} " + $"with the message having ToParty={toParty} for SendingPMode {sendingPMode.Id}"); throw new DynamicDiscoveryException( "An exception occured during the Dynamic Discovery process", ex); } }
/// <summary> /// Complete the <paramref name="pmode"/> with the SMP metadata that is present in the <paramref name="smpMetaData"/> <see cref="XmlDocument"/> /// </summary> /// <param name="pmode">The <see cref="SendingProcessingMode"/> that must be decorated with the SMP metadata</param> /// <param name="smpMetaData">An XmlDocument that contains the SMP MetaData that has been received from an SMP server.</param> /// <returns>The completed <see cref="SendingProcessingMode"/></returns> public DynamicDiscoveryResult DecoratePModeWithSmpMetaData(SendingProcessingMode pmode, XmlDocument smpMetaData) { return(PeppolDynamicDiscoveryProfile.DecoratePModeWithSmpMetaData(pmode, smpMetaData)); }