title: How to configure WCF client for WS-Security (UsernameToken + Encrypted body SOAP (no signature))
body: <p>I need to configure my WCF client for consuming a JAX service with WS-Security
  UsernameToken + Timestamp + Encryption BODY Soap message with certificate.</p>
  
  <p>For the request I need a SOAP message as below:</p>
  
  <pre><code>&lt;soapenv:Header&gt;
    &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
      &lt;xenc:EncryptedKey Id="EK-8653216552B106D28F13688042014758"
      xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"&gt;
        &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /&gt;
        &lt;ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
          &lt;wsse:SecurityTokenReference&gt;
            &lt;ds:X509Data&gt;
              &lt;ds:X509IssuerSerial&gt;
                &lt;ds:X509IssuerName&gt;
                CN=joe,OU=joe,O=joe,L=joe,ST=joe,C=US&lt;/ds:X509IssuerName&gt;
                &lt;ds:X509SerialNumber&gt;1262035674&lt;/ds:X509SerialNumber&gt;
              &lt;/ds:X509IssuerSerial&gt;
            &lt;/ds:X509Data&gt;
          &lt;/wsse:SecurityTokenReference&gt;
        &lt;/ds:KeyInfo&gt;
        &lt;xenc:CipherData&gt;&lt;xenc:CipherValue&gt;R14juoEJtNL1F8.........&lt;/xenc:CipherValue&gt;
        &lt;/xenc:CipherData&gt;
        &lt;xenc:ReferenceList&gt;
          &lt;xenc:DataReference URI="#ED-28" /&gt;
        &lt;/xenc:ReferenceList&gt;
      &lt;/xenc:EncryptedKey&gt;
      &lt;wsu:Timestamp wsu:Id="TS-27"&gt;
        &lt;wsu:Created&gt;2013-05-17T15:23:21.472Z&lt;/wsu:Created&gt;
        &lt;wsu:Expires&gt;2013-05-17T18:10:01.472Z&lt;/wsu:Expires&gt;
      &lt;/wsu:Timestamp&gt;
      &lt;wsse:UsernameToken wsu:Id="UsernameToken-26"&gt;
        &lt;wsse:Username&gt;test&lt;/wsse:Username&gt;
        &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;
        secret&lt;/wsse:Password&gt;
        &lt;wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&gt;
        avvRRapCKKjmGAeg9bRX/g==&lt;/wsse:Nonce&gt;
        &lt;wsu:Created&gt;2013-05-17T15:23:21.472Z&lt;/wsu:Created&gt;
      &lt;/wsse:UsernameToken&gt;
    &lt;/wsse:Security&gt;
  &lt;/soapenv:Header&gt;
  &lt;soapenv:Body&gt;
    &lt;xenc:EncryptedData Id="ED-5"
    Type="http://www.w3.org/2001/04/xmlenc#Content"
    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"&gt;
      &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc" /&gt;
      &lt;ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
        &lt;wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey"
        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
        xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"&gt;
          &lt;wsse:Reference URI="#EK-1FEEFE8E1D48513E9413690595467661" /&gt;
        &lt;/wsse:SecurityTokenReference&gt;
      &lt;/ds:KeyInfo&gt;
      &lt;xenc:CipherData&gt;
        &lt;xenc:CipherValue&gt;OuEL9072pqJqoTegnqZvkYBvM+05gpMgkfs0unDiTGM5IQVm...............&lt;/xenc:CipherValue&gt;
      &lt;/xenc:CipherData&gt;
    &lt;/xenc:EncryptedData&gt;
  &lt;/soapenv:Body&gt;
  </code></pre>
  
  <p>Exists a specific bindig for this configuration or I must create a custom binding (and how configure it..)?
  Anybody can help me?
  Thanks</p>
  
  <p>Michele</p>