I am new to web services and I need to implement basicHTTPBinding to an existing wpf c# desktop application that consumes a web service with WSHttpBinding. The web service has been already configured to both bindings as following on the web.config file on the web service:
<bindings>
<wsHttpBinding>
<binding name="HI_SSLBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="True" establishSecurityContext="True" />
</security>
</binding>
</wsHttpBinding>
<basicHttpBinding>
<binding name="HI_BasicBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
</security>
<readerQuotas maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="HIWebService.HIService" behaviorConfiguration="SecureBehave">
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="HI_BasicBinding" contract="HILib.HIService.IHIService"></endpoint>
<endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="HI_SSLBinding" contract="HILib.HIService.IHIService"></endpoint>
<host>
<baseAddresses>
<add baseAddress="https://10.50.1.85:1345/HI/HIService.svc" />
</baseAddresses>
</host>
</service>
</services>
The wpf c# desktop application has the App.configer to consume just the wsHttpBinding on the web service as following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="HI_SSLBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="True" establishSecurityContext="True"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior>
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://10.50.1.85:1345/HI/HIService.svc" binding="wsHttpBinding" bindingConfiguration="HI_SSLBinding" contract="HILib.HIService.IHIService">
</endpoint>
</client>
</system.serviceModel>
</configuration>
Now when the application consumes the wsHttpBinding it does the following:
System.ServiceModel.WSHttpBinding wsHTTPSBinding = new System.ServiceModel.WSHttpBinding();
wsHTTPSBinding.Name = "HIBridge_SSLBinding";
wsHTTPSBinding.OpenTimeout = TimeSpan.FromMinutes(1);
wsHTTPSBinding.CloseTimeout = TimeSpan.FromMinutes(1);
wsHTTPSBinding.SendTimeout = TimeSpan.FromMinutes(1);
wsHTTPSBinding.ReceiveTimeout = TimeSpan.FromMinutes(10);
wsHTTPSBinding.BypassProxyOnLocal = false;
wsHTTPSBinding.TransactionFlow = false;
wsHTTPSBinding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
wsHTTPSBinding.MaxBufferPoolSize = 2147483647;
wsHTTPSBinding.MaxReceivedMessageSize = 2147483647;
wsHTTPSBinding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text;
wsHTTPSBinding.TextEncoding = Encoding.UTF8;
wsHTTPSBinding.UseDefaultWebProxy = true;
wsHTTPSBinding.AllowCookies = false;
wsHTTPSBinding.ReliableSession.Ordered = true;
wsHTTPSBinding.ReliableSession.InactivityTimeout = TimeSpan.FromMinutes(10);
wsHTTPSBinding.ReliableSession.Enabled = false;
wsHTTPSBinding.Security.Mode = System.ServiceModel.SecurityMode.TransportWithMessageCredential;
wsHTTPSBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Certificate;
wsHTTPSBinding.Security.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None;
wsHTTPSBinding.Security.Transport.Realm = "";
wsHTTPSBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.UserName;
wsHTTPSBinding.Security.Message.NegotiateServiceCredential = true;
wsHTTPSBinding.Security.Message.EstablishSecurityContext = true;
System.ServiceModel.EndpointAddress endpointAddress = null;
endpointAddress = new System.ServiceModel.EndpointAddress(string.Format("https://10.50.1.85:1345/HI/HIService.svc/ws");
How do I configure the App.configer for the BasicHttpBinding and how do I call this binding on the c# wpf application as well?