Configuration binding extension 'system.serviceModel/bindings/clearUsernameBinding' could not be found - wcf-security

hi i am tring to use this article for making my wcf service authenticate without SSL
http://webservices20.blogspot.in/2008/11/introducing-wcf-clearusernamebinding.html
but i am geting this error when i try to compile :
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="clearUsernameBinding" type="ClearUsernameCollectionElement, ClearUsernameBinding" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyValidator,App_Code"/>
</serviceCredentials>
<!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment-->
<serviceMetadata httpsGetEnabled="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-->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="SampleServiceBehaviour">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyUserNameValidator, App_Code" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service" behaviorConfiguration="SampleServiceBehaviour">
<endpoint address="~/QuadraService/Service.svc" binding="wsHttpBinding" contract="IService" bindingConfiguration="Binding1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<endpoint binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding" contract="IService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
<clearUsernameBinding>
<binding name="myClearUsernameBinding"
messageVersion="Soap12">
</binding>
</clearUsernameBinding>
<wsHttpBinding>
<binding name="Binding1">
<!-- UsernameToken over Transport Security -->
<security mode="TransportWithMessageCredential" >
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Configuration binding extension 'system.serviceModel/bindings/clearUsernameBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
please help

Seems like you are receiving the "An error occurred when verifying security for the message" exception because you have not manually modified the configuration file on the client.
The author states the following in the comments:
As for the desktop application, the client needs to manually configure
clearUsernameBinding as done in the sample console application. The
reason is that the clearUsernameBinding dll is not part of .Net 3.5
and needs to be deployed on the client side.

Related

WCF Services - Configuration web service binding exception

All,
Env:
Asp.net 4.0
IIS 7 (or greater)
WCF service consumed by SL component
Authentication:
Anonymous/Forms
When I attempt to browse to my WCF web service (using browser) I get the following exception on my web service, I need to get rid of this error:
The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'BasicHttpBinding' ('Anonymous'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.
I looked at ALL related posts and none of them help me.
I am not using any authentication or user/pwd transmission for my service.
The service I need to get working is consumed by Silverlight component and has this name in web.config file:
Htmls.WebStore.Services.WebStoreServices (ignore the other service).
Here's my web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WebStoreServices_InsecureTransport" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="4096" />
<security mode="None" />
</binding>
<binding name="basicHttpBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="SitefinityWebApp.Sitefinity.Services.Content.EventsAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="EndpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Telerik.Sitefinity.Web.Services.LocalizationBehavior" />
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Htmls.WebStore.Services.WebStoreServices">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="WebStoreServices_InsecureTransport" contract="Htmls.WebStore.Services.IWebStoreServices" />
</service>
<service name="SitefinityWebApp.Sitefinity.Services.Content.Events">
<endpoint address="" behaviorConfiguration="SitefinityWebApp.Sitefinity.Services.Content.EventsAspNetAjaxBehavior" binding="webHttpBinding" contract="SitefinityWebApp.Sitefinity.Services.Content.Events" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
The exception was caused by having incorrect permission on the folder where the xxxxx.svc file was. The folder was locked down using security permissions.

Why doesn't my serviceAuthenticationManagerType get called for basic authentication?

I am working with WCF OData Services and trying to use basic authentication. When I browse to my OData Services in a web browser I get the username/password prompt. But when I enter a user name and password my custom serviceAuthenticationManagerType does not get called and the login fails. Do I have something configured wrong?
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="basicHttp">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="dataServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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 -->
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="WcfResearch.AuthorizationManagers.WcfResearchAuthorizationPolicy, WcfResearch.AuthorizationManagers" />
</authorizationPolicies>
</serviceAuthorization>
<serviceAuthenticationManager authenticationSchemes="Basic" serviceAuthenticationManagerType="WcfResearch.AuthorizationManagers.WcfResearchAuthenticationManager, WcfResearch.AuthorizationManagers"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="WcfResearch.WcfDataService1" behaviorConfiguration="dataServiceBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="basicHttp" contract="System.Data.Services.IRequestHandler" />
</service>
</services>

WCF configuration and authentication nightmare

I am working with windows server 2008 r2 running iis 7.5. My WCF service is running on framework 4.0. 32-bit app running integrated pipeline.
Service is in a virtual directory with Annonymous and Windows Authentication enabled. My configuration looks like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyWebservice.MyService" behaviorConfiguration="MyWebservice.MyServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="MyWebservice.IMyService" />
<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyWebservice.MyServiceBehavior">
<!-- 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 -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
When I connect with the WCF Test Client from an account that is on the domain, I get the following exception:
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate'.
This error is profoundly un-helpful. Can anyone point me to the error of my ways?
Reboot fixed the error. When will I ever learn, with Windows... when things stop making sense, reboot.

WCF - Remote server returned an error: 404

I am new to WCF and i am trying to host my first WCF application in a different machine. It works in my local machine from IIS. I hosted in the remote machine and i am able to view the WSDL. I have enabled anonymous authentication as well.
Problem is when i try to test my .svc with SOAP UI, it errors out saying
Error loading [http://domain.com/folder/wcfservice.svc?xsd=xsd0]: java.io.IOException: Attempted read from closed stream
So, i tried using svcutil command and it errors out with
Attempting to download metadata from 'http: //domain.com/folder/wcfService.svc?wsdl' using WS-Metadata Exchange or
DISCO. Error: Cannot obtain Metadata from http:
//domain.com/folder/wcfService.svc?wsdl WS-Metadata Exchange Error
URI: http: //domain.com/folder/wcfService.svc?wsdl Metadata contains a
reference that cannot be resolved: 'http:
//domain.com/folder/wcfService.svc?wsdl'.
There was no endpoint listening at http: //domain.com/folder/wcfService.svc?wsdl that could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.HTTP GET Error
URI: http ://domain.com/folder/wcfService.svc?wsdl The document was understood, but it could not be processed. The WSDL document
contains links that could not be resolved. There was an error
downloading 'http ://domain.com/folder/wcfService.svc?xsd=xsd0'. The
underlying connection was closed: An unexpected error occurred on a
receive. Unable to read data from the transport connection: An
existing connection was forcibly closed by the remote host.
Here is my webconfig for your reference.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="defaultBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceTimeouts transactionTimeout="10.00:00:00"/>
</behavior>
<behavior name="metadataSupport">
<serviceDebug includeExceptionDetailInFaults="False" />
<!--Enable WSDL Data Binding-->
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="wcfservice.SSO"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="wcfservice.wcfservice_Service" behaviorConfiguration="defaultBehaviors">
<host>
<baseAddresses>
<add baseAddress="http://domain.com/folder/wcfService.svc" />
</baseAddresses>
</host>
<endpoint address="xml"
binding="basicHttpBinding"
bindingConfiguration="wcfservice.SSO"
contract="wcfservice.Iwcfservice" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I think its worthwhile to mention that this WCF application was created in VS2012 and i just changed the targetframework to 4.0 in web.config after deployment.
Can somebody please help what is causing the error? Am i missing something in web.config?

Webservices wcfstorm client

I am using WCFstrom lite to find the problem with the webservice connection. It comes up with the error
"
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.RSS Feed
"
But as it is lite version I cannot find any configuration on the wcfstrom.
My web config looks like.
<system.serviceModel>
<extensions>
<behaviorExtensions>
<!-- Declare that we have an extension called WSDL Extras-->
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service name="xxxxxxxxxxxxxxxxxx" behaviourConfiguration="xxxxxxxxxxxxxx">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" behaviorConfiguration="WcfExtras.EndpointBehavior" contract="xxxxxxxxxxxx">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" behaviorConfiguration="WcfExtras.EndpointBehavior" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WcfExtras.EndpointBehavior">
<wsdlExtensions location="http://localhost:3893/xxxxxxxx.svc" singleFile="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="xxxxxxx.xxxxxxxx">
<!-- 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 -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Where do I add the following code:
<bindings>
<basicHttpBinding>
<binding name="LoggedInUsersSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
I found the answer, just select the service in the wcf Client and edit on end points then you can edit the maxReceivedmessages property
In WCFStorm (at least in the current 1.3.0 version), you can also increase the MaxReceivedMessage by loading a client app.config file which has a the right (large) value.
http://www.wcfstorm.com/wcf/loading-client-appconfig-files.aspx

Resources