title: Unable to Encrypt the xml soap message using gsoap-2.8.116
body: <p>One of my project has the need to encrypt the soap message using X509 certificate and send the encrypted message to the server. Below code was working fine in the older version of gsoap but when I upgraded it to latest 2.8.116 it is encrypting the soap header but not the SOAP:Body part and that is causing the problem.</p>
  <p>'''</p>
  <p>int main() {
  soap_wsse_set_wsu_id(( * proxy) -&gt; soap, &quot;wsse:BinarySecurityToken SOAP-ENV:Body&quot;);</p>
  <pre><code>if (soap_wsse_add_BinarySecurityTokenX509(( * proxy) -&gt; soap, &quot;X509Token&quot;, * cert1) ||
      soap_wsse_add_KeyInfo_SecurityTokenReferenceX509(( * proxy) -&gt; soap, &quot;#X509Token&quot;) ||
      soap_wsse_sign_body(( * proxy) -&gt; soap, SOAP_SMD_SIGN_RSA_SHA256, * pkey1, 0) ||
      soap_wsse_sign_only(( * proxy) -&gt; soap, &quot;SOAP-ENV:Body&quot;)) {
      return (3);
  }
  
  char * token1, * token2;
  if (cfg.isEncryptionEnabled) {
      for (int i = 0; i &lt; sk_X509_num( * ca); i++) {
          char subj[1024];
          X509_NAME_oneline(X509_get_subject_name(sk_X509_value( * ca, i)), subj, sizeof(subj));
          for (token1 = strtok_r(subj, &quot;=&quot;, &amp; token2); token1; token1 = strtok_r(NULL, &quot;=&quot;, &amp; token2)) {
              if (strcmp(SERVER_PUBLIC_KEY_NAME, token1) == 0) {
                  if (soap_wsse_add_EncryptedKey(( * proxy) -&gt; soap, SOAP_MEC_AES256_CBC, &quot;Cert&quot;, sk_X509_value( * ca, i), NULL, NULL, NULL)) {
                      return (4);
                  }`enter code here`
              }
          }
      }
  }
  
  int check = soap_write_ns2__RequestMessage(proxy -&gt; soap, ns2__requestMessage);
  proxy -&gt; soap -&gt; os = NULL;
  proxy -&gt; soap_endpoint = cfg.serverURL;
  
  int status = runTransaction(ns2__requestMessage, ** ns2__replyMessage);
  </code></pre>
  <p>}
  '''</p>
  <p>great if someone can help here.</p>