[DataContract]
public class Request
[DataMember]
public int ID { get; set; }
[DataMember]
public string Data { get; set; }
}
public Response ProcessData(Request request)
{
//do something with request.Data
}
在客户端
string data = [some large data];
server.ProcessData(new Request() {ID=1, Data=data});
如果我传递一个较小的字符串,它会很好用。但是当我读取文本文件并传递它的内容时,它会抛出错误“Bad Request 400”。
更新: 它现在有效。 wcf服务器上的web.config中的以下条目可以解决问题。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>