Exemplo n.º 1
0
        private static void GetDefault()
        {
            ServiceReferenceDefault.ServiceContractClient proxy = new ServiceContractClient();

            var data = proxy.GetByName("Usuario");

            proxy.Close();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            OperaCallback         ock     = new OperaCallback();
            var                   context = new InstanceContext(ock);
            ServiceContractClient scc     = new ServiceContractClient(context);

            scc.Open();
            scc.InnerChannel.Faulted       += InnerDuplexChannel_Faulted;
            scc.InnerDuplexChannel.Faulted += InnerDuplexChannel_Faulted1;

            scc.Hook();

            bool   success = scc.Operator();
            string str;

            try
            {
                str = scc.ReturnString();
            }
            catch (CommunicationException ce)
            {
                str = ce.Message;
                scc.Abort();
                scc = new ServiceContractClient(context);
                scc.Open();
                //scc.Close();
                //scc.Open();
                //Console.WriteLine(ce.Message);
            }
            OpRequest request = new OpRequest();

            request.part = new Part()
            {
                Name = "abb", Id = 20
            };
            string name = scc.Send(request);

            Console.WriteLine("suc " + success.ToString());
            Console.WriteLine(str);
            Console.WriteLine(name);
            if (scc.State != CommunicationState.Faulted)
            {
                scc.Close();
            }
            else
            {
                scc.Abort();
            }

            Console.ReadLine();
        }