none
Problem adding a behavior to an endpoint RRS feed

  • Question

  • Hello.

    I was attempting to use the code located at http://benmccallum.wordpress.com/2011/08/27/wcf-web-service-wrapper-closing-disposing-and-aborting-best-practices/

    It's a clean way of dealing with the try/catch pattern for calling a service.

    However, after creating the factory and before calling "CreateChannel", I am adding a behavior like so: factory.Endpoint.Behaviors.Add(myBehavior);

    When I then invoke the method using "action(client)", the behavior is not there (it actually becomes a SOAP header, which is not present).

    My original code goes something like this:

    var myServiceProxy = new MyServiceClientProxy(“MyBinding”);
    var myBehavior = new BehaviorToBeAdded(“SomeValue”);  // Actually a SOAP header
    myServiceProxy.Endpoint.Behaviors.Add(myBehavior);

    Then I'd invoke a service method, and that works.

    Any thoughts as to what's going on?

    Thanks in advance,

    Mike

    Wednesday, January 29, 2014 7:59 PM

Answers

All replies