コード例 #1
0
        public ReverseWebProxy(Uri upstreamUri, Uri downstreamUri, TransportClientEndpointBehavior credentials)
        {
            this.upstreamUri = upstreamUri;
            this.downstreamUri = downstreamUri;

            this.upstreamBasePath = this.upstreamUri.PathAndQuery;
            if (this.upstreamBasePath.EndsWith("/"))
            {
                this.upstreamBasePath = this.upstreamBasePath.Substring(0, this.upstreamBasePath.Length - 1);
            }

            ServicePointManager.DefaultConnectionLimit = 50;

            WebHttpRelayBinding relayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);
            relayBinding.MaxReceivedMessageSize = int.MaxValue;
            relayBinding.TransferMode = TransferMode.Streamed;
            relayBinding.AllowCookies = false;
            relayBinding.ReceiveTimeout = TimeSpan.MaxValue;
            relayBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            relayBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            this.upstreamBinding = relayBinding;

            WebMessageEncodingBindingElement encoderBindingElement = new WebMessageEncodingBindingElement();
            encoderBindingElement.ReaderQuotas.MaxArrayLength = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            encoderBindingElement.ContentTypeMapper = new RawContentTypeMapper();
            encoder = encoderBindingElement.CreateMessageEncoderFactory().Encoder;

            this.credentials = credentials;
        }
コード例 #2
0
        public void MessageFormatterSupportsRaw()
        {
            // serializing reply
            var ms    = new MemoryStream();
            var bytes = new byte [] { 0, 1, 2, 0xFF };

            ms.Write(bytes, 0, bytes.Length);
            ms.Position = 0;
            var cd        = ContractDescription.GetContract(typeof(ITestService));
            var od        = cd.Operations [0];
            var se        = new ServiceEndpoint(cd, new WebHttpBinding(), new EndpointAddress("http://localhost:37564/"));
            var formatter = new WebHttpBehaviorExt().DoGetReplyDispatchFormatter(od, se);

            var msg = formatter.SerializeReply(MessageVersion.None, null, ms);
            var wp  = msg.Properties ["WebBodyFormatMessageProperty"] as WebBodyFormatMessageProperty;

            Assert.IsNotNull(wp, "#1");
            Assert.AreEqual(WebContentFormat.Raw, wp.Format, "#2");

            var wmebe = new WebMessageEncodingBindingElement();
            var wme   = wmebe.CreateMessageEncoderFactory().Encoder;
            var ms2   = new MemoryStream();

            wme.WriteMessage(msg, ms2);
            Assert.AreEqual(bytes, ms2.ToArray(), "#3");
        }
コード例 #3
0
        public AzureProxyHandler(Uri requestUrl, Uri responseUrl)
        {
            _credentials = new TransportClientEndpointBehavior {
                CredentialType = TransportClientCredentialType.SharedSecret
            };
            _credentials.Credentials.SharedSecret.IssuerName   = Manager.Configuration.Azure.IssuerName;
            _credentials.Credentials.SharedSecret.IssuerSecret = Manager.Configuration.Azure.IssuerSecret;

            Init(requestUrl, responseUrl);

            ServicePointManager.DefaultConnectionLimit = 50;

            _requestBinding = new BasicHttpRelayBinding(EndToEndBasicHttpSecurityMode.None, RelayClientAuthenticationType.None);
            _requestBinding.MaxReceivedMessageSize              = int.MaxValue;
            _requestBinding.TransferMode                        = TransferMode.Streamed;
            _requestBinding.AllowCookies                        = false;
            _requestBinding.ReceiveTimeout                      = TimeSpan.MaxValue;
            _requestBinding.ReaderQuotas.MaxArrayLength         = int.MaxValue;
            _requestBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            _requestBinding.MaxReceivedMessageSize              = int.MaxValue;
            _requestBinding.MaxBufferSize                       = 4 * 1024 * 1024;
            _requestBinding.MaxBufferPoolSize                   = 32 * 4 * 1024 * 1024;

            WebMessageEncodingBindingElement encoderBindingElement = new WebMessageEncodingBindingElement();

            encoderBindingElement.ReaderQuotas.MaxArrayLength         = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxDepth        = 128;
            encoderBindingElement.ReaderQuotas.MaxBytesPerRead = 65536;
            encoderBindingElement.ContentTypeMapper            = new RawContentTypeMapper();
            _webEncoder = encoderBindingElement.CreateMessageEncoderFactory().Encoder;
        }
コード例 #4
0
        public AzureProxyHandler(Uri requestUrl, Uri responseUrl)
        {
            _credentials = new TransportClientEndpointBehavior {
                CredentialType = TransportClientCredentialType.SharedSecret
            };
            _credentials.Credentials.SharedSecret.IssuerName = Manager.Configuration.Azure.IssuerName;
            _credentials.Credentials.SharedSecret.IssuerSecret = Manager.Configuration.Azure.IssuerSecret;

            Init(requestUrl, responseUrl);

            ServicePointManager.DefaultConnectionLimit = 50;

            _requestBinding = new BasicHttpRelayBinding(EndToEndBasicHttpSecurityMode.None, RelayClientAuthenticationType.None);
            _requestBinding.MaxReceivedMessageSize = int.MaxValue;
            _requestBinding.TransferMode = TransferMode.Streamed;
            _requestBinding.AllowCookies = false;
            _requestBinding.ReceiveTimeout = TimeSpan.MaxValue;
            _requestBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            _requestBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            _requestBinding.MaxReceivedMessageSize = int.MaxValue;
            _requestBinding.MaxBufferSize = 4 * 1024 * 1024;
            _requestBinding.MaxBufferPoolSize = 32 * 4 * 1024 * 1024;

            WebMessageEncodingBindingElement encoderBindingElement = new WebMessageEncodingBindingElement();
            encoderBindingElement.ReaderQuotas.MaxArrayLength = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxDepth = 128;
            encoderBindingElement.ReaderQuotas.MaxBytesPerRead = 65536;
            encoderBindingElement.ContentTypeMapper = new RawContentTypeMapper();
            _webEncoder = encoderBindingElement.CreateMessageEncoderFactory().Encoder;
        }
コード例 #5
0
        public void MessageFormatterSupportsRaw2()
        {
            // deserializing request
            var ms = new MemoryStream();

            ms.Write(new byte [] { 0, 1, 2, 0xFF }, 0, 4);
            ms.Position = 0;
            var cd        = ContractDescription.GetContract(typeof(ITestService));
            var od        = cd.Operations [0];
            var se        = new ServiceEndpoint(cd, new WebHttpBinding(), new EndpointAddress("http://localhost:8080/"));
            var wmebe     = new WebMessageEncodingBindingElement();
            var wme       = wmebe.CreateMessageEncoderFactory().Encoder;
            var msg       = wme.ReadMessage(ms, 100, null); // "application/xml" causes error.
            var formatter = new WebHttpBehaviorExt().DoGetRequestDispatchFormatter(od, se);

            object [] pars = new object [1];
            formatter.DeserializeRequest(msg, pars);
            Assert.IsTrue(pars [0] is Stream, "ret");
        }
コード例 #6
0
        MessageEncoder CreateEncoder()
        {
            WebMessageEncodingBindingElement m = new WebMessageEncodingBindingElement();

            return(m.CreateMessageEncoderFactory().Encoder);
        }
コード例 #7
0
		MessageEncoder CreateEncoder ()
		{
			WebMessageEncodingBindingElement m = new WebMessageEncodingBindingElement ();
			return m.CreateMessageEncoderFactory ().Encoder;
		}
コード例 #8
0
 public JSONPEncoder()
 {
     WebMessageEncodingBindingElement element = new WebMessageEncodingBindingElement();
     encoder = element.CreateMessageEncoderFactory().Encoder;
 }
コード例 #9
0
            public JSONPEncoder()
            {
                WebMessageEncodingBindingElement element = new WebMessageEncodingBindingElement();

                encoder = element.CreateMessageEncoderFactory().Encoder;
            }
コード例 #10
0
ファイル: WebHttpBehaviorTest.cs プロジェクト: carrie901/mono
		public void MessageFormatterSupportsRaw2 ()
		{
			// deserializing request
			var ms = new MemoryStream ();
			ms.Write (new byte [] {0, 1, 2, 0xFF}, 0, 4);
			ms.Position = 0;
			var cd = ContractDescription.GetContract (typeof (ITestService));
			var od = cd.Operations [0];
			var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
			var wmebe = new WebMessageEncodingBindingElement ();
			var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
			var msg = wme.ReadMessage (ms, 100, null); // "application/xml" causes error.
			var formatter = new WebHttpBehaviorExt ().DoGetRequestDispatchFormatter (od, se);
			object [] pars = new object [1];
			formatter.DeserializeRequest (msg, pars);
			Assert.IsTrue (pars [0] is Stream, "ret");
		}
コード例 #11
0
ファイル: WebHttpBehaviorTest.cs プロジェクト: carrie901/mono
		public void MessageFormatterSupportsRaw ()
		{
			// serializing reply
			var ms = new MemoryStream ();
			var bytes = new byte [] {0, 1, 2, 0xFF};
			ms.Write (bytes, 0, bytes.Length);
			ms.Position = 0;
			var cd = ContractDescription.GetContract (typeof (ITestService));
			var od = cd.Operations [0];
			var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:37564/"));
			var formatter = new WebHttpBehaviorExt ().DoGetReplyDispatchFormatter (od, se);

			var msg = formatter.SerializeReply (MessageVersion.None, null, ms);
			var wp = msg.Properties ["WebBodyFormatMessageProperty"] as WebBodyFormatMessageProperty;
			Assert.IsNotNull (wp, "#1");
			Assert.AreEqual (WebContentFormat.Raw, wp.Format, "#2");

			var wmebe = new WebMessageEncodingBindingElement ();
			var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
			var ms2 = new MemoryStream ();
			wme.WriteMessage (msg, ms2);
			Assert.AreEqual (bytes, ms2.ToArray (), "#3");
		}