本文整理匯總了C#中System.ServiceModel.ChannelFactory.Open方法的典型用法代碼示例。如果您正苦於以下問題:C# ChannelFactory.Open方法的具體用法?C# ChannelFactory.Open怎麽用?C# ChannelFactory.Open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.ServiceModel.ChannelFactory
的用法示例。
在下文中一共展示了ChannelFactory.Open方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Send
public static void Send(Pager model)
{
if (model.To == null || string.IsNullOrWhiteSpace(model.Message)) return;
using (model.Modifier(x => x.Message))
{
Message message = new Message
{
CreatedTime = DateTime.Now,
From = From,
To = model.To,
ContentAsText = model.Message
};
model.Message = string.Empty;
model.History.Add(message) ;
m_history.Add(message);
using (var factory = new ChannelFactory<IMessageHost>(new BasicHttpBinding(), message.To.Uri))
{
factory.Open();
factory.CreateChannel().Send(new Request<Message>(message));
}
}
}
示例2: EncodeDecodeWithSecureWcf
// This test sets a secure service that user our custom encoder/decoder.
// the service actually modifies the property after deserializing it to simulate what
// a forwarder/gateway/proxy might do.
void EncodeDecodeWithSecureWcf()
{
Binding binding = WcfHelpers.CreateCustomSecureBinding();
string address = "net.tcp://localhost:8080";
ServiceHost host = new ServiceHost(new Service(), new Uri(address));
host.AddServiceEndpoint(typeof(IService1), binding, address);
host.Open();
ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
factory.Open();
IService1 proxy = factory.CreateChannel();
((IChannel)proxy).Open();
Message msg = WcfHelpers.CreateMessage();
string originalPayloadValue = Guid.NewGuid().ToString();
WcfHelpers.AddOutOfBandPropertyToMessage(originalPayloadValue, msg);
Message outputMsg = proxy.Operation(msg);
Console.WriteLine("\nEncoding with secure WCF");
ValidateResult(originalPayloadValue, outputMsg, Service.TransportModifier);
((IChannel)proxy).Close();
host.Close();
}
示例3: ImitatorServiceFactory
public ImitatorServiceFactory()
{
var binding = BindingHelper.CreateBindingFromAddress("net.pipe://127.0.0.1/GKImitator/");
var endpointAddress = new EndpointAddress(new Uri("net.pipe://127.0.0.1/GKImitator/"));
_channelFactory = new ChannelFactory<IImitatorService>(binding, endpointAddress);
_channelFactory.Open();
}
示例4: DoCreate
IFS2Contract DoCreate(string serverAddress)
{
if (serverAddress.StartsWith("net.pipe:"))
{
if (!FS2LoadHelper.Load())
BalloonHelper.ShowFromFiresec("Не удается соединиться с агентом 2");
}
var binding = BindingHelper.CreateBindingFromAddress(serverAddress);
var endpointAddress = new EndpointAddress(new Uri(serverAddress));
ChannelFactory = new ChannelFactory<IFS2Contract>(binding, endpointAddress);
foreach (OperationDescription operationDescription in ChannelFactory.Endpoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractSerializerOperationBehavior = operationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
if (dataContractSerializerOperationBehavior != null)
dataContractSerializerOperationBehavior.MaxItemsInObjectGraph = Int32.MaxValue;
}
ChannelFactory.Open();
IFS2Contract firesecService = ChannelFactory.CreateChannel();
(firesecService as IContextChannel).OperationTimeout = TimeSpan.FromMinutes(10);
return firesecService;
}
示例5: CreateInstance
public static ChannelItem CreateInstance(BasicHttpBinding bind, EndpointAddress address)
{
ChannelFactory<IFICService> factory = new ChannelFactory<IFICService>(bind, address);
factory.Open();
IFICService service = factory.CreateChannel();
return ((service == null) ? null : new ChannelItem(service));
}
示例6: joinTopicsManager
private static void joinTopicsManager(string username)
{
ChannelFactory<TopicsManager> dupFactory = null;
TopicsManager clientProxy = null;
dupFactory = new ChannelFactory<TopicsManager>(
new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/TopicManager"));
dupFactory.Open();
clientProxy = dupFactory.CreateChannel();
while (true)
{
Console.WriteLine("************TOPICS MANAGER************");
Console.WriteLine("Liste des rooms diponibles : ");
List<string> list = clientProxy.listTopics();
foreach (var t in list)
{
Console.WriteLine(t);
}
Console.WriteLine("1. Se connecter a une room \n2.Créer un nouveau chatroom");
switch (Console.ReadLine())
{
case "1":
Console.WriteLine("Entrez le nom de la room");
joinChatroom(clientProxy.joinTopic(Console.ReadLine()), username);
break;
case "2":
Console.WriteLine("Entrez le nom de la room");
clientProxy.createTopic(Console.ReadLine());
break;
}
}
}
示例7: button1_Click
private void button1_Click(object sender, EventArgs e)
{
string page = textBox1.Text;
try
{
EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:2137/Server"));
NetTcpBinding binding = new NetTcpBinding();
binding.MaxBufferPoolSize = 4 * 128 * 1024 * 1024;
binding.MaxBufferSize = 128 * 1024 * 1024;
binding.MaxReceivedMessageSize = 128 * 1024 * 1024;
ChannelFactory<IPictureService> fac = new ChannelFactory<IPictureService>(binding, address);
fac.Open();
var svc = fac.CreateChannel();
MessageBox.Show(svc.TextMe("World"));
Picture pic = svc.DownloadPicture(page);
Bitmap bmp = pic.GetBitmap();
pictureBox1.Image = new Bitmap(bmp, new Size(bmp.Width < 894 ? bmp.Width : 894, bmp.Height < 542 ? bmp.Height : 542));
}
catch (EndpointNotFoundException ex)
{
MessageBox.Show("Brak połączenia z serwerem.\n\n" + ex.Message.ToString());
}
}
示例8: Main
static void Main(string[] args)
{
// allow server certificate that doesn't match the host in the endpoint address
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreSubjectNameMismatch);
string uri = "https://" + Environment.MachineName + ":8443/TestService/BinaryEncoderOverHTTPS";
if (args.Length > 0)
{
uri = args[0];
}
EndpointAddress address = new EndpointAddress(uri);
NetHttpBinding binding = new NetHttpBinding();
ChannelFactory<IEchoService> factory = new ChannelFactory<IEchoService>(binding, address);
factory.Open();
IEchoService service = factory.CreateChannel();
Console.WriteLine(service.Echo(new string('a', 1024)));
Console.WriteLine("called service successfully using binding in code");
factory = new ChannelFactory<IEchoService>("EchoServer");
factory.Open();
service = factory.CreateChannel();
Console.WriteLine(service.Echo(new string('b', 1024)));
Console.WriteLine("called service successfully using binding from config. Press enter to exit...");
Console.ReadLine();
}
示例9: AuthForm
public AuthForm()
{
InitializeComponent();
ChannelFactory<AuthentificationManager> dupFactory = null;
dupFactory = new ChannelFactory<AuthentificationManager>(
new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8999/AuthManager"));
dupFactory.Open();
clientProxy = dupFactory.CreateChannel();
}
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
ChannelFactory<SampleServer.ICalcService> factory = new ChannelFactory<SampleServer.ICalcService>("CustomBinding_ICalcService");
factory.Open();
SampleServer.ICalcService channel = factory.CreateChannel();
string result = channel.SetValue(int.Parse(textBox1.Text));
factory.Close();
MessageBox.Show(result);
}
示例11: Configure
public static void Configure()
{
try
{
PubilcyInfoProxy = new ChannelFactory<IPubilcyInfo>("BindingIPubilcyInfoService");
PubilcyInfoProxy.Open();
}
catch (Exception ex)
{
Log4netHelper.Logger.Fatal(ex);
}
}
示例12: Main
static void Main(string[] args)
{
EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/demoservice");
Binding binding = new WebHttpBinding();
ContractDescription contract = ContractDescription.GetContract(typeof(IContract));
ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, address);
using (ChannelFactory<IContract> channelFactory = new ChannelFactory<IContract>(endpoint))
{
channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());
channelFactory.Open();
}
}
示例13: OnBrowserCreated
public override void OnBrowserCreated(CefBrowserWrapper browser)
{
browsers.Add(browser);
if (parentBrowserId == null)
{
parentBrowserId = browser.BrowserId;
}
if (ParentProcessId == null || parentBrowserId == null)
{
return;
}
var browserId = browser.IsPopup ? parentBrowserId.Value : browser.BrowserId;
var serviceName = RenderprocessClientFactory.GetServiceName(ParentProcessId.Value, browserId);
var binding = BrowserProcessServiceHost.CreateBinding();
var channelFactory = new ChannelFactory<IBrowserProcess>(
binding,
new EndpointAddress(serviceName)
);
channelFactory.Open();
var browserProcess = channelFactory.CreateChannel();
var clientChannel = ((IClientChannel)browserProcess);
try
{
clientChannel.Open();
if (!browser.IsPopup)
{
browserProcess.Connect();
}
var javascriptObject = browserProcess.GetRegisteredJavascriptObjects();
if (javascriptObject.MemberObjects.Count > 0)
{
browser.JavascriptRootObject = javascriptObject;
}
browser.ChannelFactory = channelFactory;
browser.BrowserProcess = browserProcess;
}
catch(Exception)
{
}
}
示例14: Main
static void Main(string[] args)
{
Console.WriteLine("Connecting to service.");
using (var channelFactory = new ChannelFactory<INetTcpService>("NetTcpBinding_IService1"))
{
channelFactory.Open();
var client = channelFactory.CreateChannel();
//The line below will throw an exception if .NET 4.6 is installed, works fine with 4.5.x
string result = client.SayHello(Environment.UserName);
Console.WriteLine("Recieved response, '{0}'", result);
}
Console.ReadLine();
}
示例15: ClientForm_Load
void ClientForm_Load(object sender, EventArgs e)
{
string serviceUrl = "net.tcp://localhost:65500/Communicate";
NetTcpBinding ntb = new NetTcpBinding();
ntb.TransactionFlow = false;
ntb.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
ntb.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
ntb.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
ntb.Security.Mode = SecurityMode.Transport;
f = new ChannelFactory<ICommunicate>(ntb, serviceUrl);
f.Credentials.Windows.ClientCredential.UserName = "michael";
f.Credentials.Windows.ClientCredential.Password = "k:;1n";
f.Open();
}