Zobrazujú sa príspevky s označením WCF. Zobraziť všetky príspevky
Zobrazujú sa príspevky s označením WCF. Zobraziť všetky príspevky

piatok 8. júna 2012

WCF : Cannot have two operations in the same contract with the same name

WCF - over HTTP  (and also Web Services in generaly) does not allow method overloading (it means :same method name but different atributes types, which is in C# absolutely correct).


Reason:
When data is passed to an XML Web service it is sent in a request and when it is returned it is sent in a response. Therefore, if an XML Web service contains two or more XML Web service methods with the same name, no uniquely identification will be there. Hence it will produce error.

You should use OperationContract atribute "name" or simply rename one of the methods.



 
This is example from my current project (in Slovak language)
Code Snippet
  1.         [OperationContract]
  2.         APIVytvorDokumentResponse VytvorDokument(global::eDocsInterfaceCUD.CBO_API.CUD.MTOM.APIVytvorDokumentByteArrayRequest request);
  3.        
            [OperationContract(Name = "VytvorDokumentCezStream")]
  4.         APIVytvorDokumentResponse VytvorDokument(global::eDocsInterfaceCUD.CBO_API.CUD.MTOM.APIVytvorDokumentStreamRequest request);

pondelok 27. februára 2012

Error: The maximum message size quota for incoming messages (65536) has been exceeded.

This error has occurred, when I was calling simple method on WCF service.
I double checked my web.config on server side (IIS) and everything was fine.

But!!! the size 65536 was in client app.config! The client configuration was not reflecting server WCF configuration, changing maxReceivedMessageSize to e.g. 2147483647 is solution.


Code Snippet
  1. <system.serviceModel>
  2.     <bindings>
  3.       <basicHttpBinding>
  4.         <binding name="BasicHttpBinding_IeDocsInterfaceCUD" closeTimeout="00:10:00"
  5.           openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
  6.           allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  7.           maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  8.           messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
  9.           useDefaultWebProxy="true">
  10.           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  11.             maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  12.           <security mode="None">
  13.             <transport clientCredentialType="None" proxyCredentialType="None"
  14.               realm="" />
  15.             <message clientCredentialType="UserName" algorithmSuite="Default" />
  16.           </security>
  17.         </binding>

piatok 24. februára 2012

Error : There was no endpoint listening... WCF

This error has occurred, when I was sending file to WCF service hosted on IIS 7, with more size than 30MB. There is a security limitation in IIS. After adding this lines in the web.config, the problem has been solved.



Code Snippet
  1. <system.webServer>
  2.        <security>
  3.          <requestFiltering>
  4.            <requestLimits maxAllowedContentLength="2147483647" />
  5.          </requestFiltering>
  6.        </security>
  7.     </system.webServer>

štvrtok 16. februára 2012

An error (The request was aborted: The request was canceled.) occurred while transmitting data over the HTTP channel.

I got this error when transmitting large file (byte array) to WCF service.

I double checked my web.config,

Code Snippet
  1. <bindings>
  2.       <basicHttpBinding>
  3.         <binding
  4.           name="BasicWithMtom"
  5.           maxReceivedMessageSize="2621440"
  6.           messageEncoding="Mtom">
  7.           <readerQuotas maxArrayLength="2621440"/>
  8.         </binding>
  9.       </basicHttpBinding>
  10.     </bindings>

but sizing was good enough.

The problem is, that the WCF service is hosted on IIS and  you need to configure quotas on two separated places!!

Add this:

Code Snippet
  1. <system.webServer>
  2.   <httpRuntime maxRequestLength="2621440" />
  3. </system.webServer>


Everything is working now..

Have a nice day!