Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi to all......

here am facing problem while adding my wcf in https mode with wshttpBinding... i make an certificate for my wcf service using this link

http://msdn.microsoft.com/en-us/library/hh556232.aspx[^]

once go through this link.... u can get clear idea.. what is going on...

i created a test certificate.. for my wcf service..

by using this certificate i wana run my wcf service in htts://localhost.... in SSL

here my
web.config file
C#
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  
 
  <system.serviceModel>
    <services>
      <service name="samplewcf.Service1" behaviorConfiguration="samplewcf.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="https://localhost/samplewcf/Service.svc" binding="wsHttpBinding"
           bindingConfiguration="TransportSecurity" contract="samplewcf.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    
    <behaviors>

      <serviceBehaviors>
       
        <behavior name="samplewcf.Service1Behavior" >
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata  httpsGetEnabled="true" httpsGetUrl="https://localhost/samplewcf/Service1.svc" />

          <!-- 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>


let me know any modifications ... or.. ppl check my code.. and if possible fix it
Posted
Updated 10-May-13 1:20am
v3

1 solution

I followed the same steps as in the MSDN link to add a Certificate.

Then I just changed binding to https like binding="mexHttpsBinding" and added Transport security binding under wshttpBinding.

That's all I did. And its running.

The problems in your config are....
XML
endpoint address="https://localhost/samplewcf/Service.svc"
httpsGetUrl="https://localhost/samplewcf/Service1.svc"


These names are varying, one is Service.svc and other is Service1.svc.
Write the correct one in both the cases.

And use Relative address here, not the absolute Url, as I suggested you before in the previous question.

So, they should look like below if the web.config and Service are in the same folder.
XML
endpoint address="Service1.svc"
httpsGetUrl="Service1.svc"


So, don't be in a hurry and do it carefully. Let me know it solved or not.


[Update]
Config file is like below, underlined items need to verified and changed according to your project.
XML
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Ntitish_WcfService.Service1" behaviorConfiguration="Ntitish_WcfService.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="service.svc" binding="wsHttpBinding" contract="Ntitish_WcfService.IService" bindingConfiguration="TransportSecurity"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Ntitish_WcfService.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpsGetEnabled="true" httpsGetUrl="Service.svc"/>
          <!-- 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>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
 
Share this answer
 
v3
Comments
ntitish 11-May-13 1:21am    
can u update total config file... plz

1st i have to execute this/././ then i wll add certificate

soo can u once upload full web.config file
No, WCF Test Client will not work, as that does not support https protocol.
So, you can only check from browser that it is running only with https:// protocol.

I am updating answer to include the whole config file. You need to make some naming changes as they may be different in your case.
ntitish 11-May-13 1:46am    
ok hav u check with any test certificate... generated from iis-7
Yes, I said in the first line that I followed the MSDN link and added a certificate.

It is working perfectly at my end, I can only access that WCF Service with https protocol.

Isn't it working at your end ?
Are you still facing problems ?
ntitish 11-May-13 1:53am    
Tadit... thx a lot... i complected reaming work

actually i assume.. after this successful execution only we can host in iis but its not for this

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900