locked
Problem with Implementing Transport Message Security with WCF 4.0 and VS 2010 RRS feed

  • Question

  • Hi,

    I'm working on a tree tier project in this solution I have tree project ,

    the Service layer,the ServiceContract Layer and presentation layer

    At first I implemented it without security and it worked  properly,

    But when I tried to add Transport Message security with SSL I faced some problem here is some of my code :

    web.config in service layer:

     

    <br/>
     <br/>
    <system.serviceModel><br/>
      <bindings><br/>
       <basicHttpBinding><br/>
        <binding name="Binding1"><br/>
         <!-- UsernameToken over Transport Security --><br/>
         <security mode="TransportWithMessageCredential"><br/>
           <message clientCredentialType="UserName"/><br/>
          </security><br/>
        </binding><br/>
       </basicHttpBinding><br/>
      </bindings><br/>
      <services><br/>
       <service name="AutomationService.AutomationService" behaviorConfiguration="MyBehavior"><br/>
        <endpoint address="" binding="basicHttpBinding" contract="AutomationService.IAutomationService" bindingConfiguration="Binding1"><br/>
         <identity><br/>
          <dns value="localhost"/><br/>
         </identity><br/>
        </endpoint><br/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/><br/>
       </service><br/>
      </services><br/>
      <behaviors><br/>
       <serviceBehaviors><br/>
        <behavior name="MyBehavior"><br/>
         <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --><br/>
         <!-- 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 --><br/>
         <serviceDebug includeExceptionDetailInFaults="false" /><br/>
         <serviceCredentials><br/>
          <serviceCertificate storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="MyUsrPwdCert"/><br/>
          <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyValidator, app_code"/><br/>
         </serviceCredentials><br/>
         <serviceMetadata/><br/>
         </behavior><br/>
       </serviceBehaviors><br/>
      </behaviors><br/>
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /><br/>
     </system.serviceModel><br/>
    
    

    also I've already add certification by makecert successfully.

    but when I try to run my wcf service application I receive this error "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata."

    could you please tell me whats wrong with my code?

     

     

    Friday, November 12, 2010 9:08 PM

All replies

  • If you deploy on iis - have you configured iis to use ssl?

    also turn on wcf trace and check any inner errors.


    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    Friday, November 12, 2010 9:21 PM
  • Hamid, have you solved this issue? The error message seems to be generated by WCF test client utility. You can try to navigate to the service in browser directly, which may provide more information.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, November 16, 2010 6:56 AM