1

I have to implement a client for a SOAP service, which need to transmit the data using standard http compression. The server side is provided by a third party, so not under my control! I am using .Net 4.5 and c#. The task sounded simple in the beginning, but I was not able yet to enable the http compression.

As the service uses WS-Security, I use WCF to handle the connection and all the security stuff. Basically the codes looks like this:

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);
}

The Binding is a CustomBinding (due to the WS-Security) which uses httpsTransport. Here is the correponding part:

<?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>

I found a lot of articles on compression, however they all make the call either directly using a HttpWebRequest or they use compression inside the message and not on the transport layer. The HttpWebRequest would leave me with creating all the needed security stuff for my object (which is now handled by WCF). The compression below the tranport level means, it is not interoperable and therefore unusable in my case.

Transmitting the data without compression works fine. I am greatful for any help enabling the compression on the http transport layer!

Dennis M.
  • 11
  • 3
  • Is this of any use? http://stackoverflow.com/questions/3735501/compressing-data-coming-out-of-wcf?rq=1 – MattC Apr 21 '16 at 13:00
  • Hi MattC, the article you posted is on enabling compression on the server side. I need to compress the data send in the client. If the server sends compressed data back, I will be able to decompress it, because that is automatically handled (as the article mentions). So I fear it isn't helping with my problem, but thanks for the reply! – Dennis M. Apr 21 '16 at 13:58
  • Ah sorry http://stackoverflow.com/questions/13031968/compressing-http-post-data-sent-from-browser or http://stackoverflow.com/questions/9549161/how-do-i-signal-to-a-web-server-that-im-posting-gzipped-data?rq=1 – MattC Apr 22 '16 at 08:35

0 Answers0