Error "Request entity too large" - all properties have top values - wcf

I'm trying to consume a WCFservice, but i'm getting HTTP 413 error "Request entity too large".
I configured WCF service's web.config with the following:
<system.serviceModel>
<services>
<service name="MyCompany.WCF.Payments.SWPayments" behaviorConfiguration="behaviorPayments">
<endpoint binding="basicHttpBinding" contract="MyCompany.WCF.Payments.Contract.ISWPayments" address="">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorPayments">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Payments" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<client>
<endpoint address="http://server:port/MyCompanyWCFPayments/Payments.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Payments" contract="MyCompany.WCF.Payments.Contract.ISWPayments" name="BasicHttpBinding_Payments" />
</client>
</system.serviceModel>
As you can see, the properties' values are set with the top value. But i'm getting the HTTP 413 error.
Am I missing something?
Thanks in advance and best regards. Looking forward for your comments on above.

It seems that the server and the client are on the same machine. We should at least ensure the binding configuration is applied in the server. Besides, please do not forget to apply the configuration on the binding configuration of the server by using BindingConfiguration property.
<services>
<service name="MyCompany.WCF.Payments.SWPayments" behaviorConfiguration="behaviorPayments">
<endpoint bindingConfiguration="BasicHttpBinding_Payments" binding="basicHttpBinding" contract="MyCompany.WCF.Payments.Contract.ISWPayments" address="">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Feel free to let me know if the problem still exists.

Related

A relative URI cannot be created because the 'uriString' parameter represents an absolute

I have created a simple WCF application to host in sharepoint server.
When deployed i got this error
A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.http://<MySharepointserver>:28000/_vti_bin/WCF/service.svc
Here is my service Web.config
<system.serviceModel>
<services>
<service behaviorConfiguration="AssignmentCreatorMK1.ISAPI.ServiceBehaviour" name="AssignmentCreatorMK1.ISAPI.Service">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEmployeeService" contract="AssignmentCreatorMK1.ISAPI.IService" name="BasicHttpBinding_IEmployeeService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IEmployeeService" maxReceivedMessageSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AssignmentCreatorMK1.ISAPI.ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
can somebdy please help me out here ?

http wcf error "Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding..."

am getting this error when i try to call my custom svc file from sharpoint. i have posted my web.config file here, could you guys tell wats wrong with this.
am trying to have my custom webservice in the sharepoint, so i created a project but due to this error i could not browse my web methods.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="AlertWcfService.CustomServiceBehaviour"
name="AlertWcfService.AlertService">
<endpoint address="http://localhost:2000/" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration"
contract="AlertWcfService.IAlertService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2000/"></add>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfiguration">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AlertWcfService.CustomServiceBehaviour">
<!--<serviceMetadata httpsGetEnabled="false"/>-->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The error is that you're not using HTTPS, but you're using an MEX binding for HTTPS rather than HTTP. TO fix this, change this line:
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
To
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
In your interface declaration IAlertService, add the name attribute beside the namespace if you do not have it yet...
[ServiceContract(Name = "NameNeeded", Namespace = "http://blahbalh")]
public interface IAlertService
{
.....
}

WCF 4 and multiple endpoint bindings

I am yrying to have the same contract and service to be exposed as both basicHttpBinding and webHttpBinding to be able to do a POST call. somehow it's NEVER seeing the endpoint for webHttpBinding when I look at the wsdl. What I am doing wrong?
<system.serviceModel>
<services>
<service name="MyService">
<endpoint address =""
binding="basicHttpBinding"
name="EndpointBasic"
contract="IMyService"/>
<endpoint address ="PostMethod"
binding="webHttpBinding"
name="EndpointJson"
contract="IMyService"/>
<host>
<baseAddresses>
<add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" />
</basicHttpBinding>
<webHttpBinding>
<binding name="Postbinding"
maxBufferSize="65536"
maxReceivedMessageSize="2000000000"
transferMode="Streamed">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Thanks!
I have the following service element entry which works for both SOAP and REST:
<service name="XMLService.RestAndSoapService" behaviorConfiguration="default">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="RestBinding" name="SampleService" contract="XMLService.IRestAndSoapService" />
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="noSecurity" contract="XMLService.IRestAndSoapService" />
</service>
Points to note in your config:
In your service element your contract and service name are not fully qualified. Make sure that they are fully qualified ie. includes the namespace along with the interface.
You have not specified the bindingConfiguration as "Postbinding" for webHttpEndpoint and "basicBinding" for basicHttpBinding endpoint
So with the above changes your config might look as shown below:
<service name="namespace.MyService">
<endpoint address =""
bindingConfiguration="basicBinding"
binding="basicHttpBinding"
name="EndpointBasic"
contract="namespace.IMyService"/>
<endpoint address ="PostMethod"
bindingConfiguration="Postbinding"
binding="webHttpBinding"
name="EndpointJson"
contract="namespace.IMyService"/>
<host>
<baseAddresses>
<add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
</baseAddresses>
</host>
</service>

WCF .config file - something is plainly wrong

Folks,
I've got something wrong with this .config for my WCF. When I send data to it more than 8192 bytes (the default) it fails, telling me my "maxStringContentLength" is only 8192. I think I have it set here to 10,000,000.
Any clues?
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom">
<readerQuotas maxDepth="200" maxStringContentLength="10000000" maxArrayLength="16384" maxBytesPerRead="10000000" maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="PsychCoverage.WcfMT.Admin">
<endpoint address="" binding="wsHttpBinding" contract="PsychCoverage.Common.IAdmin">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfMT/Admin/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior >
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You do have it set, but you're not referencing it in the endpoint element, so .NET is using the default for wsHttpBinding (8192). Add the config you specified using the bindingConfiguration attribute of the endpoint element:
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PsychCoverage.Common.IAdmin">
Also, I'd recommend using a different name than wsHttpBinding to prevent confusion.

WCF with custombinding on both http and https

I have a WCF service with custombinding and it is working fine on either http or https. But I have totally no idea about how can I make it available on both http and https?
Also is it possible to do that?
Here's my configuration in web.config.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
Thanks
You'll need to have two endpoints, one for HTTP and another for HTTPS. It should work just fine.
<bindings>
<customBinding>
<binding name="customBindingHTTP">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="customBindingHTTPS">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="customBindingHTTP"
contract="MyWCFService" />
<endpoint address=""
binding="customBinding"
bindingConfiguration="customBindingHTTPS"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>