When I try to transfer a large data in WCF, I get this error:
The formatter threw an exception while trying to deserialize the
message: There was an error while trying to deserialize parameter
http://tempuri.org/:requete. The InnerException message was 'There was
an error deserializing the object of type System.String. 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 8843.'.
Please see InnerException for more details.
This is my app.config file :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" maxBufferSize="52428800" maxBufferPoolSize="52428800">
<readerQuotas maxStringContentLength="52428800" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TSO_WCF.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/TSO_WCF/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding" contract="TSO_WCF.IService1" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<appSettings>
<add key="Mapping" value="D:\workspace\oddo.app.ldw.tsomanagertool\ProjetTSO\MappingsXML"/>
</appSettings>
</configuration>
You should increse the MaxStringContentLength on the server and client binding. At this moment you are using the default value of 8192.
Perhaps you could change your binding /use streaming. See this page: http://msdn.microsoft.com/en-us/library/ms733742.aspx
Related
I just started WCF for a project and it is showing the following exception, however I found some Question related to this problem but I am not able to found in my code, here I am putting my code, please look and suggest the best solution for my code.
<system.serviceModel>
<services>
<service name="CompanyService.CompanyService" behaviorConfiguration="mexBehaviour">
<endpoint address="CompanyService" binding="basicHttpBinding" contract="CompanyService.ICompanyPublicService"></endpoint>
<endpoint address="CompanyService" binding="netHttpBinding" contract="CompanyService.ICompanyConfidentialService"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
<add baseAddress="net.tcp://localhost:8091/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Here below is the error exception:
'A binding instance has already been associated to listen URI 'http://localhost:8080/CompanyService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config. '
You need to modify the name of the endpoint address:
<services>
<service name="CompanyService.CompanyService" behaviorConfiguration="mexBehaviour">
<endpoint address="CompanyService01" binding="basicHttpBinding" contract="CompanyService.ICompanyPublicService"></endpoint>
<endpoint address="CompanyService02" binding="netHttpBinding" contract="CompanyService.ICompanyConfidentialService"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
<add baseAddress="net.tcp://localhost:8091/"/>
</baseAddresses>
</host>
</service>
</services>
I am new to WCF and i am trying to host my first WCF application in a different machine. It works in my local machine from IIS. I hosted in the remote machine and i am able to view the WSDL. I have enabled anonymous authentication as well.
Problem is when i try to test my .svc with SOAP UI, it errors out saying
Error loading [http://domain.com/folder/wcfservice.svc?xsd=xsd0]: java.io.IOException: Attempted read from closed stream
So, i tried using svcutil command and it errors out with
Attempting to download metadata from 'http: //domain.com/folder/wcfService.svc?wsdl' using WS-Metadata Exchange or
DISCO. Error: Cannot obtain Metadata from http:
//domain.com/folder/wcfService.svc?wsdl WS-Metadata Exchange Error
URI: http: //domain.com/folder/wcfService.svc?wsdl Metadata contains a
reference that cannot be resolved: 'http:
//domain.com/folder/wcfService.svc?wsdl'.
There was no endpoint listening at http: //domain.com/folder/wcfService.svc?wsdl that could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.HTTP GET Error
URI: http ://domain.com/folder/wcfService.svc?wsdl The document was understood, but it could not be processed. The WSDL document
contains links that could not be resolved. There was an error
downloading 'http ://domain.com/folder/wcfService.svc?xsd=xsd0'. The
underlying connection was closed: An unexpected error occurred on a
receive. Unable to read data from the transport connection: An
existing connection was forcibly closed by the remote host.
Here is my webconfig for your reference.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="defaultBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceTimeouts transactionTimeout="10.00:00:00"/>
</behavior>
<behavior name="metadataSupport">
<serviceDebug includeExceptionDetailInFaults="False" />
<!--Enable WSDL Data Binding-->
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="wcfservice.SSO"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="wcfservice.wcfservice_Service" behaviorConfiguration="defaultBehaviors">
<host>
<baseAddresses>
<add baseAddress="http://domain.com/folder/wcfService.svc" />
</baseAddresses>
</host>
<endpoint address="xml"
binding="basicHttpBinding"
bindingConfiguration="wcfservice.SSO"
contract="wcfservice.Iwcfservice" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I think its worthwhile to mention that this WCF application was created in VS2012 and i just changed the targetframework to 4.0 in web.config after deployment.
Can somebody please help what is causing the error? Am i missing something in web.config?
I am trying to pass a BMP file as a parameter in a WCF Service. I'mm getting an error when the size of the BMP file is 350kb. When I pass a small file of 10-20 kb it runs perfectly.
The remote server returned an unexpected response: (413) Request Entity Too Large.
[OperationContract]
byte[] ConvertData(Bitmap bmp);
I have tried to solve the issue with changing IIS setting following this link: http://blogs.msdn.com/b/jiruss/archive/2007/04/13/http-413-request-entity-too-large-can-t-upload-large-files-using-iis6.aspx but no luck
My Server web.config is
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
My Client Web.Config is
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<client>
<endpoint address="http://localhost:8012/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceClient.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
On your readerQuotas, try to set maxStringContentLength to 2147483647 as well, and make sure this config is set on both ends.
So both the server and the client need to have these values. It's no help if the client is allowed to send a large file, if the server will reject it anyway.
What is the value of maxArrayLength on the wcf server application
hi i am tring to use this article for making my wcf service authenticate without SSL
http://webservices20.blogspot.in/2008/11/introducing-wcf-clearusernamebinding.html
but i am geting this error when i try to compile :
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="clearUsernameBinding" type="ClearUsernameCollectionElement, ClearUsernameBinding" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyValidator,App_Code"/>
</serviceCredentials>
<!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment-->
<serviceMetadata 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>
<behavior name="SampleServiceBehaviour">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyUserNameValidator, App_Code" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service" behaviorConfiguration="SampleServiceBehaviour">
<endpoint address="~/QuadraService/Service.svc" binding="wsHttpBinding" contract="IService" bindingConfiguration="Binding1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<endpoint binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding" contract="IService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
<clearUsernameBinding>
<binding name="myClearUsernameBinding"
messageVersion="Soap12">
</binding>
</clearUsernameBinding>
<wsHttpBinding>
<binding name="Binding1">
<!-- UsernameToken over Transport Security -->
<security mode="TransportWithMessageCredential" >
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Configuration binding extension 'system.serviceModel/bindings/clearUsernameBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
please help
Seems like you are receiving the "An error occurred when verifying security for the message" exception because you have not manually modified the configuration file on the client.
The author states the following in the comments:
As for the desktop application, the client needs to manually configure
clearUsernameBinding as done in the sample console application. The
reason is that the clearUsernameBinding dll is not part of .Net 3.5
and needs to be deployed on the client side.
I am using WCFstrom lite to find the problem with the webservice connection. It comes up with the error
"
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.RSS Feed
"
But as it is lite version I cannot find any configuration on the wcfstrom.
My web config looks like.
<system.serviceModel>
<extensions>
<behaviorExtensions>
<!-- Declare that we have an extension called WSDL Extras-->
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service name="xxxxxxxxxxxxxxxxxx" behaviourConfiguration="xxxxxxxxxxxxxx">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" behaviorConfiguration="WcfExtras.EndpointBehavior" contract="xxxxxxxxxxxx">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" behaviorConfiguration="WcfExtras.EndpointBehavior" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WcfExtras.EndpointBehavior">
<wsdlExtensions location="http://localhost:3893/xxxxxxxx.svc" singleFile="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="xxxxxxx.xxxxxxxx">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
Where do I add the following code:
<bindings>
<basicHttpBinding>
<binding name="LoggedInUsersSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
I found the answer, just select the service in the wcf Client and edit on end points then you can edit the maxReceivedmessages property
In WCFStorm (at least in the current 1.3.0 version), you can also increase the MaxReceivedMessage by loading a client app.config file which has a the right (large) value.
http://www.wcfstorm.com/wcf/loading-client-appconfig-files.aspx