private static Uri CreateSmpServerUrl(Model.Core.Party party, ESensConfig config) { string hashedPartyId = CalculateMD5Hash(party.PrimaryPartyId); string host = $"b-{hashedPartyId}.{config.SmlScheme}.{config.SmpServerDomainName}"; string path = $"{config.SmlScheme}::{party.PrimaryPartyId}/services/{DocumentIdentifierScheme}::{DocumentIdentifier}"; var builder = new UriBuilder { Host = host, // DotNetBug: Colons need to be Percentage encoded in final Url for SMP lookup. // Uri/HttpClient.GetAsync components encodes # but not : so we need to do it manually. Path = HttpUtility.UrlEncode(path) }; return(builder.Uri); }
/// <summary> /// Retrieves the SMP meta data <see cref="XmlDocument"/> for a given <paramref name="party"/> using a given <paramref name="properties"/>. /// </summary> /// <param name="party">The party identifier to select the right SMP meta-data.</param> /// <param name="properties">The information properties specified in the <see cref="SendingProcessingMode"/> for this profile.</param> public async Task <XmlDocument> RetrieveSmpMetaDataAsync( Model.Core.Party party, IDictionary <string, string> properties) { if (party == null) { throw new ArgumentNullException(nameof(party)); } if (properties == null) { throw new ArgumentNullException(nameof(properties)); } if (party.PrimaryPartyId == null) { throw new InvalidOperationException("Given invalid 'ToParty'; requires a 'PartyId'"); } Uri smpUrl = CreateSmpServerUrl(party, ESensConfig.From(properties)); return(await RetrieveSmpMetaData(smpUrl)); }