.NET中带有服务引用c#的多部分消息传递

本文关键字:多部 消息传递 引用 服务 NET | 更新日期: 2023-09-27 18:19:35

我找了好几个小时,都没有找到我认为是一个常见问题的答案。

我有很多数据(字符串[200000000]),我想通过服务引用(asmx)发送到服务。SOAP因为现在的大小而爆炸,我不想增加管道,因为明天可能要发送4M个字符串。

所以我想的是多部分SOAP消息,但是.NET本身并不支持这一点(对吧?)。那么我们该怎么做呢?任何帮助或链接都将不胜感激。

[WebMethod]
public string[] returnSameStringArray(string[] string_array)
{
    return string_array;
}

呼叫代码:

BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
basicHttpBinding.MaxReceivedMessageSize = 131072;
myServiceReference = new MyService.MyServiceSoapClient(basicHttpBinding, new EndpointAddress(@"http://myaddress/myservice.asmx"));
myServiceReference.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
myServiceReference.ChannelFactory.Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
string[] theStringArray = new string[2000000](); //init with something later
theStringArray = myServiceReference.returnSameStringArray(theStringArray);

.NET中带有服务引用c#的多部分消息传递

我建议您查看zeromq和服务堆栈。它们给你所需的控制力。

您还可以考虑将负载拆分为多个调用。