Exemplo n.º 1
0
        TestConsole()
        {
            CustomBinding binding = new CustomBinding();
            MtomMessageEncodingBindingElement mtomBindingElement = new MtomMessageEncodingBindingElement();

            mtomBindingElement.MessageVersion = MessageVersion.Soap11WSAddressingAugust2004;
            binding.Elements.Add(mtomBindingElement);
            binding.Elements.Add(new WseTcpTransportBindingElement());

            // WSE sample uses a logical endpoint. So we need to set the physical via separately.
            EndpointAddress address = new EndpointAddress("soap://stockservice.contoso.com/wse/samples/2003/06/TcpSyncStockService");

            // INSERT your HOSTNAME here:
            string hostname = "localhost";
            Uri    via      = new Uri(string.Format("soap.tcp://{0}/StockService", hostname));
            StockServicePortTypeClient client = new StockServicePortTypeClient(binding, address);

            client.Endpoint.Behaviors.Add(new ClientViaBehavior(via));
            Console.WriteLine("Calling {0}", client.Endpoint.Address.Uri.AbsoluteUri);

            StockQuoteRequest quoteRequest = new StockQuoteRequest();

            quoteRequest.symbols = new ArrayOfString();
            quoteRequest.symbols.Add("FABRIKAM");
            quoteRequest.symbols.Add("CONTOSO");
            StockQuotes stocks = client.GetStockQuotes(quoteRequest);

            foreach (StockQuote quote in stocks)
            {
                Console.WriteLine("");
                Console.WriteLine("Symbol: " + quote.Symbol);
                Console.WriteLine("\tName: " + quote.Name);
                Console.WriteLine("\tLast Price: " + quote.Last);
            }
            Console.WriteLine("Press enter.");
            Console.ReadLine();

            binding             = new CustomBinding(new WseTcpTransportBindingElement());
            this.uri            = new Uri("wse.tcp://localhost:9000/a/b/");
            this.channelFactory = binding.BuildChannelFactory <IDuplexSessionChannel>();
            this.listener       = binding.BuildChannelListener <IDuplexSessionChannel>(this.uri);
        }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     StockQuotes a = new StockQuotes();
     System.Console.Out.WriteLine(a.report(new string[]{}));
     System.Console.In.ReadLine();
     //
     // TODO: Add code to start application here
     //
 }