protected EndpointDescriptionCollection TranslateEndpointDescriptions(
Uri clientUrl,
IList<BaseAddress> baseAddresses,
IList<EndpointDescription> endpoints,
ApplicationDescription application)
{
EndpointDescriptionCollection translations = new EndpointDescriptionCollection();
// process endpoints
foreach (EndpointDescription endpoint in endpoints)
{
UriBuilder endpointUrl = new UriBuilder(endpoint.EndpointUrl);
// find matching base address.
foreach (BaseAddress baseAddress in baseAddresses)
{
bool translateHttpsEndpoint = false;
if ((endpoint.TransportProfileUri == Profiles.HttpsBinaryTransport && baseAddress.ProfileUri == Profiles.HttpsXmlOrBinaryTransport)
|| endpoint.TransportProfileUri == Profiles.HttpsBinaryTransport && baseAddress.ProfileUri == Profiles.HttpsBinaryTransport)
{
translateHttpsEndpoint = true;
}
if ((endpoint.TransportProfileUri == Profiles.HttpsXmlTransport && baseAddress.ProfileUri == Profiles.HttpsXmlOrBinaryTransport)
|| endpoint.TransportProfileUri == Profiles.HttpsXmlTransport && baseAddress.ProfileUri == Profiles.HttpsXmlTransport)
{
translateHttpsEndpoint = true;
}
if (endpoint.TransportProfileUri != baseAddress.ProfileUri && !translateHttpsEndpoint)
{
continue;
}
if (endpointUrl.Scheme != baseAddress.Url.Scheme)
{
continue;
}
EndpointDescription translation = new EndpointDescription();
translation.EndpointUrl = baseAddress.Url.ToString();
if (endpointUrl.Path.StartsWith(baseAddress.Url.PathAndQuery) && endpointUrl.Path.Length > baseAddress.Url.PathAndQuery.Length)
{
string suffix = endpointUrl.Path.Substring(baseAddress.Url.PathAndQuery.Length);
translation.EndpointUrl += suffix;
}
translation.ProxyUrl = endpoint.ProxyUrl;
translation.SecurityLevel = endpoint.SecurityLevel;
translation.SecurityMode = endpoint.SecurityMode;
translation.SecurityPolicyUri = endpoint.SecurityPolicyUri;
translation.ServerCertificate = endpoint.ServerCertificate;
translation.TransportProfileUri = endpoint.TransportProfileUri;
translation.UserIdentityTokens = endpoint.UserIdentityTokens;
translation.Server = application;
translations.Add(translation);
}
}
return translations;
}