当前位置: 首页>>代码示例>>C#>>正文


C# HttpTransportBindingElement.BuildChannelFactory方法代码示例

本文整理汇总了C#中HttpTransportBindingElement.BuildChannelFactory方法的典型用法代码示例。如果您正苦于以下问题:C# HttpTransportBindingElement.BuildChannelFactory方法的具体用法?C# HttpTransportBindingElement.BuildChannelFactory怎么用?C# HttpTransportBindingElement.BuildChannelFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpTransportBindingElement的用法示例。


在下文中一共展示了HttpTransportBindingElement.BuildChannelFactory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

	public static void Main ()
	{
		HttpTransportBindingElement el =
			new HttpTransportBindingElement ();
		IChannelFactory<IRequestChannel> factory =
			el.BuildChannelFactory<IRequestChannel> (
				new BindingContext (new CustomBinding (),
					new BindingParameterCollection ()));

		factory.Open ();

		IRequestChannel request = factory.CreateChannel (
			new EndpointAddress ("http://localhost:37564"));

		request.Open ();

		using (XmlWriter w = XmlWriter.Create (Console.Out)) {
			Message.CreateMessage (MessageVersion.Default, "Echo")
				.WriteMessage (w);
		}
		Console.WriteLine ();

		Message msg = request.Request (
			Message.CreateMessage (MessageVersion.Default, "Echo"),
			TimeSpan.FromSeconds (15));
		using (XmlWriter w = XmlWriter.Create (Console.Out)) {
			msg.WriteMessage (w);
		}
	}
开发者ID:alesliehughes,项目名称:olive,代码行数:29,代码来源:request.cs

示例2: Main

	public static void Main ()
	{
		HttpTransportBindingElement el =
			new HttpTransportBindingElement ();
		IChannelListener<IReplyChannel> listener =
			el.BuildChannelListener<IReplyChannel> (
				new BindingContext (new CustomBinding (),
					new BindingParameterCollection (),
					new Uri ("http://localhost:37564"),
					String.Empty, ListenUriMode.Explicit));
		IChannelFactory<IRequestChannel> factory =
			el.BuildChannelFactory<IRequestChannel> (
				new BindingContext (new CustomBinding (),
					new BindingParameterCollection ()));

		listener.Open ();
		factory.Open ();

		IRequestChannel request = factory.CreateChannel (
			new EndpointAddress ("http://localhost:37564"));
		IReplyChannel reply = listener.AcceptChannel ();

		reply.Open ();
		request.Open ();

		new Thread (delegate () { try { RunListener (reply); } catch (Exception ex) { Console.WriteLine (ex); } }).Start ();
		Message msg = request.Request (Message.CreateMessage (
			MessageVersion.Default, "Echo"), TimeSpan.FromSeconds (15));
		XmlWriterSettings settings = new XmlWriterSettings ();
		settings.OmitXmlDeclaration = true;
		StringWriter sw = new StringWriter ();
		using (XmlWriter w = XmlWriter.Create (sw, settings)) {
			msg.WriteMessage (w);
		}
		Console.WriteLine (sw);
	}
开发者ID:alesliehughes,项目名称:olive,代码行数:36,代码来源:self-request-reply.cs

示例3: LowLevelHttpConnection

		// It is almost identical to http-low-level-binding
		public void LowLevelHttpConnection ()
		{
			HttpTransportBindingElement lel =
				new HttpTransportBindingElement ();

			// Service
			BindingContext lbc = new BindingContext (
				new CustomBinding (),
				new BindingParameterCollection (),
				new Uri ("http://localhost:37564"),
				String.Empty, ListenUriMode.Explicit);
			listener = lel.BuildChannelListener<IReplyChannel> (lbc);

			try {

			listener.Open ();

			svcret = "";

			Thread svc = new Thread (delegate () {
				try {
					svcret = LowLevelHttpConnection_SetupService ();
				} catch (Exception ex) {
					svcret = ex.ToString ();
				}
			});
			svc.Start ();

			// Client code goes here.

			HttpTransportBindingElement el =
				new HttpTransportBindingElement ();
			BindingContext ctx = new BindingContext (
				new CustomBinding (),
				new BindingParameterCollection ());
			IChannelFactory<IRequestChannel> factory =
				el.BuildChannelFactory<IRequestChannel> (ctx);

			factory.Open ();

			IRequestChannel request = factory.CreateChannel (
				new EndpointAddress ("http://localhost:37564"));

			request.Open ();

			try {
			try {
				Message reqmsg = Message.CreateMessage (
					MessageVersion.Default, "Echo");
				// sync version does not work here.
				Message msg = request.Request (reqmsg, TimeSpan.FromSeconds (5));

				using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
					msg.WriteMessage (w);
				}

				if (svcret != null)
					Assert.Fail (svcret.Length > 0 ? svcret : "service code did not finish until this test expected.");
			} finally {
				if (request.State == CommunicationState.Opened)
					request.Close ();
			}
			} finally {
				if (factory.State == CommunicationState.Opened)
					factory.Close ();
			}
			} finally {
				if (listener.State == CommunicationState.Opened)
					listener.Close ();
			}
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:72,代码来源:HttpTransportBindingElementTest.cs

示例4: GetChannelManagerBase

 public static ChannelManagerBase GetChannelManagerBase()
 {
     HttpTransportBindingElement httpBE = new HttpTransportBindingElement();
     CustomBinding binding = new CustomBinding(httpBE);
     return (ChannelManagerBase)httpBE.BuildChannelFactory<IRequestChannel>(new BindingContext(binding, new BindingParameterCollection()));
 }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:6,代码来源:Mocks.cs

示例5: ConsumeBindingElements

		// Now this test is mostly useless ...
		public void ConsumeBindingElements ()
		{
			BindingContext ctx = new BindingContext (
				new CustomBinding (
					new TextMessageEncodingBindingElement (),
					new HttpTransportBindingElement ()),
				new BindingParameterCollection ());

			HttpTransportBindingElement be =
				new HttpTransportBindingElement ();
			be.BuildChannelFactory<IRequestChannel> (ctx);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:BindingContextTest.cs


注:本文中的HttpTransportBindingElement.BuildChannelFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。