0

I am using 3rd party service URL from my WCF code and defining everything from code and database, not from web.config. Defining HTTPBinding and binding elements also from code.

 BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
 basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
 basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
 basicHttpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
 basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
 BindingElementCollection _bindingElements = _myClient.Endpoint.Binding.CreateBindingElements();
_bindingElements.Find<SecurityBindingElement>().IncludeTimestamp = false;
_myClient.Endpoint.Binding = new CustomBinding(_bindingElements);

While executing when I trace the XML it is as below. Highlighted bold part in attached image security name space is taking by default as //docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd which is not working for me. If needs to be changed to http://schemas.xmlsoap.org/ws/2003/06/secext to get response.

How to change it?

enter image description here

Jaap
  • 81,064
  • 34
  • 182
  • 193
  • Where did you get the security token from? It is not valid. I think it was generated for a different encryption algorithm. The net encryption class works with a number of different encryption schemes. I think the wrong options may of been used to generate the token. – jdweng Sep 08 '16 at 10:21
  • Security Token it is directly picking from the Client endpoint i am using. When i use endpoint form web.config file and define header there it is working fine. Here i am trying from code and it is taking oasis – user6808566 Sep 08 '16 at 10:33
  • If you are reading from a file you may be using the wrong encoding. Often when you read from a file the stream classes default to ASCII which removes non-printable characters. The token contains a security key that may be using non ASCII characters. Try setting the stream class that you are using to read token to UTF8 encoding. – jdweng Sep 08 '16 at 10:41
  • Maybe this link can help you: http://stackoverflow.com/a/10756020/4730201 – Ricardo Pontual Sep 08 '16 at 11:10

0 Answers0