I
I
Ilya Ijyan2017-09-21 16:07:02
C++ / C#
Ilya Ijyan, 2017-09-21 16:07:02

Authorization in the web service, and a deserialization error. Where to dig?

Hi friends.
I'm using the class generated through "Add Connected Service" to access the web service.
And I'm currently struggling with two problems.
First

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));
        }

In this code, in the first version (for version 1.1), I indicated
BasicHttpBinding result = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                result.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

and it works great.
How can I set up the second option? Where to substitute ClientCredential... I did not find this possibility in the CustomBinding type.
The second problem is
Error in deserializing body of reply message for operation / And this problem is with half of the methods.
Maybe someone came across?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question