Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP and HTTPS Bindings
    primarykey
    data
    text
    <p>I have a application that consumes a WCF web service. </p> <p>I have it cofigured to use a https binding. It works fine. I also wanted to add a HTTP binding to the same.</p> <p>My requirement is if my client is on my domain (or on VPN) i need them to use the HTTP binding. and if they are external clients I want them to use HTTPS binding. How can I go about doing that? I am very new to WCF and this is my first try on it. </p> <p>I have attached my Config File for reference. I did not know where to add the end point for the HTTP binding. Any help would be appriciated.</p> <pre><code>&lt;system.serviceModel&gt; &lt;services&gt; &lt;service name="{service name}" behaviorConfiguration="httpsBehavior"&gt; &lt;!--HTTPS END POINT--&gt; &lt;endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecureHTTPBinding" contract="{service contract}" /&gt; &lt;!--METADATA ENDPOINT--&gt; &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="httpsBehavior"&gt; &lt;serviceMetadata httpsGetEnabled="true" httpsGetUrl="" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;behavior name="httpBehavior"&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;!--HTTPS BINDING--&gt; &lt;binding name="SecureHTTPBinding"&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;!--HTTP BINDING--&gt; &lt;binding name="BasicHttpBinding"&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; </code></pre> <p></p> <p><strong>EDIT</strong> : Adding netTCP Binding</p> <pre><code>&lt;system.serviceModel&gt; &lt;services&gt; &lt;service name="{Service Name}" behaviorConfiguration="httpsBehavior"&gt; &lt;!--HTTPS END POINT--&gt; &lt;endpoint address="https://localhost/Service1.svc" binding="basicHttpBinding" bindingConfiguration="SecureHTTPBinding" contract="{Service Contract}" name="httpsEndPoint"/&gt; &lt;!--METADATA ENDPOINT--&gt; &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt; &lt;!--HTTP END POINT--&gt; &lt;endpoint address="http://localhost/Service1.svc" binding="basicHttpBinding" bindingConfiguration="HttpBinding" contract="{Service Contract}" name="httpsEndPoint"/&gt; &lt;!--TCP METATADATA END POINT--&gt; &lt;endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="net.tcp://localhost:808/Service1.svc" /&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;!--TCP ENDPOIN--&gt; &lt;endpoint address="net.tcp://localhost:808/Service1.svc" binding="netTcpBinding" contract="{Service Contract}" name="netTCPEndPoint" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="httpsBehavior"&gt; &lt;serviceMetadata httpsGetEnabled="true" httpsGetUrl="" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;!--HTTPS BINDING--&gt; &lt;binding name="SecureHTTPBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"&gt; &lt;readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;!--HTTP BINDING--&gt; &lt;binding name="HttpBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"&gt; &lt;readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;!--TCP BINDING--&gt; &lt;netTcpBinding&gt; &lt;binding transferMode="Buffered" /&gt; &lt;/netTcpBinding&gt; &lt;/bindings&gt; </code></pre> <p></p> <p>I am aware of the the possible Dos attacks wrt to the numbers in the code and I would work around it. For now just wanted to get it working. When I use this config file I run into error that says</p> <p><strong>Could not find a base address that matches the scheme net.tcp for the endpoint MetadataExchageTcpBinding. Registered base addresses are [http,https]</strong></p> <p>Can some one help me expose a net.tcp binding for my service. Any help would be appriciated</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload