Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.ServiceModel;
- using System.ServiceModel.Description;
- using System.Text;
- using System.Threading.Tasks;
- using WcfServiceLibrary1;
- using WcfServiceLibrary2;
- namespace host
- {
- class Program
- {
- static void Main(string[] args)
- {
- Uri baseAddress1 = new Uri("http://localhost:10010/MyBaseName/endpoint1");
- ServiceHost myHost1 = new ServiceHost(typeof(myCCalculator), baseAddress1);
- Uri baseAddress2 = new Uri("http://localhost:20010/MyBaseName/endpoint2");
- ServiceHost myHost2 = new ServiceHost(typeof(myCallbackKalkulator), baseAddress2);
- WSDualHttpBinding myBanding2 = new WSDualHttpBinding();
- try
- {
- // Add the endpoint
- // BasicHttpBinding myBinding = new BasicHttpBinding();
- // myHost1.AddServiceEndpoint(typeof(ICCalculator), myBinding, "endpoint1");
- ServiceEndpoint endpoint1 =
- myHost1.AddServiceEndpoint(typeof(ICCalculator), new BasicHttpBinding(), baseAddress1);
- ServiceEndpoint endpoint2 =
- myHost2.AddServiceEndpoint(typeof(ICallbackKalkulator), myBanding2, "CallbackKalkulator");
- // Metadata:
- ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
- smb.HttpGetEnabled = true;
- myHost1.Description.Behaviors.Add(smb);
- ServiceMetadataBehavior smb2 = new ServiceMetadataBehavior();
- smb2.HttpGetEnabled = true;
- myHost2.Description.Behaviors.Add(smb2);
- myHost1.Open();
- myHost2.Open();
- Console.WriteLine("--->CCalculator is running.");
- Console.WriteLine("--->CallbackKalkulator is running.");
- Console.WriteLine("--->Press <ENTER> to stop.\n");
- Console.ReadLine(); // wait for stop
- myHost1.Close();
- myHost2.Close();
- Console.WriteLine("---> Service finished work.");
- }
- catch (CommunicationException ce)
- {
- Console.WriteLine("Exception occurred: {0}", ce.Message);
- myHost1.Abort();
- myHost2.Abort();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement