WCF: A registration already exists for URI - wcf

I have the below in my WCF Web.Config. When I try to access the WCF service I am getting the "A registration already exists for URI" error. The WCF Service is hosted in an SSL enviroment.
Can anyone help please?
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="52428800" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="SOAPBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="52428800" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="wsHTTPBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WsBehavior">
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://*******.com/*****/*****.svc" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="***.***" behaviorConfiguration="WsBehavior">
<endpoint behaviorConfiguration="wsHTTPBehavior" binding="basicHttpBinding" contract="***.***" bindingConfiguration="WSBinding" />
<endpoint address="xml" behaviorConfiguration="jsonBehavior" binding="webHttpBinding" contract="***.***" bindingConfiguration="SOAPBinding" name="SOAP" />
</service>
</services>

Added /mex after .svc extension and worked
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://*******.com/*****/*****.svc/mex" />

Take a look at a-registration-already-exists-for-uri-when-hosting-same-service-for-https-and. It seems like the same problem...
Or this one: wcf-inner-exception-message-a-registration-already-exists-for-uri-net-tcp

Related

Upload greater than 8 MB streams through WCF Service

I'm trying to upload photo(attachment stream) through window service , using REST configuration (webHttpBinding), but I get this exception
here is the binding configuration I used (I tried all of them and the error still as it )
<webHttpBinding>
<binding name="maxRequest" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
<binding name="maxRequestBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport">
</security>
</binding>
<binding name="BasicHttpBinding_IFileService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true"
>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
I had also tried the solution for IIS posted here
https://techcommunity.microsoft.com/t5/iis-support-blog/solution-for-request-entity-too-large-error/ba-p/501134
however, all of the above doesn't work.
here is my endpoint behavior
<endpointBehaviors>
<behavior name="rest">
<webHttp faultExceptionEnabled="true" helpEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="1365536" />
</behavior>
</endpointBehaviors>
here is the contract
and For more information the image size is just 100KB.
WCF default transmission message size is 64KB, you need to use MaxReceivedMessageSize to set the transmission message size.
<system.serviceModel>
<services>
<service name="ConsoleApp1.RawDataService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8012/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding"
contract="ConsoleApp1.IReceiveData"
behaviorConfiguration="ESEndPointBehavior" bindingConfiguration="RestfullwebHttpBinding"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="RestfullwebHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You need to apply RestfullwebHttpBinding to the endpoint.
Feel free to let me know if the problem persists.

WCF Calling Error: The underlying connection was closed: The connection was closed unexpectedly

I have a really annoying problem regarding with WCF Services. I have a wcf service which has basichttpbindng.
The service is published to Azure Web App and timeout is set to 20 minutes. After 180 seconds I get the following error:
The underlying connection was closed: The connection was closed
unexpectedly
I have a method like following:
public ProcessResult TestErrorMessage()
{
try
{
System.Threading.Thread.Sleep(320000);
return new ProcessResult()
{
};
}
catch (Exception ex)
{
throw ex;
}
}
[OperationContract]
ProcessResult TestErrorMessage();
You can find both Config below.
Server Config:
<bindings>
<basicHttpBinding>
<binding name="basicBindingConfiguration" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<!--<security mode="None">-->
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Tefal.WebService.Integration.DivaIntegration" behaviorConfiguration="customBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicBindingConfiguration" contract="Tefal.WebService.Integration.IDivaIntegration" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="customBehavior">
<!--<serviceMetadata httpsGetEnabled="false" />-->
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
Cleint config:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDivaIntegration" closeTimeout="00:20:00"
openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
useDefaultWebProxy="true">
<security mode="Transport" />
</binding>
<binding name="BasicHttpBinding_IDivaIntegration1" receiveTimeout="00:20:00"
sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>

maxreceivedmessagesize error even with all configurations

I have a problem with the MaxReceivedMessageSize attribute, I have all the settings done, but I keep getting the message related to value exceeded (65536)
Can you help me identify the problem in the configuration?
Thank you
This is my web.config file
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<security mode="None" />
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="saam.mdlw.srv.aep.SerBehavior" name="saam.mdlw.srv.aep.aep">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" behaviorConfiguration="saam.mdlw.srv.aep.EndBehavior" contract="saam.mdlw.srv.aep.Isrv_aep" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="saam.mdlw.srv.aep.EndBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="saam.mdlw.srv.aep.SerBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

Maximum number of items that can be serialized or deserialized in an object graph is '32767'

I am getting an error: Maximum number of items that can be serialized or deserialized in an object graph is '32767'. Change the object graph or increase the MaxItemsInObjectGraph quota.
Here is what my server-side and client-side web.config looks like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>
</client>
The request is only pulling items so it shouldnt be throwing an error. Can anyone see what is causing this error?
Put this configuration in your service config,
The thing you have missed in your config is the service behaviour,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService" behaviorConfiguration="SilverlightWCFLargeDataApplication">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>

WCF AllowNTLM .net 3.5sp1 and IIS7.5

I am getting the following error using WCF, calling the a WCF Service on another server.
An error (The request was canceled)
occurred while transmitting data over
the HTTP channel.
The following Services worked on a IIS7 Box on .net3, but we have recently upgraded to IIS7.5 and .net 3.5sp1, if I remove the AllowNtlm attribute out of the Config, the call gets further but does not pass allow the service to do a double hop to the database, i then get the follow error.
'NT AUTHORITY\ANONYMOUS LOGON'.
I have enclosed a copy of the client app.config, which worked using iis7, but
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Windows">
<clientCredentials>
<windows allowNtlm="false" allowedImpersonationLevel="Delegation"/>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="4194304"></dataContractSerializer>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="4194304" maxReceivedMessageSize="4194304" messageEncoding="Text" name="BasicHttpBinding_CalculationWebService" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:10:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"></readerQuotas>
<security mode="TransportCredentialOnly">
<message algorithmSuite="Default" clientCredentialType="UserName"></message>
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server1.domain/WebServices/CacheManagement/CacheBusinessService.svc" behaviorConfiguration="Windows" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CacheWebService" contract="CacheWCFService.CacheWebService" name="BasicHttpBinding_CacheWebService">
<identity>
<servicePrincipalName value="http/server1.domain"></servicePrincipalName>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
This is the Server Config, any ideas?
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="CacheManagementBehavior" name="Iris.WebServices.CacheManagement.CacheWebService">
<endpoint address="" behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_CacheManagement" contract="Iris.WebServices.CacheManagement.CacheWebService" />
<endpoint address="mex" behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_CacheManagement" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_CacheManagement" maxReceivedMessageSize="4194304" receiveTimeout="00:30:00">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CacheManagementBehavior">
<dataContractSerializer maxItemsInObjectGraph="4194304" ignoreExtensionDataObject="True"/>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
</behavior>a
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
We managed to resolve the issue, by removing ServicePrincipleName from the config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Windows">
<clientCredentials>
<windows allowNtlm="false" allowedImpersonationLevel="Delegation"/>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="4194304"></dataContractSerializer>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="4194304" maxReceivedMessageSize="4194304" messageEncoding="Text" name="BasicHttpBinding_CalculationWebService" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:10:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"></readerQuotas>
<security mode="TransportCredentialOnly">
<message algorithmSuite="Default" clientCredentialType="UserName"></message>
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server1.domain/WebServices/CacheManagement/CacheBusinessService.svc" behaviorConfiguration="Windows" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CacheWebService" contract="CacheWCFService.CacheWebService" name="BasicHttpBinding_CacheWebService" />
</client>
</system.serviceModel>
</configuration>