InvalidOperationException: Client found response content type of '', but expected 'text/xml'. The request failed with an empty response - wcf

i just created one web application that deal with WCF Service. Now in linqpad5 i just load all methods from this class. and just write to just test output received from this service or not.
here is my pc's screenshot:
but at time of executing small program i just got this error like :
InvalidOperationException: Client found response content type of '', but expected 'text/xml'.
The request failed with an empty response.
for more information i just include hosted wcf service config :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" defaultLanguage="c#" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="LargeWeb" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="RestServiceImplClient">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeWeb" contract="IRestServiceImpl" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebHttp">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</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" />
<staticContent>
<mimeMap fileExtension=".svc" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
what going wrong here... please help me out of this guys...
update
this service working with iis browsing :

Related

WCF Request Entity Too Large Driving Me Crazy

My config file is here.
Looked other question tried everything but ...
Why i cant set maxRequestSize etc. That is not working.
It gives an error that "Request Entity Too Large"
Can anyone help me, please?
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="RST_SSDOP_TO_LOGO.Service.Server">
<endpoint name="EndPoint1" binding="basicHttpBinding" bindingConfiguration="qwerty" contract="RST_SSDOP_TO_LOGO.Service.IServer"></endpoint>
</service>
</services>
<client>
<endpoint address="http://192.168.1.249:52215/Server.svc" binding="basicHttpBinding"
bindingConfiguration="qwerty" contract="RST_SSDOP_TO_LOGO.Service.IServer"
name="EndPoint1" kind="" endpointConfiguration="" />
</client>
<bindings>
<basicHttpBinding>
<binding name="qwerty" closeTimeout="01:00:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I guess you receive this error on client side.
remember you have to set the max size at client side!!!
<binding name="SoapBinding" maxReceivedMessageSize="2000000" />

The remote server returned an unexpected response: (400) Bad Request WCF REST

I found similar posts, but everything I've tried doesn't work. Can you please tell me what am I doing wrong? First is my client config and second my server config.
First I thought that it is because I try to receive a large amount of data, but that wasn`t the problem in my case.
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxRequestLength="32768" targetFramework="4.5" />
</system.web>
<system.serviceModel>
<client>
<endpoint address="http://localhost:56923/TestService.svc?wsdl"
behaviorConfiguration="webBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding"
contract="TestService.TestService"
name="WcfServiceApp.TestService" />
</client>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding"
maxBufferSize="2097151"
maxBufferPoolSize="2097151"
maxReceivedMessageSize="2097151">
<readerQuotas maxDepth="128"
maxStringContentLength="2147483647"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
</modules>
</system.webServer>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxRequestLength="32768" targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding"
maxBufferSize="2097151"
maxBufferPoolSize="2097151"
maxReceivedMessageSize="2097151">
<readerQuotas maxDepth="128"
maxStringContentLength="2097151"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
One thing that jumps out is the <client> configuration in the client's config, specifically the address attribute.
address="http://localhost:56923/TestService.svc?wsdl"
First, you said you're using REST, so the WSDL file doesn't play a role in that (it's for SOAP services).
Second, the WSDL file is not the service, it's the Web Service Description Language file, which describes the web service so clients can build a proxy to it (again, this is for SOAP, not REST).
Try changing the address in your client config to just the service file:
address="http://localhost:56923/TestService.svc"

413 Request Entity Too Large in wcf service when uploading large image file

i have created wcf Service in which i am receiving Base64 string and converting base64 string to image to store in my project.
but when i am calling my wcf service method from rest client like this i am getting error like this:
413 Request Entity Too Large
and sometimes nothing happens when i am calling my wcf method from rest client.
above is how i am calling my wcf service method.
above base 64 string is an image of size 177Kb.
but when i am passing small base64 string of image with size 2 kb or 3 kb then my wcf service method is calling.
this is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
i have search alot on internet and added this:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
but error is still not resloved.
can anybody please help me???
While you have defined a basicHttpBinding with larger than default values, you have not told the WCF service to actually use that binding. When no service endpoints are defined, the default out of the box binding is basicHttpBinding with the default values.
You can either set your defined binding as the default binding configuration for any services using basicHttpBinding that use that config file by omitting the name attribute in the binding definition, like this:
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas maxDepth="200"
maxStringContentLength="8388608"
maxArrayLength="16384"
maxBytesPerRead="2147483647"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
OR you can assign the defined binding to an explicit endpoint, which would look something like this:
<services>
<service name="MyService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService"
contract="MyNamespace.IServiceContract" />
</endpoint>
</service>
A third place to check is the IIS maximum request length:
<configuration>
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
</configuration>
If you're uploading very large files you may also want to look at chunking or streaming.
Whole <system.serviceModel>
Option 1: With default binding defined (omitting name attribute from binding configuration)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas maxDepth="200"
maxStringContentLength="8388608"
maxArrayLength="16384"
maxBytesPerRead="2147483647"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Option 2: With explicit endpoint using specified binding configuration via endpoint's bindingConfiguration attribute:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas maxDepth="200"
maxStringContentLength="8388608"
maxArrayLength="16384"
maxBytesPerRead="2147483647"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService"
contract="MyNamespace.IServiceContract" />
</endpoint>
</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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Either one of these options should resolve the issue. If they don't, try the third option I gave in my original answer.

WCF Error in binding of two End Points

i am getting this
- ERROR: An unhandled exception of type
'System.Configuration.ConfigurationErrorsException' occurred in
System.Configuration.dll Additional information: The binding at
system.serviceModel/bindings/basicHttpBinding does not have a
configured binding named 'BasicHttpBinding_IService1'. This is an
invalid value for bindingConfiguration.
this is my my web.config file
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="100000000">
<readerQuotas maxDepth="32" maxStringContentLength="2097152 "
maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
contract="WcfService1.IService1" />
<endpoint address="web" behaviorConfiguration="WebBehaviour" binding="webHttpBinding"
bindingConfiguration="" name="WebEndPoint" contract="WcfService1.IService1" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehaviour" >
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DefaultBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
</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>
</configuration>

WCF REST over HTTPS

I'm developing a REST web service using WCF, C# and .NET Framework 4.0.
I have followed this tutorial to create my own certificate and use IIS Express as development server.
But now, I don't know why, I can't access my web service if I use https instead of http.
This is IIS Express applicationhost.config:
<site name="MyGameWCFService" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Fuentes\CSharp\Test\MyLib\MyGameWCFService" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:7342:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
<binding protocol="https" bindingInformation="*:443:Melnibone" />
</bindings>
</site>
And this is my WCF web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MyGameWCFService.MyGameService"
behaviorConfiguration="MyGameServiceBehaviour">
<endpoint address=""
contract="MyGameWCFService.IMyGameService"
behaviorConfiguration="restfulBehavior"
binding="webHttpBinding"
bindingConfiguration="WebHttpBindingConfig" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="WebHttpBindingConfig">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyGameServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="MyGameContext"
providerName="System.Data.SqlClient"
connectionString="Server=.\SQLEXPRESS;Database=MyGame;Integrated Security=True;MultipleActiveResultSets=True"/>
</connectionStrings>
</configuration>
I can access web service with this url:
http://localhost:7342/MyGameService.svc/users,
but I can't if I use the other ones:
https://localhost:4430/MyGameService.svc/users and
https://Melnibone:443/MyGameService.svc/users.
I'm testing it on the same computer (I'm testing it on Melnibone).
When I access it from https://localhost:44300/MyGameService.svc/users I get a HTTP 404 Not Found.
Any advice?
To founding this answer I checked all http bindings and spent about half a day. But I have got it!
Make changes to your config, like this:
<services>
<service behaviorConfiguration="Default" name="Service_Name">
<endpoint behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="httpsBinding" contract="Contract.IContract" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="httpsBinding">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>