WCF windows security

Posted by Learner under WCF on 1/8/2010 | Views : 7804 | Status : [Member] | Replies : 4
Hi ,
I am getting the following error

System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

Please c below config file.

<system.serviceModel>
<services>
<service name="StockServiceWCF.StockService" behaviorConfiguration="StockServiceWCF.Service1Behavior">

<host>
<baseAddresses>
<add baseAddress="http//localhost/StockService"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="StockServiceWCF.IStockService"></endpoint>
<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration ="BasicHttpEndpointBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="StockServiceWCF.Service1Behavior">
<!-- 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 -->

</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>




Responses

Posted by: Abhi2434 on: 1/11/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Hey, This is a common issue. Just remove mex from your bindings.

Do like this :
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"></endpoint>


You can also check the anonymous access to the website from IIS admin console. Also make sure that you denied the anonymous access in web.config of your application.

I hope this will help you.

www.abhisheksur.com

Learner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mehulthakkar1 on: 1/11/2010 [Member] Starter

Up
0
Down
Check this link
http://ahmed0192.spaces.live.com/blog/cns!FD6F44C91F5D2AD9!160.entry

Hope this will help you.

Thanks
Mehul Thakkar

Learner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learner on: 1/11/2010 [Member] Starter

Up
0
Down
Thanks. I tried removing this but when I tried to add reference at client end it was throwing error saying "No metadata available". How do i solve this so that client can successfully add service refernce?

I am new to WCF so need help :)

Thanks in Advance.

Learner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 1/12/2010 [Member] Bronze

Up
0
Down
Can you check the endpoint address as basic as follows.

The following configuration works for me:

<system.serviceModel>

<services>
<service name="WcfTestService.Service1" behaviorConfiguration="WcfTestService.Service1Behavior">
<endpoint address="ws" binding="wsHttpBinding" contract="WcfTestService.IService1" bindingConfiguration="wsBindingConfig"/>
<endpoint address="basic" binding="basicHttpBinding" contract="WcfTestService.IService1" bindingConfiguration="bindingConfig"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="bindingConfig">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsBindingConfig">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfTestService.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>


Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Learner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response