VS 2022 Добавить ссылку на службу, не генерирующую ClientCredentials для .Net FrameworkC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 VS 2022 Добавить ссылку на службу, не генерирующую ClientCredentials для .Net Framework

Сообщение Anonymous »

Мне нужно добавить ссылку на службу, чтобы создать клиентский прокси для службы .Net Framework и службы .Net 8. Справочник по добавлению службы .Net 8 правильно генерирует клиентский прокси-сервер и выполняется без проблем. В отдельном проекте или службе на основе Framework созданный прокси-сервер не включает ClientCredentials.
Для следующей политики из wsdl: Он генерирует правильную информацию о привязке/клиенте: Сгенерированный прокси-сервер клиента не создает ClientCredentials, поэтому я не могу добавить пользователя/пароль.
Сгенерированный фрагмент клиента для файла . Ссылка на Net Framework:

Код: Выделить всё

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class Query_2012_04Client : System.ServiceModel.ClientBase, WCFTest.PTSQueryService.IQuery_2012_04 {

public Query_2012_04Client() {
}

public Query_2012_04Client(string endpointConfigurationName) :
base(endpointConfigurationName) {
}

public Query_2012_04Client(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public Query_2012_04Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public Query_2012_04Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}

public WCFTest.PTSQueryService.QueryParameter[] GetQueryParameters(int qtype, string qname) {
return base.Channel.GetQueryParameters(qtype, qname);
}

public System.Threading.Tasks.Task GetQueryParametersAsync(int qtype, string qname) {
return base.Channel.GetQueryParametersAsync(qtype, qname);
}

public string GetQueryData(int qtype, string qname, WCFTest.PTSQueryService.QueryArgument[] args, int page, int pageSize) {
return base.Channel.GetQueryData(qtype, qname, args, page, pageSize);
}

public System.Threading.Tasks.Task GetQueryDataAsync(int qtype, string qname, WCFTest.PTSQueryService.QueryArgument[] args, int page, int pageSize) {
return base.Channel.GetQueryDataAsync(qtype, qname, args, page, pageSize);
}
}
Для справки, вот что сгенерировал проект .Net 8:

Код: Выделить всё

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
public partial class Query_2012_04Client : System.ServiceModel.ClientBase
, PTSQueryService.IQuery_2012_04
{

/// 
/// Implement this partial method to configure the service endpoint.
/// 
/// The endpoint to configure
/// The client credentials
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);

public Query_2012_04Client() :
base(Query_2012_04Client.GetDefaultBinding(), Query_2012_04Client.GetDefaultEndpointAddress())
{
this.Endpoint.Name = EndpointConfiguration.WSHttpBinding_IQuery_2012_04.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}

public Query_2012_04Client(EndpointConfiguration endpointConfiguration) :
base(Query_2012_04Client.GetBindingForEndpoint(endpointConfiguration), Query_2012_04Client.GetEndpointAddress(endpointConfiguration))
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}

public Query_2012_04Client(EndpointConfiguration endpointConfiguration, string remoteAddress) :
base(Query_2012_04Client.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}

public Query_2012_04Client(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
base(Query_2012_04Client.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}

public Query_2012_04Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}

public System.Threading.Tasks.Task  GetQueryParametersAsync(int qtype, string qname)
{
return base.Channel.GetQueryParametersAsync(qtype, qname);
}

public System.Threading.Tasks.Task GetQueryDataAsync(int qtype, string qname, PTSQueryService.QueryArgument[] args, int page, int pageSize)
{
return base.Channel.GetQueryDataAsync(qtype, qname, args, page, pageSize);
}

public virtual System.Threading.Tasks.Task OpenAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
}

private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.WSHttpBinding_IQuery_2012_04))
{
System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
result.Security.Mode = System.ServiceModel.SecurityMode.TransportWithMessageCredential;
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
result.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.UserName;
result.Security.Message.EstablishSecurityContext = false;
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}

private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.WSHttpBinding_IQuery_2012_04))
{
return new System.ServiceModel.EndpointAddress("https://somehost/ptsqamt/Maintain/Services/Data/2012/04/Query.s" +
"vc");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}

private static System.ServiceModel.Channels.Binding GetDefaultBinding()
{
return Query_2012_04Client.GetBindingForEndpoint(EndpointConfiguration.WSHttpBinding_IQuery_2012_04);
}

private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
{
return Query_2012_04Client.GetEndpointAddress(EndpointConfiguration.WSHttpBinding_IQuery_2012_04);
}

public enum EndpointConfiguration
{

WSHttpBinding_IQuery_2012_04,
}
}
Спасибо за любую помощь.


Подробнее здесь: https://stackoverflow.com/questions/786 ... t-framewor
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • VS 2022 Добавить ссылку на службу, не генерирующую ClientCredentials для .Net Framework
    Anonymous » » в форуме C#
    0 Ответы
    23 Просмотры
    Последнее сообщение Anonymous
  • Как преобразовать программу C++, генерирующую палиндромы, в ассемблер для SPOJ?
    Anonymous » » в форуме C++
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous
  • Связь с WCF с ClientCredentials
    Anonymous » » в форуме C#
    0 Ответы
    7 Просмотры
    Последнее сообщение Anonymous
  • Могу ли я добавить ссылку на DLL .NET Framework из проекта .NET 6?
    Anonymous » » в форуме C#
    0 Ответы
    19 Просмотры
    Последнее сообщение Anonymous
  • Добавить ссылку на службу, запрос нескольких учетных данных
    Anonymous » » в форуме C#
    0 Ответы
    11 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C#»