.net 在WCF SOAP中启用http压缩(客户端、传出消息)
我必须为SOAP服务实现一个客户端,它需要使用标准http压缩来传输数据。服务器端由第三方提供,因此不在我的控制之下!我正在使用.NET4.5和c。 这项任务一开始听起来很简单,但我还不能启用http压缩 由于服务使用WS-Security,我使用WCF来处理连接和所有安全问题。基本上代码如下所示:.net 在WCF SOAP中启用http压缩(客户端、传出消息),.net,wcf,http,soap,compression,.net,Wcf,Http,Soap,Compression,我必须为SOAP服务实现一个客户端,它需要使用标准http压缩来传输数据。服务器端由第三方提供,因此不在我的控制之下!我正在使用.NET4.5和c。 这项任务一开始听起来很简单,但我还不能启用http压缩 由于服务使用WS-Security,我使用WCF来处理连接和所有安全问题。基本上代码如下所示: public void deliverMessage(obj myMessage) { _client = new MyClient("BindingName"); //System.Ser
public void deliverMessage(obj myMessage)
{
_client = new MyClient("BindingName"); //System.ServiceModel.ClientBase
_client.ClientCredentials.ClientCertificate.SetCertificate((StoreLocation)_privCertLoc, (StoreName)_privCertStore, X509FindType.FindBySubjectName, _privCertName);
_client.ClientCredentials.ServiceCertificate.SetDefaultCertificate((StoreLocation)_pubCertLoc, (StoreName)_pubCertStore, X509FindType.FindBySubjectName, _pubCertName);
_client.DeliverData(myMessage);
}
绑定是一个CustomBinding(由于WS-Security),它使用httpsTransport。以下是相关部分:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SOAPBindingName">
<security defaultAlgorithmSuite="Default" authenticationMode="MutualCertificate" requireDerivedKeys="false" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10" requireSignatureConfirmation="false" allowSerializedSigningTokenOnReply="true">
<localClientSettings detectReplays="true" />
<localServiceSettings detectReplays="true" />
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://localhost:1234/WebService/services/MyService" binding="customBinding" bindingConfiguration="SOAPBindingName" contract="ServiceReference.Contract" name="BindingName" >
</endpoint>
</client>
</system.serviceModel>
</configuration>
我发现了很多关于压缩的文章,但是它们都是直接使用HttpWebRequest调用的,或者它们在消息内部使用压缩,而不是在传输层上。
HttpWebRequest将让我为我的对象(现在由WCF处理)创建所有需要的安全性内容。低于传输级别的压缩意味着,它不可互操作,因此在我的情况下不可用
无需压缩即可传输数据。我非常感谢在http传输层上支持压缩的任何帮助 这有用吗?您好,MattC,您发布的文章是关于在服务器端启用压缩的。我需要压缩客户端发送的数据。如果服务器将压缩数据发送回,我将能够对其进行解压缩,因为这是自动处理的(如本文所述)。所以我担心这对我的问题没有帮助,但是谢谢你的回复!啊,对不起,这有什么用吗?您好,MattC,您发布的文章是关于在服务器端启用压缩的。我需要压缩客户端发送的数据。如果服务器将压缩数据发送回,我将能够对其进行解压缩,因为这是自动处理的(如本文所述)。所以我担心这对我的问题没有帮助,但是谢谢你的回复!啊,对不起还是