以下是我致电服务的地方,请提前致谢
public static BasicHttpBinding basicHttpBinding()
{
BasicHttpBinding BasicHttpBinding_IService1 = new BasicHttpBinding();
BasicHttpBinding_IService1.CloseTimeout = TimeSpan.Parse("00:01:00");
BasicHttpBinding_IService1.OpenTimeout = TimeSpan.Parse("00:01:00");
BasicHttpBinding_IService1.ReceiveTimeout = TimeSpan.Parse("00:10:00");
BasicHttpBinding_IService1.SendTimeout = TimeSpan.Parse("00:01:00");
BasicHttpBinding_IService1.AllowCookies = false;
BasicHttpBinding_IService1.BypassProxyOnLocal = false;
BasicHttpBinding_IService1.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
BasicHttpBinding_IService1.MaxBufferSize = 2147483646;
BasicHttpBinding_IService1.MaxBufferPoolSize = 524288;
BasicHttpBinding_IService1.MaxReceivedMessageSize = 2147483646;
BasicHttpBinding_IService1.MessageEncoding = WSMessageEncoding.Text;
BasicHttpBinding_IService1.UseDefaultWebProxy = true;
BasicHttpBinding_IService1.TextEncoding = UTF8Encoding.UTF8;
BasicHttpBinding_IService1.TransferMode = TransferMode.Streamed;
return BasicHttpBinding_IService1;
}
public static EndpointAddress endPointAddress()
{
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:5409/IService.svc");
return endpointAddress;
}
private void button1_Click(object sender, EventArgs e)
{
ChannelFactory<IService> myChannelFactory = null;
myChannelFactory = new ChannelFactory<IService>(basicHttpBinding(), endPointAddress());
IService client = myChannelFactory.CreateChannel();
MessageBox.Show(client.GetData(1));
}
答案 0 :(得分:0)
ASP.NET开发服务器不支持TransferMode
Streamed
。
使用IIS或自托管WCF服务来绕过它。