Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF security mode
Hi
 
i've created a simple WCF service hosted by a console application. i am able to view its metadata and use it, but whenever i switch to transport - it is not seen anymore - not the service and not the meta data page.
 
i've followed the article in here to generate a server side certificate:
 

[^]
 
i am starting the service with this code (the certificate has no password):
 
Uri a = new Uri("https://localhost:8813");
Uri[] baseAddresses = new Uri[] { a };
ServiceHost host = new ServiceHost(typeof(DataExchangeServer), baseAddresses);
X509Certificate2 certificate = new X509Certificate2(@"D:\test.pfx", string.Empty);
host.Credentials.ServiceCertificate.Certificate = certificate;
host.Open();
 
My app.config file (serviceModel section only):
 
<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="DataExchangeServiceBehavior">
        <serviceMetadata httpsGetEnabled="true"/>
        <!--   <serviceMetadata httpGetEnabled="True"/>-->
      <serviceDebug includeExceptionDetailInFaults="true"/>
        <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>
        <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="DataExchangeServiceBehavior" name="ThundenKore.Cloud.DataExchange.Server.DataExchangeServer">
 
      <endpoint address="/DataExchangeServices" binding="basicHttpBinding" bindingConfiguration="httpsBinding" contract="ThundenKore.Cloud.DataExchange.Server.IDataExchangeServer">
        <identity>
          <dns value="Transport"/>
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      <!--        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
 
    </service>
  </services>
  <bindings>
    <basicHttpBinding>
      <binding name="httpsBinding" transferMode="Buffered" messageEncoding="Mtom" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="524288000" maxBufferSize="524288000">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <security mode="Transport"/>
      </binding>
    </basicHttpBinding>
  </bindings>
</system.serviceModel>
 
running the service like this starts it, but i cannot access it. if i change the starting code to:
 
Uri a = new Uri("http://localhost:8813");
Uri[] baseAddresses = new Uri[] { a };
ServiceHost host = new ServiceHost(typeof(DataExchangeServer), baseAddresses);
host.Open();
 
and the app.config file to:
 
<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DataExchangeServiceBehavior">
          <!--   <serviceMetadata httpsGetEnabled="true"/>-->
        <serviceMetadata httpGetEnabled="True"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="DataExchangeServiceBehavior" name="ThundenKore.Cloud.DataExchange.Server.DataExchangeServer">
 
        <endpoint address="/DataExchangeServices" binding="basicHttpBinding" bindingConfiguration="httpsBinding" contract="ThundenKore.Cloud.DataExchange.Server.IDataExchangeServer">
          <identity>
            <dns value="Transport"/>
          </identity>
        </endpoint>
        <!--        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>-->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
 
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="httpsBinding" transferMode="Buffered" messageEncoding="Mtom" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="524288000" maxBufferSize="524288000">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
 

everythig is working fine (with disabling transport security mode).
Anyone has an idea why?
 
using trace viewer i can see that everything is fine when i run the service - i get:
 
Listen at 'https://localhost:8813/DataExchangeServices'
Listen at 'https://localhost:8813/mex'
Listen at 'https://localhost:8813/'
 
but using a browser or trying to add service reference using each of these addresses does not work.
i generated the certificate using:
 
makecert -r -pe -n "CN=Test Server" -b 01/01/2012 -e 01/01/2015 -sky exchange Test.cer -sv Test.pvk
pvk2pfx.exe -pvk Test.pvk -spc Test.cer -pfx Test.pfx
Posted 2-Jun-12 3:48am
impeham708
Edited 2-Jun-12 3:54am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 2 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid