Can't Access Net TCP service From WCF Test Client - wcf

I'm trying to run two WCF services from within IIS one is a web service and one is a Net TCP Binding Service.
Here is a simulcrum of my Web.config (I've anonymized the service name):
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService">
<endpoint address="ServerService"
binding="netTcpBinding"
bindingConfiguration=""
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
<add baseAddress="htt://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration=""
name="AACCWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/IMyWebService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
When I run this in the IDE it opens a page running on port 51953 and I can get the WSDL for the webservice by browsing to http://localhost:51953/WebService.svc?wsdl (Note the port is different).
I can't seem to get the WSDL by changing to port to what I've specified in the webconfig file (8523).
When I point the WcfTestClient app at "net.tcp://localhost:8523/ServerService and it gives me an error saying that it can't access the meta data, which as far as I can see I've configured (the second end point in the service).
What am I doing wrong here?
UPDATE:
I've tried changing the port number on the project properties to 8523 as suggested that didn't seem to work, I've also tried changint the address of the mex endpoint to "ServerService\mex" the test client spent some time churning but then it threw the following error:
Error: Cannot obtain Metadata from
net.tcp://localhost:8523/ServerService If this is a Windows (R)
Communication Foundation service to which you have access, please
check that you have enabled metadata publishing at the specified
address. For help enabling metadata publishing, please refer to the
MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
Error URI: net.tcp://localhost:8523/ServerService Metadata
contains a reference that cannot be resolved:
'net.tcp://localhost:8523/ServerService'. You have tried to create
a channel to a service that does not support .Net Framing. It is
possible that you are encountering an HTTP endpoint. Expected
record type 'PreambleAck', found '72'.
I'm going to keep digging but I'd appreciate any help.
UPDATE 2:
I've changed the mex endpoint to a mexTcpBinding:
Here is the service tag:
<endpoint address="ServerServiceWS"
binding="wsHttpBinding"
bindingConfiguration=""
name="WSEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
<add baseAddress="http://localhost:8523/"/>
</baseAddresses>
</host>
</service>
Still no luck. Just to be sure I am entering the correct url into the tester the Url I am using is:
net.tcp://localhost:8523/ServerService
I've also Tried:
net.tcp://localhost:8523/mex
and
net.tcp://localhost:8523/
All of which give me some variation of the following error:
Error: Cannot obtain Metadata from
net.tcp://localhost:8523/ServerService If this is a Windows (R)
Communication Foundation service to which you have access, please
check that you have enabled metadata publishing at the specified
address. For help enabling metadata publishing, please refer to the
MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
Error URI: net.tcp://localhost:8523/ServerService Metadata
contains a reference that cannot be resolved:
'net.tcp://localhost:8523/ServerService'. You have tried to create
a channel to a service that does not support .Net Framing. It is
possible that you are encountering an HTTP endpoint. Expected
record type 'PreambleAck', found '72'.
UPDATE 3
FWIW I think there might be a bigger problem with my WEb.config Here is what it currently looks like:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="DefaultBindingConfig"
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexBinding"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration=""
name="MyWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexHttpBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/MyWebService"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DefaultBindingConfig"
maxConnections="5"
portSharingEnabled="true" >
</binding>
<binding name="mexBinding"
portSharingEnabled="true">
<security mode="None"></security>
</binding>
</netTcpBinding>
<mexTcpBinding>
<binding name="mexTcpBinding"/>
</mexTcpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServerServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I can browse to the Webservice and that allows me to get the WSDL using ?wsdl but if I put the Adddress http://localhost:8523/MyWebService into the WCF tester it throws an error too.
Error: Cannot obtain Metadata from http://localhost:8523/MyWebService
If this is a Windows (R) Communication Foundation service to which you
have access, please check that you have enabled metadata publishing at
the specified address. For help enabling metadata publishing, please
refer to the MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
Error URI: http://localhost:8523/MyWebService Metadata contains
a reference that cannot be resolved:
'http://localhost:8523/MyWebService'. An error occurred while
receiving the HTTP response to http://localhost:8523/MyWebService.
This could be due to the service endpoint binding not using the HTTP
protocol. This could also be due to an HTTP request context being
aborted by the server (possibly due to the service shutting down). See
server logs for more details. The underlying connection was closed:
An unexpected error occurred on a receive. Unable to read data from
the transport connection: An existing connection was forcibly closed
by the remote host. An existing connection was forcibly closed by
the remote hostHTTP GET Error URI:
http://localhost:8523/MyWebService There was an error downloading
'http://localhost:8523/MyWebService'. The request failed with HTTP
status 404: Not Found.
I think the issue is either something to do with paths or I'm just putting the wrong URL into the test application. Either that or I've still not configured the meta data correctly.

For the HTTP endpoint, you need to reconfigure the Project Properties so that it starts your web.config defined endpoint at port 8523 if hosted using IIS Express. Use specific port (8523) instead of auto-assigned port (51953).
For the TCP metadata, you need to support a TCP-enabled mex endpoint (mexTcpBinding).
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />

The net.tcp and HTTP bindings must be set on different ports on IIS.
It can be tested with the same port or different. It will crash in the first case. Also, you can use whatever port numbers you want. In this case, the TCP port can be changed to 8524. It's just that you cannot use two separate protocols on the same port. On the other hand, the base addresses make sense only for self-hosted services. Here the base address is determined by the URL from IIS.

just try to keep this as it is, and changing your service inside and paste it inside your config file, it should work perfectly.
to test the net.tcp you can use SvcUtil.exe
<system.serviceModel>
<services>
<service name="MyWCFServices.HelloWorldService">
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="MyWCFServices.IHelloWorldService"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8086/HelloWorldService.svc" />
<add baseAddress="http://localhost:8081/HelloWorldService.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="ultra"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
portSharingEnabled="false"
transactionFlow="false"
listenBacklog="2147483647" >
<security mode="None">
<message clientCredentialType="None"/>
<transport protectionLevel="None" clientCredentialType="None"/>
</security>
<reliableSession enabled="false"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

Related

Could not find default endpoint element that references contract in the ServiceModel client configuration section

I am trying to develop a WCF service and host it in IIS. But when I try to consume service, I get this error.
Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
I have tested the WCF service using the WCF Test Client and I was able to invoke it successfully.
But the same doesn't work when I consume it. Kindly help me to sort out this.
web.config I have used in WCF:
<!--WCF web config-->
<system.serviceModel>
<services>
<service name="ProductServiceLibrary.RuelaService">
<endpoint address="" binding="wsHttpBinding" contract="RuelaService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
When I consume the WCF service, I make use of this app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<!--URL where I have hosted my WCF http://localhost:9999/Service1.svc-->
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />
</client>
</system.serviceModel>
[1]: http://i.stack.imgur.com/djQoN.png
The service appears to be exposing a contract that differs to the client configuration.
Service:
<endpoint address="" binding="wsHttpBinding"
contract="RuelaService.IService1">
Client:
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />
So there is a mismatch somewhere.

WCF basicHttpsBinding warning: "is invalid according to its datatype"

I created a WCF application, starting with basicHttpBinding. In app.config, I have the following endpoint configured:
<endpoint address="" binding="basicHttpBinding" contract="JMMEcommerceService.IJMMEcommerceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
This builds fine. However, I want to change the protocol from HTTP to HTTPS. If I change the endpoint declaration to:
<endpoint address="" binding="basicHttpsBinding" contract="JMMEcommerceService.IJMMEcommerceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
(note: the only change is basicHttpBinding -> basicHttpsBinding)
I get the following warning a build time:
WCF configuration validation warning: The 'binding' attribute is invalid - The value 'basicHttpsBinding' is invalid according to its datatype 'serviceBindingType'.
Why would I get this warning? Is there something else that I need to change?
Here is the full app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="JMMEcommerceService.JMMEcommerceService">
<endpoint address="" binding="basicHttpsBinding" contract="JMMEcommerceService.IJMMEcommerceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:8733/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The basicHttpsBinding does not appear to exist in .NET 4.0, only in 4.5. Which version of .NET are you targeting?
If you like to enable HTTPS for your service, but not for your Metadata, you have to provide another base address for your HTTP-based Metadata Exchange endpoint.
<baseAddresses>
<add baseAddress="https://localhost:8733/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
<add baseAddress="http://localhost:8734/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
</baseAddresses>
Please note, that you have to assign another port too (8734). Two protocols can not use the same port!
PS: Do not forget to assign the correct certificate to the port 8733

What is wrong with my WCF Meta Data Configuration?

This is a follow on from this question I've configured the a WCF service running in IIS (From within Visual Studio 2010) to run one Web service and one net.tcp service. After a lot of hacking I've managed to get the Web Service to load into the WCF test client, but I can't get the Net.Tcp service to load into the test client.
Here is my Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService" behaviorConfiguration="ServerServiceBehaviour">
<endpoint address="ServerService.svc"
binding="netTcpBinding"
bindingConfiguration="DefaultNetTcpBindingConfig"
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexTcpBinding"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService" behaviorConfiguration="WebServiceBehaviour">
<endpoint address="MyWebService.svc"
binding="wsHttpBinding"
bindingConfiguration="DefaultWSBinding"
name="MyWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexHttpBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DefaultNetTcpBindingConfig"
maxConnections="5"
portSharingEnabled="true" >
</binding>
<!--<binding name="mexBinding"
portSharingEnabled="true">
<security mode="None"></security>
</binding>-->
</netTcpBinding>
<wsHttpBinding>
<binding name="DefaultWSBinding"/>
</wsHttpBinding>
<mexTcpBinding>
<binding name="mexTcpBinding"/>
</mexTcpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServerServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
</behavior>
<behavior name="WebServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
When I run the Visual Studio Debugger to publish the Service I can access the web service by entering the following url into the WCF Test Application:
http://localhost:8523/MyWebService.svc
But if I enter the following Url into the WCF Test Application I get an error:
net.tcp://localhost:8523/ServerService.svc
Here is the Error I see:
Error: Cannot obtain Metadata from
net.tcp://localhost:8523/ServerService.svc If this is a Windows (R)
Communication Foundation service to which you have access, please
check that you have enabled metadata publishing at the specified
address. For help enabling metadata publishing, please refer to the
MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
Error URI: net.tcp://localhost:8523/ServerService.svc Metadata
contains a reference that cannot be resolved:
'net.tcp://localhost:8523/ServerService.svc'. You have tried to
create a channel to a service that does not support .Net Framing. It
is possible that you are encountering an HTTP endpoint. Expected
record type 'PreambleAck', found '72'.
Having read this question is it possible that the webserver in VS 2010 doesn't support net.tcp binding?
It looks like the issue I was seeing was that the Web Server in Visual Studio 2010 doesn't support Net.Tcp Binding.
I've got slightly further by installing IIS7 (IIS6 doesn't support Net.Tcp either) and telling visual studio to use IIS instead.
You can do this by going to the properties page of your service and selecting the "Web Tab" select the Use Local IIS Web Server radio Button and configure the webserver.
You can also tell is to start an external program on this tab to make it start the WcfTestClient.exe and pass in the URL to your services as command line parameters.
I'm still having issues but they are different issues so I'll open another question.

WCF issues with wsDualHttpBinding and netTcpBinding behind firewalls

I have a standalone WCF service running on a server behind a firewall. It currently uses wsDualHttpBinding as the service utilizes callbacks. The client works fine in a LAN environment. We have opened the firewall to allow traffic on a custom port and so the discovery of the service now works from outside LAN.
Due to the nature of wsDualHttpBinding this obviously cannot work if the client is behind a firewall of its own. So naturally, netTcpBinding comes to mind which should solve the bidirectional problem. But the strange thing is that when service configuration XML is updated to include netTcpBinding on the same port (and/or exclude wsDualHttpBinding), then even the service discovery no longer works.
I am wondering if there is anything else that I am missing. I have followed the exact advice for configuration from How to: Use netTcpBinding with Windows Authentication and Message Security in WCF Calling from Windows Forms and from Windows Communication Foundation QuickStart - Multiple Binding VS2010.
The configuration:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingEndpointConfig">
<security mode="Message" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Service1.Service1.Service">
<endpoint address="Service1" binding="wsDualHttpBinding" contract="Service1.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="" binding="netTcpBinding"
bindingConfiguration="NetTcpBindingEndpointConfig"
name="NetTcpBindingEndpoint" contract="Service1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:9999/Service1.Service1/"/>
<add baseAddress="net.tcp://localhost:9999/Service1.Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
If you can use only single port and you must use netTcpBinding try to configure your service this way:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingEndpointConfig">
<security mode="Message" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Service1.Service1.Service">
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<endpoint address="" binding="netTcpBinding"
bindingConfiguration="NetTcpBindingEndpointConfig"
name="NetTcpBindingEndpoint" contract="Service1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9999/Service1.Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
When adding service reference try to use this address:
net.tcp://localhost:9999/Service1.Service1/mex

Changing WCF service to require SSL

I have a WCF service which was running fine on a http binding. I've tried to update this to use SSL but i am getting the following error:
"Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https]."
This only occurs when i set the site to "Require SSL" in IIS 7.5 if I uncheck it it works fine.
Here's my config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost/WcfService1/"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
name="wsHttpEndpoint" contract="WcfService1.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
I've tried allsorts and nothing seems to get me there, any help is greatly appreciated!
Modify your binding configuration:
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>
And reference that configuration in your endpoint by setting its bindingConfiguration attribute to the name of configuration.
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="wsHttpEndpointBinding"
name="wsHttpEndpoint" contract="WcfService1.IService1" />
You can also delete the host section with base address because it is not used when hosting in IIS.
In addition to changing the binding configuration settings (as Ladislav mentioned)... Change HTTP in the base address to HTTPS.