我在这里面临一个问题.我正在做一个客户端/服务器项目,这是WCF Web服务调用来获取数据.由于传输的大量数据,我必须以编程方式(而不是通过配置文件)将我的绑定更改为自定义绑定.
我正在创建一个新的用户定义绑定,也就是自定义绑定.该类的例子是:
public class MyCustomBinding : CustomBinding
Run Code Online (Sandbox Code Playgroud)
并覆盖函数BindingElementCollection:
public override BindingElementCollection CreateBindingElements()
{
WSHttpBinding wSHttpBinding = new WSHttpBinding("RMSKeberosBinding"); //this is to load the configuration from app.config. because i want to copy the setting of wsHttpConfig to my custom binding.
BindingElementCollection wSHttpBindingElementCollection = wSHttpBinding.CreateBindingElements();
TransactionFlowBindingElement transactionFlowBindingElement = wSHttpBindingElementCollection.Remove<TransactionFlowBindingElement>();
SymmetricSecurityBindingElement securityElement = wSHttpBindingElementCollection.Remove<SymmetricSecurityBindingElement>();
MessageEncodingBindingElement textElement = wSHttpBindingElementCollection.Remove<MessageEncodingBindingElement>();
HttpTransportBindingElement transportElement = wSHttpBindingElementCollection.Remove<HttpTransportBindingElement>();
GZipMessageEncodingBindingElement gzipElement = new GZipMessageEncodingBindingElement(); // this is from microsoft sample. i want to add gzip as a compress to my message.
BindingElementCollection newCol = new BindingElementCollection();
newCol.Add(transactionFlowBindingElement);
newCol.Add(securityElement);
newCol.Add(gzipElement);
newCo .Add(transElement);
return newCol;
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是从wshttpbinding复制所有设置,并添加gzip作为消息编码器. 压缩加密数据将导致原始数据大小更大. 这是因为WSHttpBinding的SymmetricSecurityBindingElement进行了加密.如何以正确的方式做到这一点?我希望wshttpbinding的安全设置,以及gzip工作.
您应该能够仅使用一种行为来相应地应用压缩:
http://weblogs.asp.net/cibrax/archive/2006/03/29/441398.aspx
编辑:我也许还应该包含基于行为的压缩的链接:
http://weblogs.shockbyte.com.ar/rodolfof/archive/2006/04/06/5632.aspx
| 归档时间: |
|
| 查看次数: |
2989 次 |
| 最近记录: |