Hi,
I have two services, configured via a config file. Each of them listens to one http and one https address. The problem is how to configure the ports. If I configure the http ports to the same value and the https ports to another value, when debugging the whole project I get the following error message in WCF Service Host:
Status: Error System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:8002/Services/xxxService/ because TCP port 8002 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
If I configure the four ports (http and https) to have different values and none of the https values is the value of the ssl port configured and certified in IIS, I get the following exception on service call (but both services are started in the WCF Service Host):
An error occurred while making the HTTP request to https://localhost:8000/Services/yyyService/. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
If I configure the first service to use the SSL port (443), then only the second service is started (the one with the "wrong" https port). The error message for the first service again is:
System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:443/Services/xxxService/ because TCP port 443 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
On top of that, I get an exception, when calling the second service:
An error occurred while making the HTTP request to https://localhost/Services/yyyService/. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
When I configure both services to use 443 for https, well... then nothing gets started. And I get all kinds of strange exceptions - clientcredentials is readonly, the handshake encountered an unexpected packet format, something about remote address and so on.
I have configured both addresses in the web.config as follows:
<baseAddresses>
<add baseAddress="http://localhost:port1/Services/xxxService/" />
<add baseAddress="https://localhost:port2/Services/xxxService/" />
</baseAddresses>
[...]
<baseAddresses>
<add baseAddress="http://localhost:port3/Services/yyyService/" />
<add baseAddress="https://localhost:port4/Services/yyyService/" />
</baseAddresses>
I have been trying to run this thing for two days now, so any helf would be appreciated.
PS. In Visual Studio I have configured IIS as a development server, instead of the in-build visual studio web development server.
EDIT:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="namespace.xxxService"
behaviorConfiguration="default">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Services/xxxService/" />
<add baseAddress="https://localhost:8001/Services/xxxService/" />
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="defaultWsHttpBinding"
contract="namespace.IxxxService" />
<endpoint address="mex/"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingConfiguration="" />
</service>
<service name="namespace.yyyService" behaviorConfiguration="default">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8003/Services/yyyService/" />
<add baseAddress="https://localhost:8004/Services/yyyService/" />
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="defaultWsHttpBinding"
contract="namespace.IyyyService" />
<endpoint address="mex/"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<client>
<endpoint address="https://localhost:8001/Services/xxxService/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IxxxService"
contract="namespace.IxxxService" name="WSHttpBinding_IxxxService" />
<endpoint address="https://localhost:8001/Services/yyyService/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IyyyService"
contract="namespace.IyyyService" name="WSHttpBinding_IyyyService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="SqlMembershipProvider" />
</serviceCredentials>
<serviceAuthorization principalPermissionMode="UseAspNetRoles"
roleProviderName="SqlRoleProvider" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="defaultWsHttpBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="WSHttpBinding_IyyyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
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="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpBinding_IxxxService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
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="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>