WCF WSDL Soap Header en todas las operaciones

Al definir un atributo que implementa IContactBehavior y IWsdlExportExtension y establecer ese atributo en su contrato de servicio, puede agregar fácilmenteSoap Headers a su wsdl (verhttp: //wcfextras.codeplex.com para más información

Pero ahora necesito establecer un contrato de Soap Header en el wsdl en todos los contratos de Operación y esta vez no puedo establecer un atributo.

El siguiente código (llamado desde IWsdlExportExtension.ExportEndPoint) no funciona, pero funciona cuando se llama desde SoapHeaderAttributes (que ejecuta un IWsdlExportExtension.ExportContract)

foreach (OperationDescription operationDescription in context.ContractConversionContext.Contract.Operations)
{
   AddSoapHeader(operationDescription, "SomeHeaderObject", typeof(SomeHeaderObject), SoapHeaderDirection.InOut);                    
}

internal static void AddSoapHeader(OperationDescription operationDescription, string name, Type type, SoapHeaderDirection direction)
{
    MessageHeaderDescription header = GetMessageHeader(name, type);
    bool input = ((direction & SoapHeaderDirection.In) == SoapHeaderDirection.In);
    bool output = ((direction & SoapHeaderDirection.Out) == SoapHeaderDirection.Out);

    foreach (MessageDescription msgDescription in operationDescription.Messages)
    {
        if ((msgDescription.Direction == MessageDirection.Input && input) ||
            (msgDescription.Direction == MessageDirection.Output && output))
            msgDescription.Headers.Add(header);
    }
}

internal static MessageHeaderDescription GetMessageHeader(string name, Type type)
{
    string headerNamespace = SoapHeaderHelper.GetNamespace(type);
    MessageHeaderDescription messageHeaderDescription = new MessageHeaderDescription(name, headerNamespace);
    messageHeaderDescription.Type = type;
    return messageHeaderDescription;
}

Anyone tiene una idea de cómo aplicar este código en todas las operaciones (sin usar atributos) y, al hacer esto, agregar el contrato del encabezado al wsdl?

Respuestas a la pregunta(6)

Su respuesta a la pregunta