void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
        {
            bool createdNew;
            MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(endpointContext, out createdNew);

            TransportBindingElement.ExportWsdlEndpoint(exporter, endpointContext, this.WsdlTransportUri, encodingBindingElement.MessageVersion.Addressing);
        }
Beispiel #2
0
        public HttpChannelListenerBase(HttpTransportBindingElement source,
                                       BindingContext context)
            : base(context)
        {
            this.Source = source;
            // The null Uri check looks weird, but it seems the listener can be built without it.
            // See HttpTransportBindingElementTest.BuildChannelListenerWithoutListenUri().
            if (Uri != null && source.Scheme != Uri.Scheme)
            {
                throw new ArgumentException(String.Format("Requested listen uri scheme must be {0}, but was {1}.", source.Scheme, Uri.Scheme));
            }

            foreach (BindingElement be in context.RemainingBindingElements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    encoder = CreateEncoder <TChannel> (mbe);
                    break;
                }
            }
            if (encoder == null)
            {
                encoder = new TextMessageEncoder(MessageVersion.Default, Encoding.UTF8);
            }
        }
 private void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.TransactionFlowBindingElement txFlow, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     this.BypassProxyOnLocal = transport.BypassProxyOnLocal;
     this.HostNameComparisonMode = transport.HostNameComparisonMode;
     this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
     this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
     this.ProxyAddress = transport.ProxyAddress;
     this.UseDefaultWebProxy = transport.UseDefaultWebProxy;
     if (encoding is TextMessageEncodingBindingElement)
     {
         this.MessageEncoding = WSMessageEncoding.Text;
         TextMessageEncodingBindingElement element = (TextMessageEncodingBindingElement) encoding;
         this.TextEncoding = element.WriteEncoding;
         this.ReaderQuotas = element.ReaderQuotas;
     }
     else if (encoding is MtomMessageEncodingBindingElement)
     {
         this.messageEncoding = WSMessageEncoding.Mtom;
         MtomMessageEncodingBindingElement element2 = (MtomMessageEncodingBindingElement) encoding;
         this.TextEncoding = element2.WriteEncoding;
         this.ReaderQuotas = element2.ReaderQuotas;
     }
     this.TransactionFlow = txFlow.Transactions;
     this.reliableSession.Enabled = session != null;
     if (session != null)
     {
         this.session.InactivityTimeout = session.InactivityTimeout;
         this.session.Ordered = session.Ordered;
     }
 }
 public CryptEncoderFactory(MessageEncodingBindingElement innerMessageEncodingBindingElement, string key,string iv)
 {
     this.innerMessageEncodingBindingElement = innerMessageEncodingBindingElement;
     this.key = key;
     this.iv = iv;
     messageEncoder = new CryptEncoder(this,key, iv);
 }
        static void EnsureMessageEncoding(WsdlEndpointConversionContext context, MessageEncodingBindingElement encodingBindingElement)
        {
            EnvelopeVersion   soapVersion = SoapHelper.GetSoapVersion(context.WsdlBinding);
            AddressingVersion addressingVersion;

            if (encodingBindingElement == null)
            {
                encodingBindingElement = new TextMessageEncodingBindingElement();
                ConvertToCustomBinding(context).Elements.Add(encodingBindingElement);

                addressingVersion = AddressingVersion.None;
            }
            else
            {
                if (soapVersion == EnvelopeVersion.None)
                {
                    addressingVersion = AddressingVersion.None;
                }
                else
                {
                    addressingVersion = encodingBindingElement.MessageVersion.Addressing;
                }
            }

            MessageVersion newMessageVersion = MessageVersion.CreateVersion(soapVersion, addressingVersion);

            if (!encodingBindingElement.MessageVersion.IsMatch(newMessageVersion))
            {
                ConvertToCustomBinding(context).Elements.Find <MessageEncodingBindingElement>().MessageVersion
                    = MessageVersion.CreateVersion(soapVersion, addressingVersion);
            }
        }
        private void CreateBinding()
        {
            Collection <BindingElement> bindingElementsInTopDownChannelStackOrder = new Collection <BindingElement>();
            BindingElement securityBindingElement = this.config.SecurityManager.GetSecurityBindingElement();

            if (securityBindingElement != null)
            {
                bindingElementsInTopDownChannelStackOrder.Add(securityBindingElement);
            }
            TcpTransportBindingElement item = new TcpTransportBindingElement {
                MaxReceivedMessageSize = this.config.MaxReceivedMessageSize,
                MaxBufferPoolSize      = this.config.MaxBufferPoolSize,
                TeredoEnabled          = true
            };
            MessageEncodingBindingElement encodingBindingElement = null;

            if (this.messageHandler != null)
            {
                encodingBindingElement = this.messageHandler.EncodingBindingElement;
            }
            if (encodingBindingElement == null)
            {
                BinaryMessageEncodingBindingElement element4 = new BinaryMessageEncodingBindingElement();
                this.config.ReaderQuotas.CopyTo(element4.ReaderQuotas);
                bindingElementsInTopDownChannelStackOrder.Add(element4);
            }
            else
            {
                bindingElementsInTopDownChannelStackOrder.Add(encodingBindingElement);
            }
            bindingElementsInTopDownChannelStackOrder.Add(item);
            this.binding = new CustomBinding(bindingElementsInTopDownChannelStackOrder);
            this.binding.ReceiveTimeout = TimeSpan.MaxValue;
        }
Beispiel #7
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            bool flag;

            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            ICollection <XmlElement> bindingAssertions = context.GetBindingAssertions();

            if (TransferModeHelper.IsRequestStreamed(this.TransferMode) || TransferModeHelper.IsResponseStreamed(this.TransferMode))
            {
                bindingAssertions.Add(new XmlDocument().CreateElement("msf", "Streamed", "http://schemas.microsoft.com/ws/2006/05/framing/policy"));
            }
            MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(context.BindingElements, out flag);

            if (flag && (element is IPolicyExportExtension))
            {
                element = new BinaryMessageEncodingBindingElement();
                ((IPolicyExportExtension)element).ExportPolicy(exporter, context);
            }
            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, element.MessageVersion.Addressing);
        }
Beispiel #8
0
        void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
        {
            bool flag;
            MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(endpointContext, out flag);

            TransportBindingElement.ExportWsdlEndpoint(exporter, endpointContext, "http://schemas.microsoft.com/soap/peer", element.MessageVersion.Addressing);
        }
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                AddressingVersion addressing = MessageVersion.Default.Addressing;
#pragma warning disable 56506
                MessageEncodingBindingElement encoding = context.Binding.Elements.Find <MessageEncodingBindingElement>();
                if (encoding != null)
                {
                    addressing = encoding.MessageVersion.Addressing;
                }
                ChannelProtectionRequirements myRequirements = base.GetProtectionRequirements(addressing, ProtectionLevel.EncryptAndSign);
                myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)(object)myRequirements);
            }
            else
            {
                return(base.GetProperty <T>(context));
            }
        }
Beispiel #10
0
        public MsmqChannelListener(MsmqTransportBindingElement source,
                                   BindingContext context)
            : base(context.Binding)
        {
            if (context.ListenUriMode == ListenUriMode.Explicit)
            {
                listen_uri = new Uri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);
            }
            else
            {
                // FIXME: consider ListenUriMode.Unique
                throw new NotImplementedException();
            }

            foreach (BindingElement be in context.RemainingBindingElements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    encoder = CreateEncoder <TChannel> (mbe);
                    break;
                }
            }
            if (encoder == null)
            {
                encoder = new BinaryMessageEncoder();
            }
        }
Beispiel #11
0
        public HttpChannelFactory(HttpTransportBindingElement source, BindingContext ctx)
            : base(source, ctx)
        {
            ClientCredentials = ctx.BindingParameters.Find <ClientCredentials> ();
            foreach (BindingElement be in ctx.RemainingBindingElements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    encoder = CreateEncoder <TChannel> (mbe);
                    break;
                }
#if NET_2_1
                var cbe = be as HttpCookieContainerBindingElement;
                if (cbe != null)
                {
                    cookie_manager = cbe.GetProperty <IHttpCookieContainerManager> (ctx);
                }
#endif
            }
            if (encoder == null)
            {
                encoder = new TextMessageEncoder(MessageVersion.Default, Encoding.UTF8);
            }
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            ICollection <XmlElement> policyAssertions = context.GetBindingAssertions();

            if (TransferModeHelper.IsRequestStreamed(this.TransferMode) ||
                TransferModeHelper.IsResponseStreamed(this.TransferMode))
            {
                policyAssertions.Add(new XmlDocument().CreateElement(TransportPolicyConstants.DotNetFramingPrefix,
                                                                     TransportPolicyConstants.StreamedName, TransportPolicyConstants.DotNetFramingNamespace));
            }

            bool createdNew;
            MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(context.BindingElements, out createdNew);

            if (createdNew && encodingBindingElement is IPolicyExportExtension)
            {
                encodingBindingElement = new BinaryMessageEncodingBindingElement();
                ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context);
            }

            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, encodingBindingElement.MessageVersion.Addressing);
        }
 /// <summary>
 /// Default constructor. 
 /// Creates encoding and transport binding elements.
 /// </summary>
 public SerialTransportBinding(string port)
 {
     //this.messageElement = new TextMessageEncodingBindingElement();
       this.messageElement =
     new SerialEncoderBindingElement();
       this.transportElement = new SerialTransportBindingElement();
       this.transportElement.FactoryPort = port;
 }
 public MessageBusTransportBinding(IBus bus, SessionfulMode sessionfulMode)
     : base()
 {
     _messageElement = new TextMessageEncodingBindingElement();
     _transportElement = new MessageBusTransportBindingElement(bus);
     if (sessionfulMode == SessionfulMode.Standard)
     {
         _sessionElement = new ReliableSessionBindingElement();
     }
 }
Beispiel #15
0
        internal ChannelProtectionRequirements GetProtectionRequirements(BindingContext context)
        {
            AddressingVersion             addressingVersion            = AddressingVersion.WSAddressing10;
            MessageEncodingBindingElement messageEncoderBindingElement = context.Binding.Elements.Find <MessageEncodingBindingElement>();

            if (messageEncoderBindingElement != null)
            {
                addressingVersion = messageEncoderBindingElement.MessageVersion.Addressing;
            }
            return(GetProtectionRequirements(addressingVersion));
        }
        private void ImportPolicyInternal(PolicyConversionContext context)
        {
            XmlElement element;

            context.GetBindingAssertions();
            MessageEncodingBindingElement encodingBindingElement = this.CreateEncodingBindingElement(context.GetBindingAssertions(), out element);
            AddressingVersion             addressingVersion      = WsdlImporter.WSAddressingHelper.FindAddressingVersion(context);

            ApplyAddressingVersion(encodingBindingElement, addressingVersion);
            context.BindingElements.Add(encodingBindingElement);
        }
        internal ChannelProtectionRequirements GetProtectionRequirements(BindingContext context)
        {
            AddressingVersion addressingVersion = AddressingVersion.WSAddressing10;

#pragma warning suppress 56506 // [....], CustomBinding.Elements can never be null
            MessageEncodingBindingElement messageEncoderBindingElement = context.Binding.Elements.Find <MessageEncodingBindingElement>();
            if (messageEncoderBindingElement != null)
            {
                addressingVersion = messageEncoderBindingElement.MessageVersion.Addressing;
            }
            return(GetProtectionRequirements(addressingVersion));
        }
 private static void ApplyAddressingVersion(MessageEncodingBindingElement encodingBindingElement, AddressingVersion addressingVersion)
 {
     EnvelopeVersion envelope = encodingBindingElement.MessageVersion.Envelope;
     if ((envelope == EnvelopeVersion.None) && (addressingVersion != AddressingVersion.None))
     {
         encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, addressingVersion);
     }
     else
     {
         encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(envelope, addressingVersion);
     }
 }
        private MessageEncodingBindingElement FindMessageEncodingBindingElement(BindingElementCollection bindingElements, out bool createdNew)
        {
            createdNew = false;
            MessageEncodingBindingElement encodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>();

            if (encodingBindingElement == null)
            {
                createdNew             = true;
                encodingBindingElement = new BinaryMessageEncodingBindingElement();
            }
            return(encodingBindingElement);
        }
        private static void ApplyAddressingVersion(MessageEncodingBindingElement encodingBindingElement, AddressingVersion addressingVersion)
        {
            EnvelopeVersion envelope = encodingBindingElement.MessageVersion.Envelope;

            if ((envelope == EnvelopeVersion.None) && (addressingVersion != AddressingVersion.None))
            {
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, addressingVersion);
            }
            else
            {
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(envelope, addressingVersion);
            }
        }
 WSDualHttpBinding(
     HttpTransportBindingElement transport,
     MessageEncodingBindingElement encoding,
     TransactionFlowBindingElement txFlow,
     ReliableSessionBindingElement session,
     CompositeDuplexBindingElement compositeDuplex,
     OneWayBindingElement oneWay,
     WSDualHttpSecurity security)
     : this()
 {
     this.security = security;
     InitializeFrom(transport, encoding, txFlow, session, compositeDuplex, oneWay);
 }
        void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

#pragma warning suppress 56506 // Microsoft, these properties cannot be null in this context
            if (context.Endpoint.Binding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding");
            }

            BindingElementCollection          bindingElements = GetBindingElements(context);
            MessageEncodingBindingElement     messageEncodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>();
            TextMessageEncodingBindingElement textEncodingBindingElement    = messageEncodingBindingElement as TextMessageEncodingBindingElement;

            if (messageEncodingBindingElement != null)
            {
                Type elementType = messageEncodingBindingElement.GetType();
                if (elementType != typeof(TextMessageEncodingBindingElement) &&
                    elementType != typeof(BinaryMessageEncodingBindingElement) &&
                    elementType != typeof(MtomMessageEncodingBindingElement))
                {
                    return;
                }
            }

            EnsureMessageEncoding(context, messageEncodingBindingElement);

            foreach (OperationBinding wsdlOperationBinding in context.WsdlBinding.Operations)
            {
                OperationDescription operation = context.GetOperationDescription(wsdlOperationBinding);

                for (int i = 0; i < operation.Messages.Count; i++)
                {
                    MessageDescription message            = operation.Messages[i];
                    MessageBinding     wsdlMessageBinding = context.GetMessageBinding(message);
                    ImportMessageSoapAction(context.ContractConversionContext, message, wsdlMessageBinding, i != 0 /*isResponse*/);
                }

                foreach (FaultDescription fault in operation.Faults)
                {
                    FaultBinding wsdlFaultBinding = context.GetFaultBinding(fault);
                    if (wsdlFaultBinding != null)
                    {
                        ImportFaultSoapAction(context.ContractConversionContext, fault, wsdlFaultBinding);
                    }
                }
            }
        }
        internal override bool IsMatch(BindingElement b)
        {
            if (b == null)
            {
                return(false);
            }

            MessageEncodingBindingElement encoding = b as MessageEncodingBindingElement;

            if (encoding == null)
            {
                return(false);
            }

            return(true);
        }
Beispiel #24
0
        public static MessageEncoderFactory GetEncoder(BindingContext context)
        {
            MessageEncodingBindingElement messageEncoderBindingElement = context.BindingParameters.Remove <MessageEncodingBindingElement>();
            MessageEncoderFactory         factory = null;

            if (messageEncoderBindingElement != null)
            {
                factory = messageEncoderBindingElement.CreateMessageEncoderFactory();
            }
            else
            {
                factory = UdpConstants.Defaults.MessageEncoderFactory;
            }

            return(factory);
        }
Beispiel #25
0
 public PeerChannelFactory(PeerTransportBindingElement source, BindingContext ctx)
 {
     this.source = source;
     foreach (BindingElement be in ctx.RemainingBindingElements)
     {
         MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
         if (mbe != null)
         {
             encoder = CreateEncoder <TChannel> (mbe);
             break;
         }
     }
     if (encoder == null)
     {
         encoder = new BinaryMessageEncoder();
     }
 }
Beispiel #26
0
 public HttpChannelFactory(HttpTransportBindingElement source, BindingContext ctx)
     : base(source, ctx)
 {
     foreach (BindingElement be in ctx.RemainingBindingElements)
     {
         MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
         if (mbe != null)
         {
             encoder = CreateEncoder <TChannel> (mbe);
             break;
         }
     }
     if (encoder == null)
     {
         encoder = new TextMessageEncoder(MessageVersion.Default, Encoding.UTF8);
     }
 }
        static void ApplyAddressingVersion(MessageEncodingBindingElement encodingBindingElement, AddressingVersion addressingVersion)
        {
            EnvelopeVersion defaultEnvelopeVersion = encodingBindingElement.MessageVersion.Envelope;

            if (defaultEnvelopeVersion == EnvelopeVersion.None &&
                addressingVersion != AddressingVersion.None)
            {
                // The default envelope version is None which incompatible with the
                // addressing version.
                // We replace it with soap12. This will be updated at wsdl import time if necessary.
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, addressingVersion);
            }
            else
            {
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(defaultEnvelopeVersion, addressingVersion);
            }
        }
 private void ShowMessageEncodingDetails(MessageEncodingBindingElement element)
 {
     string encodingInfoStr = "messageVersion=" + element.MessageVersion;
     if (element is WebMessageEncodingBindingElement)
     {
         WebMessageEncodingBindingElement webElement = (WebMessageEncodingBindingElement)element;
         encodingInfoStr += ", writeEncoding=" + webElement.WriteEncoding;
         if (webElement.ContentTypeMapper != null)
         {
             encodingInfoStr += ",contentTypeMapper=" + webElement.ContentTypeMapper.GetType().FullName;
         }
         if (webElement.ReaderQuotas != null)
         {
             encodingInfoStr += ",readerQuotas=" + webElement.ReaderQuotas.GetType().FullName;
         }
     }
 }
Beispiel #29
0
 public QpidBinding(string host, int port, string username, string password, string virtualhost)
 {
     Host = host;
     PortNumber = port;
     UserName = username;
     Password = password;
     VirtualHost = virtualhost;
     _transport = new QpidTransportBindingElement();
     _transport.Host = host;
     _transport.PortNumber = port;
     _transport.Password = password;
     _transport.UserName = username;
     _transport.VirtualHost = virtualhost;
     _encoding = new TextMessageEncodingBindingElement();
     _session = new ReliableSessionBindingElement();
     _compositeDuplex = new CompositeDuplexBindingElement();
     _transactionFlow = new TransactionFlowBindingElement();
 }       
        internal static MessageEncodingBindingElement ExportAddressingPolicy(
            PolicyConversionContext context)
        {
            MessageEncodingBindingElement messageEncodingElement = null;

            foreach (var element in context.BindingElements)
            {
                var check = element as MessageEncodingBindingElement;
                if (check == null)
                {
                    continue;
                }
                messageEncodingElement = check;
                break;
            }

            var doc        = new XmlDocument();
            var assertions = context.GetBindingAssertions();

            if (messageEncodingElement == null)
            {
                assertions.Add(doc.CreateElement(
                                   "wsaw", "UsingAddressing",
                                   "http://www.w3.org/2006/05/addressing/wsdl"));
                return(null);
            }

            var addressing = messageEncodingElement.MessageVersion.Addressing;

            if (addressing == AddressingVersion.WSAddressingAugust2004)
            {
                assertions.Add(doc.CreateElement(
                                   "wsaw", "UsingAddressing",
                                   "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"));
            }
            else if (addressing != AddressingVersion.None)
            {
                assertions.Add(doc.CreateElement(
                                   "wsaw", "UsingAddressing",
                                   "http://www.w3.org/2006/05/addressing/wsdl"));
            }

            return(messageEncodingElement);
        }
        public NamedPipeChannelListener(NamedPipeTransportBindingElement source, BindingContext context)
            : base(context)
        {
            foreach (BindingElement be in context.Binding.Elements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    MessageEncoder = CreateEncoder <TChannel> (mbe);
                    quotas         = mbe.GetProperty <XmlDictionaryReaderQuotas> (context);
                    break;
                }
            }

            if (MessageEncoder == null)
            {
                MessageEncoder = new BinaryMessageEncoder();
            }
        }
Beispiel #32
0
        public NamedPipeChannelFactory(NamedPipeTransportBindingElement source, BindingContext ctx)
        {
            foreach (BindingElement be in ctx.RemainingBindingElements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    encoder = CreateEncoder <TChannel> (mbe);
                    quotas  = mbe.GetProperty <XmlDictionaryReaderQuotas> (ctx);
                    break;
                }
            }
            if (encoder == null)
            {
                encoder = new BinaryMessageEncoder();
            }

            this.source = source;
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            bool flag;

            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            XmlDocument document = new XmlDocument();
            ICollection <XmlElement> bindingAssertions = context.GetBindingAssertions();

            if (!this.Durable)
            {
                bindingAssertions.Add(document.CreateElement("msmq", "MsmqVolatile", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
            }
            if (!this.ExactlyOnce)
            {
                bindingAssertions.Add(document.CreateElement("msmq", "MsmqBestEffort", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
            }
            if (context.Contract.SessionMode == SessionMode.Required)
            {
                bindingAssertions.Add(document.CreateElement("msmq", "MsmqSession", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
            }
            if (this.MsmqTransportSecurity.MsmqProtectionLevel != ProtectionLevel.None)
            {
                bindingAssertions.Add(document.CreateElement("msmq", "Authenticated", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
                if (this.MsmqTransportSecurity.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain)
                {
                    bindingAssertions.Add(document.CreateElement("msmq", "WindowsDomain", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
                }
            }
            MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(context.BindingElements, out flag);

            if (flag && (element is IPolicyExportExtension))
            {
                ((IPolicyExportExtension)element).ExportPolicy(exporter, context);
            }
            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, element.MessageVersion.Addressing);
        }
Beispiel #34
0
 public PeerChannelListener(PeerTransportBindingElement source,
                            BindingContext context)
     : base(context)
 {
     this.source = source;
     foreach (BindingElement be in context.Binding.Elements)
     {
         MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
         if (mbe != null)
         {
             MessageEncoder = CreateEncoder <TChannel> (mbe);
             break;
         }
     }
     if (MessageEncoder == null)
     {
         MessageEncoder = new BinaryMessageEncoder();
     }
 }
        internal MessageEncoder CreateEncoder <TChannel> (MessageEncodingBindingElement mbe)
        {
            var f = mbe.CreateMessageEncoderFactory();
            var t = typeof(TChannel);

            if (t == typeof(IRequestSessionChannel) ||
#if !NET_2_1
                t == typeof(IReplySessionChannel) ||
#endif
                t == typeof(IInputSessionChannel) ||
                t == typeof(IOutputSessionChannel) ||
                t == typeof(IDuplexSessionChannel))
            {
                return(f.CreateSessionEncoder());
            }
            else
            {
                return(f.Encoder);
            }
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            bool flag;

            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            this.OnExportPolicy(exporter, context);
            MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(context.BindingElements, out flag);

            if (flag && (element is IPolicyExportExtension))
            {
                ((IPolicyExportExtension)element).ExportPolicy(exporter, context);
            }
            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, element.MessageVersion.Addressing);
        }
Beispiel #37
0
        public TcpChannelFactory(TcpTransportBindingElement source, BindingContext ctx)
        {
            MessageEncoder            encoder = null;
            XmlDictionaryReaderQuotas quotas  = null;

            foreach (BindingElement be in ctx.RemainingBindingElements)
            {
                MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
                if (mbe != null)
                {
                    encoder = CreateEncoder <TChannel> (mbe);
                    quotas  = mbe.GetProperty <XmlDictionaryReaderQuotas> (ctx);
                    break;
                }
            }
            if (encoder == null)
            {
                encoder = new BinaryMessageEncoder();
            }
            info = new TcpChannelInfo(source, encoder, quotas);
        }
Beispiel #38
0
        void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
        {
            bool createdNew;
            MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(endpointContext, out createdNew);
            bool useWebSocketTransport = WebSocketHelper.UseWebSocketTransport(this.WebSocketSettings.TransportUsage, endpointContext.ContractConversionContext.Contract.IsDuplex());

            EndpointAddress address = endpointContext.Endpoint.Address;

            if (useWebSocketTransport)
            {
                address = new EndpointAddress(WebSocketHelper.GetWebSocketUri(endpointContext.Endpoint.Address.Uri), endpointContext.Endpoint.Address);
                WsdlNS.SoapAddressBinding binding = SoapHelper.GetSoapAddressBinding(endpointContext.WsdlPort);
                if (binding != null)
                {
                    binding.Location = address.Uri.AbsoluteUri;
                }
            }

            TransportBindingElement.ExportWsdlEndpoint(exporter, endpointContext,
                                                       this.GetWsdlTransportUri(useWebSocketTransport), address, encodingBindingElement.MessageVersion.Addressing);
        }
 private static void EnsureMessageEncoding(WsdlEndpointConversionContext context, MessageEncodingBindingElement encodingBindingElement)
 {
     AddressingVersion none;
     EnvelopeVersion soapVersion = SoapHelper.GetSoapVersion(context.WsdlBinding);
     if (encodingBindingElement == null)
     {
         encodingBindingElement = new TextMessageEncodingBindingElement();
         ConvertToCustomBinding(context).Elements.Add(encodingBindingElement);
         none = AddressingVersion.None;
     }
     else if (soapVersion == EnvelopeVersion.None)
     {
         none = AddressingVersion.None;
     }
     else
     {
         none = encodingBindingElement.MessageVersion.Addressing;
     }
     MessageVersion messageVersion = MessageVersion.CreateVersion(soapVersion, none);
     if (!encodingBindingElement.MessageVersion.IsMatch(messageVersion))
     {
         ConvertToCustomBinding(context).Elements.Find<MessageEncodingBindingElement>().MessageVersion = MessageVersion.CreateVersion(soapVersion, none);
     }
 }
 public PlainDsspBinding()
 {
     security = CreateSecurity();
     messageEncoding = CreateMessageEncoding();
     transport = CreateTransport();
 }
 private bool IsBindingElementsMatch(MsmqTransportBindingElement transport, MessageEncodingBindingElement encoding)
 {
     if (!this.GetTransport().IsMatch(transport))
     {
         return false;
     }
     if (!this.encoding.IsMatch(encoding))
     {
         return false;
     }
     return true;
 }
        // check that properties of the HttpTransportBindingElement and 
        // MessageEncodingBindingElement not exposed as properties on NetMsmqBinding
        // match default values of the binding elements
        bool IsBindingElementsMatch(MsmqTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            // we do not have to check the transport match here: they always match
            if (!this.GetTransport().IsMatch(transport))
                return false;

            if (!this.encoding.IsMatch(encoding))
                return false;
            return true;
        }
 protected virtual void ConfigureFromMessageEncodingBindingElement(MessageEncodingBindingElement source)
 {
 }
 private bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay)
 {
     if (!this.httpTransport.IsMatch(transport))
     {
         return false;
     }
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!this.textEncoding.IsMatch(encoding))
         {
             return false;
         }
     }
     else if ((this.MessageEncoding == WSMessageEncoding.Mtom) && !this.mtomEncoding.IsMatch(encoding))
     {
         return false;
     }
     if (!this.txFlow.IsMatch(txFlow))
     {
         return false;
     }
     if (!this.session.IsMatch(session))
     {
         return false;
     }
     if (!this.compositeDuplex.IsMatch(compositeDuplex))
     {
         return false;
     }
     if (!this.oneWay.IsMatch(oneWay))
     {
         return false;
     }
     return true;
 }
 private bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding)
 {
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!this.textEncoding.IsMatch(encoding))
         {
             return false;
         }
     }
     else if ((this.MessageEncoding == WSMessageEncoding.Mtom) && !this.mtomEncoding.IsMatch(encoding))
     {
         return false;
     }
     if (!this.GetTransport().IsMatch(transport))
     {
         return false;
     }
     return true;
 }
Beispiel #46
0
 protected AmqpBinding(MessageEncodingBindingElement encoding)
 {
     this.encoding = encoding;
     transport = new AmqpTransportBindingElement();
 }
 void Initialize()
 {
     transport = new UdpTransportBindingElement();
     session = new ReliableSessionBindingElement();
     compositeDuplex = new CompositeDuplexBindingElement();
     encoding = new TextMessageEncodingBindingElement();
 }
        internal virtual void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            this.BypassProxyOnLocal = transport.BypassProxyOnLocal;
            this.HostNameComparisonMode = transport.HostNameComparisonMode;
            this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
            this.MaxBufferSize = transport.MaxBufferSize;
            this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
            this.ProxyAddress = transport.ProxyAddress;
            this.TransferMode = transport.TransferMode;
            this.UseDefaultWebProxy = transport.UseDefaultWebProxy;
            this.httpTransport.WebSocketSettings = transport.WebSocketSettings;
            this.httpsTransport.WebSocketSettings = transport.WebSocketSettings;

            if (encoding is TextMessageEncodingBindingElement)
            {
                TextMessageEncodingBindingElement text = (TextMessageEncodingBindingElement)encoding;
                this.TextEncoding = text.WriteEncoding;
                this.ReaderQuotas = text.ReaderQuotas;
            }
            else if (encoding is MtomMessageEncodingBindingElement)
            {
                MtomMessageEncodingBindingElement mtom = (MtomMessageEncodingBindingElement)encoding;
                this.TextEncoding = mtom.WriteEncoding;
                this.ReaderQuotas = mtom.ReaderQuotas;
            }

            this.BasicHttpSecurity.Transport.ExtendedProtectionPolicy = transport.ExtendedProtectionPolicy;
        }
 public AzureTableTransportBinding(AzureTableTransportBindingElement transportElement)
 {
     this.messageElement = new TextMessageEncodingBindingElement();
     this.transportElement = transportElement;
 }
Beispiel #50
0
        internal virtual void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            this.HostNameComparisonMode = transport.HostNameComparisonMode;
            this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
            this.MaxBufferSize = transport.MaxBufferSize;
            this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
            this.TransferMode = transport.TransferMode;
            _httpTransport.WebSocketSettings = transport.WebSocketSettings;
            _httpsTransport.WebSocketSettings = transport.WebSocketSettings;

            if (encoding is TextMessageEncodingBindingElement)
            {
                TextMessageEncodingBindingElement text = (TextMessageEncodingBindingElement)encoding;
                this.TextEncoding = text.WriteEncoding;
                this.ReaderQuotas = text.ReaderQuotas;
            }
        }
 private bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.TransactionFlowBindingElement txFlow, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     if (!this.GetTransport().IsMatch(transport))
     {
         return false;
     }
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!this.textEncoding.IsMatch(encoding))
         {
             return false;
         }
     }
     else if ((this.MessageEncoding == WSMessageEncoding.Mtom) && !this.mtomEncoding.IsMatch(encoding))
     {
         return false;
     }
     if (!this.txFlow.IsMatch(txFlow))
     {
         return false;
     }
     if (this.reliableSession.Enabled)
     {
         if (!this.session.IsMatch(session))
         {
             return false;
         }
     }
     else if (session != null)
     {
         return false;
     }
     return true;
 }
        bool BindingElementsPropertiesMatch(UdpTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            if (!this.udpTransport.IsMatch(transport))
            {
                return false;
            }

            if (!this.textEncoding.IsMatch(encoding))
            {
                return false;
            }

            return true;
        }
        static void ApplyAddressingVersion(MessageEncodingBindingElement encodingBindingElement, AddressingVersion addressingVersion)
        {
            EnvelopeVersion defaultEnvelopeVersion = encodingBindingElement.MessageVersion.Envelope;

            if (defaultEnvelopeVersion == EnvelopeVersion.None
                && addressingVersion != AddressingVersion.None)
            {
                // The default envelope version is None which incompatible with the 
                // addressing version.
                // We replace it with soap12. This will be updated at wsdl import time if necessary.
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, addressingVersion);
            }
            else
            {
                encodingBindingElement.MessageVersion = MessageVersion.CreateVersion(defaultEnvelopeVersion, addressingVersion);
            }
        }
        void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session)
        {
            // transport
            this.BypassProxyOnLocal = transport.BypassProxyOnLocal;
            this.HostNameComparisonMode = transport.HostNameComparisonMode;
            this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
            this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
            this.ProxyAddress = transport.ProxyAddress;
            this.UseDefaultWebProxy = transport.UseDefaultWebProxy;

            // this binding only supports Text and Mtom encoding
            if (encoding is TextMessageEncodingBindingElement)
            {
                this.MessageEncoding = WSMessageEncoding.Text;
                TextMessageEncodingBindingElement text = (TextMessageEncodingBindingElement)encoding;
                this.TextEncoding = text.WriteEncoding;
                this.ReaderQuotas = text.ReaderQuotas;

            }
            else if (encoding is MtomMessageEncodingBindingElement)
            {
                messageEncoding = WSMessageEncoding.Mtom;
                MtomMessageEncodingBindingElement mtom = (MtomMessageEncodingBindingElement)encoding;
                this.TextEncoding = mtom.WriteEncoding;
                this.ReaderQuotas = mtom.ReaderQuotas;
            }
            this.TransactionFlow = txFlow.Transactions;
            this.reliableSession.Enabled = session != null;

            //session
            if (session != null)
            {
                // only set properties that have standard binding manifestations
                this.session.InactivityTimeout = session.InactivityTimeout;
                this.session.Ordered = session.Ordered;
            }
        }
        // check that properties of the HttpTransportBindingElement and 
        // MessageEncodingBindingElement not exposed as properties on BasicHttpBinding 
        // match default values of the binding elements
        bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session)
        {

            if (!this.GetTransport().IsMatch(transport))
                return false;
            if (this.MessageEncoding == WSMessageEncoding.Text)
            {
                if (!this.textEncoding.IsMatch(encoding))
                    return false;
            }
            else if (this.MessageEncoding == WSMessageEncoding.Mtom)
            {
                if (!this.mtomEncoding.IsMatch(encoding))
                    return false;
            }
            if (!this.txFlow.IsMatch(txFlow))
                return false;

            if (reliableSession.Enabled)
            {
                if (!this.session.IsMatch(session))
                    return false;
            }
            else if (session != null)
            {
                return false;
            }

            return true;
        }
 private void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding)
 {
     this.BypassProxyOnLocal = transport.BypassProxyOnLocal;
     this.HostNameComparisonMode = transport.HostNameComparisonMode;
     this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
     this.MaxBufferSize = transport.MaxBufferSize;
     this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
     this.ProxyAddress = transport.ProxyAddress;
     this.TransferMode = transport.TransferMode;
     this.UseDefaultWebProxy = transport.UseDefaultWebProxy;
     this.Security.Transport.ExtendedProtectionPolicy = transport.ExtendedProtectionPolicy;
     if (encoding is TextMessageEncodingBindingElement)
     {
         this.MessageEncoding = WSMessageEncoding.Text;
         TextMessageEncodingBindingElement element = (TextMessageEncodingBindingElement) encoding;
         this.TextEncoding = element.WriteEncoding;
         this.ReaderQuotas = element.ReaderQuotas;
     }
     else if (encoding is MtomMessageEncodingBindingElement)
     {
         this.messageEncoding = WSMessageEncoding.Mtom;
         MtomMessageEncodingBindingElement element2 = (MtomMessageEncodingBindingElement) encoding;
         this.TextEncoding = element2.WriteEncoding;
         this.ReaderQuotas = element2.ReaderQuotas;
     }
 }
		public MessageEncodingBindingElement (MessageEncodingBindingElement source)
		{
			MessageVersion = source.MessageVersion;
		}
 public FileTransportBinding()
 {
     this.messageElement = new TextMessageEncodingBindingElement();
     this.transportElement = new FileTransportBindingElement();
 }