Based on this post Error calling a WCF REST service using JSON. length quota (8192) exceeded
I experienced the same problem when calling my WCF REST Service (hosted on IIS 7) from a console application (using Microsoft.HttpClient library). I have increased the maxStringContentLength="2147483647" on the WCF REST Service config, but it still throws the same error for files bigger than 8KB. (Note: there is no client configuration as I simply make a HTTP Post request, I got the same problem when test it using Fiddler)
This is my WCF REST config
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="EmailService">
<host>
<baseAddresses>
<add baseAddress="http://mywebsite.com/v1" />
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="webBehavior" contract="IEmailService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
hey it seem that you are sending more data then it is allowed i.e int.max length, try using custom binding (Binary ) that will help you
Related
I have a WCF service in the web application. Service and application are running fine. Web app address is localhost:53536 and service address is localhost:53536/Mobile/MobileService.svc. These are duplex services and I am consuming these service on the different application. Here is my configuration
<behaviors>
<serviceBehaviors>
<behavior name="" >
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<bindings>
<wsDualHttpBinding>
<binding name="MobileServiceBinding" closeTimeout="00:00:05" openTimeout="00:00:05">
<readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service name="Asm.As.PerformanceMonitor.Web.Mobile.MobileService" >
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="MobileServiceBinding" contract="Asm.As.PerformanceMonitor.Web.Mobile.IMobileService" />
</service>
</services>
As you can see the address is empty. When I add address like http://localhost:1212
It's not working. An error comes refused to connect. Is there any way to host service on a different port or service has different address along with the application? Please note that service will be hosted with the web application.
I'm trying to add a service reference to my VS2015 project. The service is published on IIS in Windows Server 2012 hosted in an Azure VM. This is the 1st time I'm hosting a service inside an Azure VM (Windows Server 2012) so I don't know what I might have been doing wrong.
I can access the TheService.svc file in my web browser normally (i.e.: http://xxxxxx.xxxxx.cloudapp.azure.com/TheService/TheService.svc).
But when I try to add the service reference using the same adress in my VS project, it just hangs to: Please wait for service information to be downloaded or click Stop and the metadata is never downloaded.
Here is the service configuration in the web.config:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="TestBinding" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="true" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Text">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TheService.TheService">
<endpoint address="http://localhost/TheService/TheService.svc" binding="basicHttpBinding" bindingConfiguration="TestBinding" name="TheService_Local" contract="TheService.ITheService" />
<host>
<timeouts openTimeout="00:10:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
It looks like you have not published the metadata for the service, try:
<service name="TheService.TheService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="TestBinding" name="TheService_Local" contract="TheService.ITheService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<timeouts openTimeout="00:10:00" />
</host>
</service>
I solved my problem by setting this attribute in my web.config transform file:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" xdt:Transform="SetAttributes(multipleSiteBindingsEnabled)"/>
I had developed a windows service that hosts a WCF service. The service is installed on a server and the idea is to process some files on the local network (domain). Also, the service is executing as my domain user.
the configuration of the service is this:
<system.serviceModel>
<services>
<service name="Zeus.My.Upload.Service.MyHostedService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:1089/Domain/Service"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:1089/Domain/Service/Uploader" binding="basicHttpBinding" contract="Zeus.My.Upload.Contract.IHostedService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="4294967296" transferMode="Streamed" sendTimeout="01:00:00" messageEncoding="Mtom">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
The issue with this configuration is that only my user is able to access and use this service. Other users of domain cannot even access to the URL.
How can I solve this issue?
Can someone please point me out what's wrong with this service configuration in web.config. I want to access this over HTTPS.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<endpoint binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="WcfService1.IService1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="myBehavior">
<webHttp/>
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false">
</serviceHostingEnvironment>
</system.serviceModel>
I have enabled SSL using Test Certificates on IIS7. The Service1.svc is accessible without any error and I am getting 200 OK Response when accessed through a .NET Console client application. But I am getting 400 Bad Request while accessing the api defined in the service. The same api is working fine when used with HTTP configuration.
I'm using the website which contain .svc file and hosted on https as rest api. My question is:
My website has SVCUTIL.exe is https://XXXXXXX but when I call it with https request it fails but working fine with http request.And I don’t want use SSL certificates
Thanks
This is my webconfig settings:
<serviceBehaviors>
<behavior name="Mybehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="Mybehaviour" name="PBUIService">
<endpoint address="https://XXXXXXXXXXXXXXX" behaviorConfiguration="PBBehaviour" binding="webHttpBinding" bindingConfiguration="wsHttpBindingSettings" contract="PBUIService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
I've added the following lines to make it work with https:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>