3

Per http://msdn.microsoft.com/en-us/library/system.servicemodel.wshttpbinding.security.aspx, .NET Framework 4.5's WSHttpBinding class has a public Security attribute of type System.ServiceModel.WSHttpSecurity.

The problem is WSHttpBinding is missing this attribute. If I inspect an object of that type with the debugger, it shows no such property:

Debug inspector showing no Security property

Also, Intellisense shows no Security property:

enter image description here

IMPORTANT: Notice that I am setting the Security attribute using the object initializer! And Visual Stuido is fine with that!?

In Correct way communicate WSSE Usernametoken for SOAP webservice, @Chris Marisic shows where he modifies this object.

This app is being compiled for .NET Framework 4.5.

What gives?

Community
  • 1
  • 1
Aren Cambre
  • 6,540
  • 9
  • 30
  • 36
  • 2
    What type is `service.Endpoint.Binding`? It's probably a super-type of `WSHttpBinding`, so it's showing only relevant properties for its actual defined type. **Edit**: [ClientBase.Endpoint.Binding](http://msdn.microsoft.com/en-us/library/system.servicemodel.description.serviceendpoint.binding.aspx) is type [`Binding`](http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.aspx), so you're only seeing the properties relevant to that type. – mellamokb Jan 14 '13 at 21:41
  • 1
    It is a generic type of `System.ServiceModel.Channels.Binding` per http://msdn.microsoft.com/en-us/library/system.servicemodel.endpoint.binding.aspx – msmucker0527 Jan 14 '13 at 21:43

1 Answers1

3

The problem is the Binding property of ClientBase.Endpoint is of type System.ServiceModel.Channels.Binding, which is a generic abstract class that is the parent type of all Binding types. So you are seeing the intellisense for that type.

You need to set the properties on the actual WSHttpBinding instance before you assign it, as you are doing now with the object initialization syntax. Another method would be to assign it to a local variable first:

var binding = new WSHttpBinding(SecurityMode....);
binding.Security = new WSHttpSecurity();
// etc.
service.Endpoint.Binding = binding;
mellamokb
  • 56,094
  • 12
  • 110
  • 136