powered by simpleCommunicator - 2.0.48     © 2025 Programmizd 02
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Не работает служба WCF
2 сообщений из 2, страница 1 из 1
Не работает служба WCF
    #37809547
qfisher
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Подскажите пожалуйста почему не получаются данные,

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
[ServiceContract]
    public interface IService
    {
        [OperationContract]
        string GetName();
 
        [OperationContract]
        string GetIP();
 
    }
 
[ServiceContract]
    public interface IAuthService : IService
    {
        [OperationContract]
        string OpenSession(string login, string pass);
 
        [OperationContract]
        int CloseSession(string ssid);
 
        [OperationContract]
        List<ServiceItem> GetServices(string ssid);
 
    }
 
 
// класс реализации сервиса
class AuthService :  IAuthService, IServiceRegistration
    {
        public AuthService()
        {
            _name = "AuthService";
        }
 
        public string OpenSession(string login, string pass)
        {
            //todo : fill it
            return "NEW_SSID";
        }
        
        private bool _isRegistered;
        public bool isRegistered
        {
            get
            {
                return _isRegistered;
            }
        }
 
        public int CloseSession(string ssid)
        {
            return default(int);
        }
 
        public string GetIP()
        {
            // todo: fill it
            return "IP AuthService ";
        }
 
        private string _name;
        public string name
        {
            get
            {
                return _name;
            }
        }
 
        public string GetName()
        {
            return "_name";// _name;
        }
 
        public List<ServiceItem> GetServices(string ssid)
        {
            // todo: fill it
            return new List<ServiceItem>();
        }
 
        // ******************************************************************************************************
 
        private List<ServiceItem> services;
 
        public bool RegisterService(ServiceItem item)
        {
            // todo: fill it
            return true;
        }
 
        public bool UnRegisterService(ServiceItem item)
        {
            // todo: fill it
            return true;
        }
 
        public bool CheckSSID(string ssid)
        {
            // todo: fill it
            return true;
        }
 
    }
 
// клиент вызывающий службу
class Program
    {
        static void Main(string[] args)
        {
            string connect_string = @"http://192.168.0.4:5070/AuthService";
 
            Console.WriteLine("Start connection to AuthService ...");
 
            Uri tcpUri = new Uri(connect_string);
            EndpointAddress address = new EndpointAddress(tcpUri);
            BasicHttpBinding binding = new BasicHttpBinding();
            ChannelFactory<IAuthService> factory = new ChannelFactory<IAuthService>(binding, address);
            IAuthService auth_service = factory.CreateChannel();
 
            Console.WriteLine("AuthService is connected");
 
            string user = "user1";
            string pass = "pass1";
 
            // ***************************************************************
            string ssid = auth_service.OpenSession(user, pass);
            Console.WriteLine("ssid = " + ssid);
            string sss = auth_service.GetName();
            Console.WriteLine(sss);
 
            // ***************************************************************
 
            Console.WriteLine("Press 'Enter' if you want to stop connection to AuthService.");
            Console.ReadLine();
            factory.Close();
 
        }
    }



после запуска получается ssid, но string sss = auth_service.GetName(); - зависает, т.е. не ответа ни привета, после чего проходит минута и вылетает ошибка что таймаута не хватает.
...
Рейтинг: 0 / 0
Не работает служба WCF
    #37823907
Winnipuh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
1. а так?
// ***************************************************************
string sss = auth_service.GetName();
Console.WriteLine(sss);
string ssid = auth_service.OpenSession(user, pass);
Console.WriteLine("ssid = " + ssid);
// ***************************************************************

2. под дебаггером надо пустить и посмотреть
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Не работает служба WCF
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]