Closing this out - apparently it can't be done.
How to set SoapProcessing via code
質問
I'm trying to disable SoapProcessing for an endpoint (yes, it needs to be done, don't ask why, and message inspectors will not work):
However, all of the documentation I've found seems to rely on setting this value in the app's config file. I am developing a plugin for an application that does not allow me to include a separate config file, so I have to set up the endpoint and bindings and all that via code:
// Create transport binding
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
// Create client
MySyncPortClient _service = new MySyncPortClient(binding, new EndpointAddress("https://path/to/service"));
_service.ClientCredentials.UserName.UserName = "foo";
_service.ClientCredentials.UserName.Password = "bar";
// Set custom bindings
BindingElementCollection elements = _service.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
_service.Endpoint.Binding = new CustomBinding(elements);
// Perform a request
_service.DoSomething();
If anyone can point me in the right direction, I'd appreciate it. And not to be rude, but please do not suggest using a config file. It -NEEDS- to be done via code. If you want a full explanation, I can provide one separately.
解決
所属していません StackOverflow