Kloder
@Kloder
Ищу опыт

Авторизация в веб сервисе, и ошибка десериализации. Куда копать?

Привет, друзья.
Я использую сгенерированный через "Добавление подключенной службы" класс для доступа к веб сервису.
И борюсь в данный момент с двумя проблемами.

Первая
private static Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
        {
            if ((endpointConfiguration == EndpointConfiguration.ПФ_ПорталДПОSoap))
            {
                BasicHttpBinding result = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                result.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                result.MaxBufferSize = int.MaxValue;
                result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
                result.MaxReceivedMessageSize = int.MaxValue;
                result.AllowCookies = true;
                return result;
            }
            if ((endpointConfiguration == EndpointConfiguration.ПФ_ПорталДПОSoap12))
            {
                CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
                System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
                textBindingElement.MessageVersion = System.ServiceModel.Channels.MessageVersion.CreateVersion(EnvelopeVersion.Soap12, System.ServiceModel.Channels.AddressingVersion.None);
                result.Elements.Add(textBindingElement);
                System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
                httpBindingElement.AllowCookies = true;
                httpBindingElement.MaxBufferSize = int.MaxValue;
                httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
                result.Elements.Add(httpBindingElement);
                return result;
            }
            throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
        }


В этом коде в первом варианте ( для версии 1.1 ) я указал
BasicHttpBinding result = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                result.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

и это отлично работает.

Как мне настроить второй вариант? Куда подставлять подставлять ClientCredential... В типе CustomBinding я не нашел этой возможности.

Вторая проблема
Error in deserializing body of reply message for operation / И эта проблема c половиной методов.

Может кто-то сталкивался?
  • Вопрос задан
  • 247 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы