title: How to consume third party https wsdl web service in c#
body: <p>In SoapUI tool I've configured .Jks file with Outgoing WS-Security Configurations Signature is BinarySecurityToken and algorithm is CanonicalizationMethod and SignatureMethod it is working perfectly.</p>
  
  <p>Now I try to consume from C# code as below :</p>
  
  <pre><code>SprintApiService.QueryCsaPortTypeClient client = new QueryCsaPortTypeClient();
  
  ClientCredentials ce = new ClientCredentials();
  string fileName = Server.MapPath("");
  fileName = fileName + "/test-01.pfx";
  ce.ClientCertificate.Certificate = new X509Certificate2(fileName, "tag123");
  var val = ce.ClientCertificate.Certificate.GetSerialNumber();
  ce.ClientCertificate.SetCertificate("CN=jaitest-01, OU=TPA, OU=BMP, OU=Projects, O=Sprint, C=us", StoreLocation.CurrentUser, StoreName.TrustedPeople);
  
  System.IdentityModel.Selectors.SecurityTokenManager sTokenMgr = ce.CreateSecurityTokenManager();
  //var sTokenMgr = ce.CreateSecurityTokenManager();
  </code></pre>
  
  <p>But I could not succeed. I am always getting "Rejected by Client (Policy)" please help me.</p>
  
  <p>This is sample request which is created in SoapUI tool :</p>
  
  <pre><code>&lt;wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
           &lt;wsu:Timestamp wsu:Id="Timestamp-c55ce328-af36-4b0f-97d8-3bab57ee6a46" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
              &lt;wsu:Created&gt;2014-02-18T12:27:52Z&lt;/wsu:Created&gt;
              &lt;wsu:Expires&gt;2014-02-18T12:32:52Z&lt;/wsu:Expires&gt;
           &lt;/wsu:Timestamp&gt;
           &lt;wsse:BinarySecurityToken wsu:Id="SecurityToken-1da2e6b0-3a0d-4943-bcae-de0805d9c4c5" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;MIIDmTCCAwKgAwIBAgIERxqCLDANBgkqhkiG9w0BAQUFADAeMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGU3ByaW50MB4XDTExMDgwMjIwMDc0OVoXDTE4MDgwNDA0MDAwMFowYjELMAkGA1UEBhMCVVMxDzANBgNVBAoTBlNwcmludDERMA8GA1UECxMIUHJvamVjdHMxDDAKBgNVBAsTA0JNUDEMMAoGA1UECxMDVFBBMRMwEQYDVQQDEwpzcHJpbnQtbXNvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCG2yDWPQBNG9bjt+sVMzlaooX3jON7tOoqtIxPkXl7XCEvbzZpXL2tYtHXqxVfPo9h1weulbj0dE4LlVjlTjzW4upBI92StqDVYdzTLvZWie1fEslIThHDoX7paQpnrSew3TZ6fk4qVnF4h44J/rLnFt3jLEO6IyRhddganpoOowIDAQABo4IBnjCCAZowCwYDVR0PBAQDAgWgMCsGA1UdEAQkMCKADzIwMTEwODAyMjAwNzQ5WoEPMjAxODA4MDQwNDAwMDBaMBEGCWCGSAGG+EIBAQQEAwIFoDCB5AYDVR0fBIHcMIHZMDagNKAypDAwLjELMAkGA1UEBhMCVVMxDzANBgNVBAoTBlNwcmludDEOMAwGA1UEAxMFQ1JMMjkwgZ6ggZuggZiGSmxkYXA6Ly9jYXg1MDAxLnNwcmludC5jb206Mzg5L289U3ByaW50LGM9VVM/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdD9iYXNlhkpsZGFwOi8vY2F4NTAwMi5zcHJpbnQuY29tOjM4OS9vPVNwcmludCxjPVVTP2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3Q/YmFzZTAfBgNVHSMEGDAWgBRFTY2yujBdccYEb58W/Dt7VY3NHzAdBgNVHQ4EFgQUzUEoNuQ9ummaIU8K6h28izpV2YUwCQYDVR0TBAIwADAZBgkqhkiG9n0HQQAEDDAKGwRWNy4xAwIDKDANBgkqhkiG9w0BAQUFAAOBgQCTDjwpnYdx9JZpBrIwm4qIF4tZmXCCUIBEcoER1oUw/NSdgbbRjpU5AxUR/aK1K3taa27HS+WBQYTeMw+Y/LFhp8m+UjHBx/O1kfk4JAz201Kk0HeGgFvt9sscLfK8YD0aavdDJ6Z0rMpHBlcv8VQ7P+1zqJLay3TY+atl9wuD/Q==&lt;/wsse:BinarySecurityToken&gt;
           &lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;
              &lt;SignedInfo&gt;
                 &lt;CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                 &lt;SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/&gt;
                 &lt;Reference URI="#Timestamp-c55ce328-af36-4b0f-97d8-3bab57ee6a46"&gt;
                    &lt;Transforms&gt;
                       &lt;Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                    &lt;/Transforms&gt;
                    &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
                    &lt;DigestValue&gt;8H8usvOvRYPwOKHVHdOXO6Y3Cz4=&lt;/DigestValue&gt;
                 &lt;/Reference&gt;
                 &lt;Reference URI="#Body-db900962-5b93-4a49-a70a-a1745bed8255"&gt;
                    &lt;Transforms&gt;
                       &lt;Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
                    &lt;/Transforms&gt;
                    &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
                    &lt;DigestValue&gt;54u/0PxaY+S7RigxrisF2Chnplc=&lt;/DigestValue&gt;
                 &lt;/Reference&gt;
              &lt;/SignedInfo&gt;
              &lt;SignatureValue&gt;HC10RHq8lweC1KLGAzw1pxjju5LbWASn5GUCxane36DqUxaXQQnBrF0fyBkpI70H+ncrYaO00sxVd1QWnLfYxzl/YEWfHus/qObmFckRnNsEnx9MV5ejHhntbXdzIc9RFbXoFGPcoEGAsKoUbeOi7UWKbofzATG6VMlKhLFz01k=&lt;/SignatureValue&gt;
              &lt;KeyInfo&gt;
                 &lt;wsse:SecurityTokenReference xmlns=""&gt;
                    &lt;wsse:Reference URI="#SecurityToken-1da2e6b0-3a0d-4943-bcae-de0805d9c4c5" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/&gt;
                 &lt;/wsse:SecurityTokenReference&gt;
              &lt;/KeyInfo&gt;
           &lt;/Signature&gt;
  &lt;/wsse:Security&gt;      
  </code></pre>
  
  <p>Thanks...</p>