Reputation:
I'm using a WCF API and a can't serialize an object with a byte array when I try to make Download of a file. The file size is small: 104 bytes. The object is:
[DataContract]
public class File
{
[DataMember]
public string Name { get; set; }
[DataMember]
public byte[] Data { get; set; }
}
I've tried to use KnownType(typeof(byte)), KnownType(typeof(byte[])) and KnownType(typeof(Array)) in the class, but without sucess.
I've also tried to return a string with Base64 of the byte array, but it didn't work.
I have no error message in the client side. The WCF just doesn't return the object until I receive the TimeOut message (I've waiting more than 1 minute). I also tried to change the sizes in the web config. There are my bindings configurations:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
closeTimeout="0:10:00" openTimeout="1:10:00" receiveTimeout="1:10:00" sendTimeout="1:10:00" allowCookies="false"
messageEncoding="Mtom" textEncoding="utf-8">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession enabled="true" inactivityTimeout="00:25:00"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
Plase, help me!!
Upvotes: 2
Views: 1796
Reputation:
After a couple of days I discovered the solution to my problem.
The problem was in the client side, not in the server side, like I thought.
I've forgotten to use the maxReceivedMessageSize
tag in the client side.
So, I copy everything inside the binding block and I and paste in the client webconfig, and it works.
Upvotes: 1