Question

I have a problem with my wcf service. I have read all posts about this error, i tried almost all propsitions but it does not works!! I want to upload images smaller than 1 mb.

My client config by code : EndpointAddress ea = new EndpointAddress("AddressofServer"); BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); XmlDictionaryReaderQuotas reader = new XmlDictionaryReaderQuotas(); basicHttpBinding.MaxBufferSize = 2147483647; basicHttpBinding.MaxBufferPoolSize = 2147483647; basicHttpBinding.MaxReceivedMessageSize = 2147483647; reader.MaxStringContentLength = 2147483647; reader.MaxDepth = 2147483647; reader.MaxArrayLength = 2147483647; reader.MaxBytesPerRead = 2147483647; reader.MaxNameTableCharCount = 2147483647; basicHttpBinding.ReaderQuotas = reader;

        basicHttpBinding.SendTimeout = new TimeSpan(0, 0, 50);
        basicHttpBinding.OpenTimeout = new TimeSpan(0, 0, 5);
        basicHttpBinding.ReceiveTimeout = basicHttpBinding.SendTimeout;
        basicHttpBinding.AllowCookies = false;
        basicHttpBinding.Security.Mode = BasicHttpSecurityMode.None;

        ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client(basicHttpBinding, ea);


        string nm = sc.Endpoint.Binding.Name;
        using (FileStream fs = new FileStream("c:\\httpfiles\\test.jpg", FileMode.Open))
        {
            byte[] buffer = new byte[fs.Length];
            fs.Read(buffer, 0, buffer.Length);
            sc.GetImage(1, "appareillage", buffer);
        }

My web.config file :

   <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="bnd"
 maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
 maxBufferSize="2147483647"    closeTimeout="00:10:00" openTimeout="00:10:00"
 receiveTimeout="00:10:00" sendTimeout="00:10:00" messageEncoding="Text">
      <readerQuotas
        maxArrayLength="2147483647"
        maxStringContentLength="2147483647" />
      <security mode="None"/>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment
  multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
<services>
  <service name="PodoTouchService.PTouchService" behaviorConfiguration="" >
    <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="bnd"
        contract="Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
</system.serviceModel>
<system.webServer>
<security>
  <requestFiltering allowDoubleEscaping="true">
    <requestLimits maxAllowedContentLength="2147483647"/>
    <fileExtensions allowUnlisted="true"/>
    <verbs allowUnlisted="true"/>
  </requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>

I tried to change applicationHost.config too.

Any idea ?

Was it helpful?

Solution

Thanks for the reply, i found the problem. When i have created the service i changed the ServiceContract attribute to

[ServiceContract(Namespace="PTouchService")]
public interface IService1

 And in the web config file i could not matched this name space. And as a result all changes that i tried did not work. 

This is the working version of my web config file:

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PTouchService.Service1Behavior">
      <!-- Pour éviter la divulgation d'informations de métadonnées, définissez la valeur ci-dessous sur false avant le déploiement -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- Pour recevoir les détails de l'exception dans les erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Pour éviter la divulgation d'informations d'exception, définissez-la sur false avant le déploiement -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="bnd" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
      <security mode="None"/>
    </binding>
  </basicHttpBinding>
</bindings>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top