Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Delphi [игнор отключен] [закрыт для гостей] / WebService - не получается залогиниться / 7 сообщений из 7, страница 1 из 1
16.06.2018, 12:42
    #39661542
novtoxa
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
Есть задача. Надо залогиниться на WebSepvice и залить данные. На сервисе есть функции, произвёл их импорт и получил:

Код: pascal
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.
unit webservice;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Borland types; however, they could also
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:string          - "http://www.w3.org/2001/XMLSchema"
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"
  // !:int             - "http://www.w3.org/2001/XMLSchema"


  string_         =  type WideString;      { "http://tempuri.org/" }

  // ************************************************************************ //
  // Namespace : http://tempuri.org/
  // soapAction: http://tempuri.org/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // binding   : WebServiceSoap
  // service   : WebService
  // port      : WebServiceSoap
  // URL       : https://it.vod.kiev.ua:44/ws/webservice.asmx
  // ************************************************************************ //
  WebServiceSoap = interface(IInvokable)
  ['{F790808E-B4BF-D72D-D6C0-3B8652961A63}']
    function  LoginEx(const login: WideString; const password: WideString): WideString; stdcall;
    function  ExecuteEx(const calcId: WideString; const args: WideString; const ticket: WideString): WideString; stdcall;
  end;

function GetWebServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): WebServiceSoap;


implementation

function GetWebServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WebServiceSoap;
const
  defWSDL = 'https://it.vod.kiev.ua:44/ws/webservice.asmx?WSDL';
  defURL  = 'https://it.vod.kiev.ua:44/ws/webservice.asmx';
  defSvc  = 'WebService';
  defPrt  = 'WebServiceSoap';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as WebServiceSoap);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


initialization
  InvRegistry.RegisterInterface(TypeInfo(WebServiceSoap), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WebServiceSoap), 'http://tempuri.org/%operationName%');
  RemClassRegistry.RegisterXSInfo(TypeInfo(string_), 'http://tempuri.org/', 'string_', 'string');

end.



Вызываю функцию LoginEx таким образом:

Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
procedure TForm1.Button1Click(Sender: TObject);
Var
  str: String;
  soap: WebServiceSoap;
begin
soap:= GetWebServiceSoap(False,'',HTTPRIO1);
str:= soap.LoginEx ('логин', 'пароль');
showmessage(str);
end;



Получаю такой ответ:

{"Success":false,"Id":null,"UserName":null,"Ticket":null,"FailReason":null,"NeedChangePassword":false,"TempPasswordRequired":false,"TempPasswordMessage":null}

Т.е. не залогинился. Такое впечатление, что сервис не прочёл логин и пароль! Пробовал через браузер - всё работает! Не могу понять где ошибка!!!
...
Рейтинг: 0 / 0
16.06.2018, 13:22
    #39661549
novtoxa
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
Попробовал так:

Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
procedure TForm1.Button1Click(Sender: TObject);
Var
  str: String;
  soap: WebServiceSoap;
  Login, Password: WideString;
begin
Login:= 'novtoxa';
Password:= 'mDjDa6xLjR';
soap:= HTTPRIO1 as WebServiceSoap;
str:= soap.LoginEx (Login, Password);
Edit1.Text:= str;
end;



Результат тот-же!
...
Рейтинг: 0 / 0
16.06.2018, 14:20
    #39661557
X-Cite
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
Версия Delphi какая?
...
Рейтинг: 0 / 0
16.06.2018, 15:12
    #39661559
novtoxa
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
Delphi 7
...
Рейтинг: 0 / 0
16.06.2018, 17:00
    #39661576
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
novtoxa! Пробовал через браузер - всё работает! Не могу понять где ошибка!!!Ставьте сниффер и сравнивайте паакеты
...
Рейтинг: 0 / 0
16.06.2018, 20:24
    #39661603
X-Cite
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
novtoxaDelphi 7
не уверен, но у вас 'utf-8' требуется.. я не в курсе умеет ли 7-ка soap пакеты в этой кодировке отдавать
...
Рейтинг: 0 / 0
16.06.2018, 21:01
    #39661605
SOFT FOR YOU
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
WebService - не получается залогиниться
X-Cite,

А какая разница, он же в латинице передаёт?
...
Рейтинг: 0 / 0
Форумы / Delphi [игнор отключен] [закрыт для гостей] / WebService - не получается залогиниться / 7 сообщений из 7, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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