Пример #1
0
        void IClientMessageInspector.AfterReceiveReply(ref Message reply, object correlationState)
        {
            OperationHeaders operationHeaders;

            if (headersFromAction.TryGetValue((string)correlationState, out operationHeaders))
            {
                if (operationHeaders.Out.Count > 0)
                {
                    foreach (SoapHeaderAttribute header in operationHeaders.Out)
                    {
                        string           headerName = header.Name;
                        SoapHeaderHelper sh         = shHelpers[header.Type];
                        Headers[headerName] = sh.GetHeader(headerName, reply.Headers);
                    }
                }
            }
        }
Пример #2
0
        internal static void AddSoapHeader(OperationDescription op, SoapHeaderAttribute soapHeader)
        {
            string headerNamespace          = SoapHeaderHelper.GetNamespace(soapHeader.Type);
            MessageHeaderDescription header = new MessageHeaderDescription(soapHeader.Name, headerNamespace);

            header.Type = soapHeader.Type;
            bool input  = ((soapHeader.Direction & SoapHeaderDirection.In) == SoapHeaderDirection.In);
            bool output = ((soapHeader.Direction & SoapHeaderDirection.Out) == SoapHeaderDirection.Out);

            foreach (MessageDescription msgDescription in op.Messages)
            {
                if ((msgDescription.Direction == MessageDirection.Input && input) ||
                    (msgDescription.Direction == MessageDirection.Output && output))
                {
                    msgDescription.Headers.Add(header);
                }
            }
        }
Пример #3
0
        object IClientMessageInspector.BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            OperationHeaders operationHeaders;

            if (headersFromAction.TryGetValue(request.Headers.Action, out operationHeaders))
            {
                if (operationHeaders.In.Count > 0)
                {
                    foreach (SoapHeaderAttribute header in operationHeaders.In)
                    {
                        string headerName  = header.Name;
                        object headerValue = Headers[headerName];
                        if (headerValue != null)
                        {
                            SoapHeaderHelper sh = shHelpers[header.Type];
                            sh.AddHeader(headerName, headerValue, request.Headers);
                        }
                    }
                }
            }
            return(request.Headers.Action);
        }