Cannot find authenticationScheme within httpTransport - wcf

I am trying to use Windows Authentication for a service and have read several posts just saying I need to add
httpTransport = authenticationScheme="Negotiate"
However I just get the message 'The authenicationScheme attribute is not declared'
Can anybody explain how I may find this, or if there is another way to give Windows Authentication to a custom service.
<customBinding>
<binding name="CustomBinding_AFDiscoveryService">
<binaryMessageEncoding />
<httpTransport authenticationScheme="Negotiate" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
Many Thanks
Chris

That should work just fine. Where do you get this message?
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_AFDiscoveryService">
<binaryMessageEncoding />
<httpTransport authenticationScheme="Negotiate" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<services>
<service name="Host.Service1">
<endpoint address="" binding="customBinding" bindingConfiguration="CustomBinding_AFDiscoveryService" contract="Host.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/Host/Service1/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>

Related

WCF Setting Security to None fails

I have a service that is working fine using the default security (Windows as far as I know). But I need to enable mi service to work across different domains, so I am trying to disable security for test purposes.
Here's the original client :
Client app.config
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService">
<security>
<transport clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://me.domain.local/MyService/Service.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="MyService.IMyService" name="NetTcpBinding_IMyService">
<identity>
<servicePrincipalName value="host/me.domain.local" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Now, I set this security tag from Windows to None and I will need to to the same in the Service side but it seems that I'm failing to do so
Heres the original working app.config of the Service
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyServiceWCF.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyServiceWCF.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyServiceWCF/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I tried adding this tag but it would not work
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConfig" transferMode="Buffered" maxReceivedMessageSize="5242880">
<readerQuotas maxArrayLength="5242880" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
Edit 1 :
So I corrected the client app.config code to set Security mode to None. I also try to use Net Tcp binding.
<bindings>
<netTcpBinding>
<binding name="MyBinding">
<security mode="None">
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://me.domain.local/MyService/Service.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="GService.IMyService" name="NetTcpBinding_IMyService">
<identity>
<servicePrincipalName value="host/me.domain.local" />
</identity>
</endpoint>
</client>
Now for the server side I tried this but wont work either. I really think Im missing a point here.
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="MyServiceWCF.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyServiceWCF.IMyService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="netTcpBinding" contract="MyServiceWCF.IMyService" bindingConfiguration="NetTcpBinging_IMyService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyServiceWCF/Service1/" />
</baseAddresses>
</host>
</service>
</services>
You don't have to change to tcp.
Just add a basic http endpoint for your service:
<endpoint address="http://rofl.lol" binding="basicHttpBinding" bindingConfiguration="BasicHttpBindingSettings" contract="roflservice" bindingName="BasicHttpBindingSettings/>
And set the security to none in you binding:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBindingSettings">
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>

in the client configuration, it says that I don't have a configuration with the name xxx

I have this configuration in my app config in the client application:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="netHttpBinding_ICalculadora" sendTimeout="00:05:00">
<binaryMessageEncoding compressionFormat="Deflate" />
<tcpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/WCFCalculadoraService/Service1/"
binding="netHttpBinding" bindingConfiguration="netHttpBinding_ICalculadora"
contract="WCFCalculadoraService.ICalculadoraService" name="NetHttpBinding_ICalculadoraService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
But I get an error that says that I don't have a configuration with the name "netHttpBinding_ICalculadora", but I have a custom binding configuration with this name. Why do I get this error?
Thank so much.
Probably this is the problem -
set
binding="customBinding" instead of binding="netHttpBinding"

How to debug "Metadata publishing for this service is currently disabled"?

Below is the web.config file I used.
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<!--Note: the service name must match the configuration name for the service implementation.-->
<service name="_1C_GBCService.GBCService" behaviorConfiguration="GBCServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="_1C_GBCService.IGBCService" />
<!--Add the following endpoint.
Note: your service must have an http base address to add this endpoint.-->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="GBCServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!--policyVersion="Policy15"-->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<!--<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>-->
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="VASASMXSoap" />
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_ILogging">
<security mode="None" />
</binding>
</netTcpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_ILogging" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://onecuatcoresrvs.cognizant.com/messaging/onecommunicator/notification/vas.asmx"
binding="basicHttpBinding" bindingConfiguration="VASASMXSoap"
contract="OneCommunicatorService.VASASMXSoap" name="VASASMXSoap">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://onecsitcoresrvs.cognizant.com/255/Logging.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILogging"
contract="ExceptionLoggingService.ILogging" name="WSHttpBinding_ILogging">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://onecsitcoresrvs.cognizant.com/255/Logging.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ILogging"
contract="ExceptionLoggingService.ILogging" name="NetTcpBinding_ILogging">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
And am confused whether to add the attributes other than name in binding element.
To enable publishing of your metadata for your service GBCService. I added bindingConfiguration equals to WSHttpBinding_ILogging.
<service name="_1C_GBCService.GBCService" behaviorConfiguration="GBCServiceBehavior">
<endpoint address="" bindingConfiguration="WSHttpBinding_ILogging"
binding="wsHttpBinding"
contract="_1C_GBCService.IGBCService" />
<!--Add the following endpoint.Note: your service must have
an http base address to add this endpoint.-->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
And changed your protocol mapping to wsHttpBinding and scheme to HTTP because that was the binding you are using. And HTTP because your metadata exchange or mex used non-secured mexHttpBinding.
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<protocolMapping>
<add binding="wsHttpBinding" scheme="http" />
</protocolMapping>

wcf why when I use two endpoints i can't getthe metadata?

Well, until now, I have only one endpoint and the endpoint for the metadata. Then, I use internet explorer for example, and I can see the metadata.
However, when I configure a second endpoint for other contract, I can't get the metadata, so the service does not expose the contract correctly and I can't use the srvice from the client.
My app.config (it is a self host service) is:
<system.serviceModel>
<services>
<service name="GTS.CMMS.Service.Service" behaviorConfiguration="behaviorConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7997/CMMSHost"/>
<add baseAddress="http://localhost:7998/CMMSHost"/>
</baseAddresses>
</host>
<endpoint address="ServiceCore/"
binding="netTcpBinding"
bindingConfiguration="ServiceCore"
name="ServiceCore"
contract="GTS.CMMS.Service.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="ServiceDocumentos/"
binding="ServiceDocumentos"
bindingConfiguration="basicHttpBinding"
name="ServiceDocumentos"
contract="GTS.CMMS.Service.IServiceDocumentos">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="http://localhost:5000/mex" listenUriMode="Explicit" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorConfig">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" />
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="ServiceCore" maxBufferSize="67108864"
maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
transferMode="Buffered" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:20:00"
sendTimeout="00:01:00" maxConnections="100"
portSharingEnabled="true">
<security mode="None"/>
<readerQuotas maxArrayLength="67108864" maxBytesPerRead="67108864" maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00" />
</binding>
<binding name="ServiceDocumentos" maxBufferSize="67108864"
maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
transferMode="Streamed" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:20:00"
sendTimeout="00:01:00" maxConnections="100"
portSharingEnabled="true">
<security mode="None"/>
<readerQuotas maxArrayLength="67108864" maxBytesPerRead="67108864" maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00" />
</binding>
</netTcpBinding>
<basicHttpBinding>
<binding name="ServiceDocumentos" messageEncoding="Mtom" transferMode="Streamed" />
<binding name="ServiceCore" messageEncoding="Mtom" transferMode="Buffered" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
Thanks.

WCF config files - and the famous "string content length quota (8192)" error

Folks,
Thanks for your help with my previous WCF config file issue. Here's a new one.
My project is a WinForms app client (.NET 4.0) that pulls data from (and saves it to) a WCF services hosted on IIS 7.0. When I save a small payload, all is well. When I try to save a payload over 8192 bytes the error is:
The formatter threw an exception while trying to deserialize the
message: There was an error while trying to deserialize parameter
http://tempuri.org/:objEncounterType. The InnerException message was
'There was an error deserializing the object of type
PsychCoverage.Common.EncounterType. The maximum string content length
quota (8192) has been exceeded while reading XML data. This quota may
be increased by changing the MaxStringContentLength property on the
XmlDictionaryReaderQuotas object used when creating the XML reader.
Line 1, position 10809.'. Please see InnerException for more
details
I have confirmed that my <binding name=""> is the same as my <endpoint bindingConfiguration="">.
I've set my maxReceivedMessageSize and maxBufferPoolSize and maxBufferSize all to 10,000,000 on both my client app.config and my web.config. I tried making my <readerQuota> values very high.
In my web.config I set <httpRuntime maxRequestLength="10000000" />
This is from my client app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wcfAdmin_binding"
maxReceivedMessageSize="10000000"
maxBufferPoolSize="10000000"
maxBufferSize="10000000"
messageEncoding="Text"
sendTimeout="00:05:00"
receiveTimeout="00:05:00"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="false"
>
<readerQuotas maxDepth="200" maxStringContentLength="10000000" maxArrayLength="16384" maxBytesPerRead="10000000" maxNameTableCharCount="16384" />
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<clear/>
<endpoint address="http://localhost/PsychCoverage/Admin.svc" name="AdminUIClientEndpoint" binding="basicHttpBinding" bindingConfiguration="wcfAdmin_binding" contract="PsychCoverage.Common.IAdmin">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
And this is from my service web.config:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="False" ></serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="wcfAdmin_binding"
maxReceivedMessageSize="10000000"
maxBufferPoolSize="10000000"
maxBufferSize="10000000"
messageEncoding="Text"
sendTimeout="00:05:00"
receiveTimeout="00:05:00">
<readerQuotas maxDepth="200"
maxStringContentLength="10000000"
maxArrayLength="16384"
maxBytesPerRead="10000000"
maxNameTableCharCount="16384" />
<security mode="None"></security>
</binding>
<binding name="wcfClientWebPortal_binding"
maxReceivedMessageSize="10000000"
maxBufferPoolSize="10000000"
maxBufferSize="10000000"
messageEncoding="Text"
sendTimeout="00:05:00"
receiveTimeout="00:05:00">
<readerQuotas maxDepth="200"
maxStringContentLength="10000000"
maxArrayLength="16384"
maxBytesPerRead="10000000"
maxNameTableCharCount="16384" />
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="wcfBehavior" name="PsychCoverage.WcfMT.Admin">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="wcfAdmin_binding"
name="AdminEndpoint"
bindingName="wcfAdmin_binding"
contract="PsychCoverage.Common.IAdmin">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
<service behaviorConfiguration="wcfBehavior" name="PsychCoverage.WcfMT.ClientWebPortal">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="wcfClientWebPortal_binding"
name="ClientWebPortalEndpoint"
bindingName="wcfClientWebPortal_binding"
contract="PsychCoverage.Common.IClientWebPortal">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="False" />
<!-- 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" />
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Many thanks in advance.