Hi Greg,

a possible solution is to add headers to your service config like:

<services>
  <service name="WcfService1.Service1">
    <endpoint address="http://localhost:9000"; binding="basicHttpBinding"
bindingConfiguration="" contract="WcfService1.IService1">
      <headers>
        <myTag>My Custom Value</myTag>
      </headers>
    </endpoint>
  </service>
</services>
This will add the the value defined in the tag to the soap value in every
call and allow you to extract it in your service implementation through the
OperationContext. I don't think adding a behaviour is necessary as this
might imply that you want to inspect and somehow modify messages at runtime.
If you are only ever going to pass the same value, and provided the client
and service agree on the headers, this is all you would need to do.

Hope this helps.

Steve

On 12 June 2010 08:52, Greg Keogh <[email protected]> wrote:

>  Folks, I’m revisiting a topic I raised about a year ago on how to
> simulate SOAP Headers in WCF. Back then I had a problem where dozens of
> methods in my WCF service all needed the same argument passed in every call,
> and it was crazy to manually add the argument to dozens of methods. In the
> Web Service days you used a SOAP Header member to pass the extra “baggage”
> with each call.
>
>
>
> I was told back then that I’d need to write a custom WCF behaviour, so I
> read the chapter on behaviours in my WROX *WCF Programming* book (which
> sucks) and I think I understand the rather tedious 3-step technique for
> creating behaviours. After reading the book and some web articles I’m left
> confused about exactly which behaviour I need to customise to silently pass
> the extra argument and to retrieve it at the server end. Thanks to the book
> I’m also confused by exactly what data structures the various custom
> behaviours intercept. Lucky for me, back then, the whole issue was low
> priority and I skipped it, but now it’s come back for urgent vengeance.
>
>
>
> Has anyone done what I describe? Or is there an example anyone can find
> that clarifies which behaviour I need to customise?
>
>
>
> Cheers,
>
> Greg
>
>
>

Reply via email to