Soap Header in WCF

How to use Soap Headers in WCF The samples using MessageContractAttribute doesn't help to solve this.

Thanks,

Sangeetha



Answer this question

Soap Header in WCF

  • Maxamor

    Hi Scoot,

    I like the idea but it throws error when I try to run that sample.

    "Cross-thread operation not valid: Control 'txtRequest' accessed from a thread other than the thread it was created on."

    Regards,

    JDang


  • Seah Chen Khoon

    Never mind.

    Thanks


  • Gouri Sankar

    Here's a sample of the second method inside a Client MessageInspector.

    http://wcf.netfx3.com/files/folders/message_inspection/entry3783.aspx

    Thanks!

    S



  • AlexInToronto

    Scott,

    I have tried to follow your example and I could not be able to see the message which sends from client to the server. The only different between your example and my example is I use app.config file. I think I may miss something on my App.Config file at <EndpointBehavior> attribute section. If you have to use app.config file then what you put on <EndpointBehavior>

    Jdang


  • friggityfraggity

    Two main ways.

    • Contractually specified headers are done using the MessageHeaderAttribute for a MessageContractAttribute-created service.
    • Headers not part of the contract can be added to the headers properties of the OperationContext on either side. Outbound headers need to have a new OperationContextScope created in order to set the headers.

    Does this answer your question Note that this model is different than the ASMX one. There is no attribute that you put on top of an operation to specify adding a specific header with a default value. Instead, if you care about headers you should create a MessageContractAttribute-based service contract, and then headers are directly part of the OM.

    Does this help


  • Soap Header in WCF