public void Initialize()
 {
     this._bufferManager = new PoxBufferManager();
     this._property = new DisposableProperty();
     PoxBinaryMessageEncodingBindingElement pox = new PoxBinaryMessageEncodingBindingElement();
     MessageEncoderFactory factory = pox.CreateMessageEncoderFactory();
     this._encoder = factory.Encoder;
     this._simpleMessageArray = this.GetMessageArray(this._simpleMessageString);
 }
Exemple #2
0
        public void Initialize()
        {
            this._bufferManager = new PoxBufferManager();
            this._property      = new DisposableProperty();
            PoxBinaryMessageEncodingBindingElement pox = new PoxBinaryMessageEncodingBindingElement();
            MessageEncoderFactory factory = pox.CreateMessageEncoderFactory();

            this._encoder            = factory.Encoder;
            this._simpleMessageArray = this.GetMessageArray(this._simpleMessageString);
        }
Exemple #3
0
        /// <summary>
        /// Creates an endpoint based on the specified address.
        /// </summary>
        /// <param name="contract">The endpoint's contract.</param>
        /// <param name="address">The endpoint's base address.</param>
        /// <returns>An endpoint.</returns>
        private ServiceEndpoint CreateEndpointForAddress(ContractDescription contract, Uri address)
        {
            PoxBinaryMessageEncodingBindingElement encoding = new PoxBinaryMessageEncodingBindingElement();

            ServiceUtility.SetReaderQuotas(encoding.ReaderQuotas);

            HttpTransportBindingElement transport;

            if (address.Scheme.Equals(Uri.UriSchemeHttps))
            {
                transport = new HttpsTransportBindingElement();
            }
            else
            {
                transport = new HttpTransportBindingElement();
            }
            transport.ManualAddressing       = true;
            transport.MaxReceivedMessageSize = ServiceUtility.MaxReceivedMessageSize;

            if (ServiceUtility.AuthenticationScheme != AuthenticationSchemes.None)
            {
                transport.AuthenticationScheme = ServiceUtility.AuthenticationScheme;
            }

            CustomBinding binding =
                new CustomBinding(
                    new BindingElement[]
            {
                encoding,
                transport
            });

            ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, new EndpointAddress(address.OriginalString + "/" + this.Name));

            endpoint.Behaviors.Add(new DomainServiceWebHttpBehavior()
            {
                DefaultBodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Wrapped
            });
            endpoint.Behaviors.Add(new SilverlightFaultBehavior());
            return(endpoint);
        }
        /// <summary>
        /// Creates an endpoint based on the specified address.
        /// </summary>
        /// <param name="contract">The endpoint's contract.</param>
        /// <param name="address">The endpoint's base address.</param>
        /// <returns>An endpoint.</returns>
        private ServiceEndpoint CreateEndpointForAddress(ContractDescription contract, Uri address)
        {
            PoxBinaryMessageEncodingBindingElement encoding = new PoxBinaryMessageEncodingBindingElement();
            ServiceUtility.SetReaderQuotas(encoding.ReaderQuotas);

            HttpTransportBindingElement transport;
            if (address.Scheme.Equals(Uri.UriSchemeHttps))
            {
                transport = new HttpsTransportBindingElement();
            }
            else
            {
                transport = new HttpTransportBindingElement();
            }
            transport.ManualAddressing = true;
            transport.MaxReceivedMessageSize = ServiceUtility.MaxReceivedMessageSize;

            if (ServiceUtility.AuthenticationScheme != AuthenticationSchemes.None)
            {
                transport.AuthenticationScheme = ServiceUtility.AuthenticationScheme;
            }

            CustomBinding binding =
                new CustomBinding(
                    new BindingElement[] 
                    {
                        encoding,
                        transport
                    });

            ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, new EndpointAddress(address.OriginalString + "/" + this.Name));
            endpoint.Behaviors.Add(new DomainServiceWebHttpBehavior()
            {
                DefaultBodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Wrapped
            });
            endpoint.Behaviors.Add(new SilverlightFaultBehavior());
            return endpoint;
        }
Exemple #5
0
        public void PoxBufferedMessage_GetReader()
        {
            PoxBinaryMessageEncodingBindingElement pox = new PoxBinaryMessageEncodingBindingElement();

            pox.ReaderQuotas.MaxArrayLength         = 1;
            pox.ReaderQuotas.MaxBytesPerRead        = 1;
            pox.ReaderQuotas.MaxDepth               = 1;
            pox.ReaderQuotas.MaxNameTableCharCount  = 1;
            pox.ReaderQuotas.MaxStringContentLength = 1;
            MessageEncoderFactory factory = pox.CreateMessageEncoderFactory();

            this._encoder = factory.Encoder;

            // Test that the XmlDictionaryReaderQuotas propagate to the XmlDictionaryReader.
            using (Message message = this.GetMessage())
                using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
                {
                    Assert.AreEqual(1, reader.Quotas.MaxArrayLength, "MaxArrayLength");
                    Assert.AreEqual(1, reader.Quotas.MaxBytesPerRead, "MaxBytesPerRead");
                    Assert.AreEqual(1, reader.Quotas.MaxDepth, "MaxDepth");
                    Assert.AreEqual(1, reader.Quotas.MaxNameTableCharCount, "MaxNameTableCharCount");
                    Assert.AreEqual(1, reader.Quotas.MaxStringContentLength, "MaxStringContentLength");
                }
        }
        public void PoxBufferedMessage_GetReader()
        {
            PoxBinaryMessageEncodingBindingElement pox = new PoxBinaryMessageEncodingBindingElement();
            pox.ReaderQuotas.MaxArrayLength = 1;
            pox.ReaderQuotas.MaxBytesPerRead = 1;
            pox.ReaderQuotas.MaxDepth = 1;
            pox.ReaderQuotas.MaxNameTableCharCount = 1;
            pox.ReaderQuotas.MaxStringContentLength = 1;
            MessageEncoderFactory factory = pox.CreateMessageEncoderFactory();
            this._encoder = factory.Encoder;

            // Test that the XmlDictionaryReaderQuotas propagate to the XmlDictionaryReader.
            using (Message message = this.GetMessage())
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                Assert.AreEqual(1, reader.Quotas.MaxArrayLength, "MaxArrayLength");
                Assert.AreEqual(1, reader.Quotas.MaxBytesPerRead, "MaxBytesPerRead");
                Assert.AreEqual(1, reader.Quotas.MaxDepth, "MaxDepth");
                Assert.AreEqual(1, reader.Quotas.MaxNameTableCharCount, "MaxNameTableCharCount");
                Assert.AreEqual(1, reader.Quotas.MaxStringContentLength, "MaxStringContentLength");
            }
        }