Jestem zielony, jeżeli chodzi o SOAP. Chcę odczytać dane, które podaje
serwer SOAP. Serwer działa w sieci lokalnej na Windows Server 2008 (jest
IIS, MS SQL). Niech będzie, że pod adresem:
http://mydataserver/soapserver dostępna jest ta usługa. Pod adresem
http://mydataserver/soapserver/soapbrowser mam taką prostą przeglądarkę
danych dostarczoną przez producenta. Dostęp do niej wymaga zalogowania,
tu wszystko działa, więc serwer na pewno odpowiada.
W Delphi (XE2, Windows 7 64 Bit) importuje do projektu plik WSDL z
serwera (
http://mydataserver/soapserver/soapserver.wsdl). Jest dosyć
pokaźny, fragmenty tego, co istotne są poniżej. Zestaw danych, które
chcę pobierać to obiekt klasy ITypeDataSet1Title. Do obsługi tych danych
mam interface SoapDataSet1LibrarySoapPort.
type
ITypeDataSet1Title = class(TRemotable)
private
function GetID: Integer;
procedure SetID(Value: Integer);
public
destructor Destroy; override;
published
property Id: Integer read GetId write SetId;
// inne własności
end;
SoapDataSet1LibrarySoapPort = interface(IInvokable)
['{7BB8B4B4-641E-0D31-BCC7-22BA9482F755}']
procedure Get(var pIType: ITypeDataSet1Title); stdcall;
procedure Update(var pIType: ITypeDataSet1Title); stdcall;
procedure Insert(var pIType: ITypeDataSet1Title); stdcall;
procedure Delete(const pIType: ITypeDataSet1Title); stdcall;
end;
function GetSoapDataSet1LibrarySoapPort(UseWSDL: Boolean; Addr: string;
HTTPRIO: THTTPRIO): SoapDataSet1LibrarySoapPort;
const
defWSDL = '
http://mydataserver/soapserver/soapserver.wsdl';
defURL = '
http://localhost:8080/soapserver/SoapServer.WSDL';
defSvc = 'SoapServer';
defPrt = 'SoapDataSet1LibrarySoapPort';
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 SoapDataSet1LibrarySoapPort);
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;
Odpowiednie InvRegistry.RegisterInterface,
InvRegistry.RegisterDefaultSOAPAction, InvRegistry.RegisterMethodInfo
itd. są w initialization.
Serwer wymaga logowania, ja chcę odebrać dane typu ITypeDataSet1Title.
Podpowie mi ktoś jak to zrobić? To, co wygoogle'ałem to przykłady, w
których wyglądało to stokroć prościej, żadnego logowania... No i
niewiele mi to pomogło. To, czego próbowałem nie będę wpisywał, bo
obciach ;)
jh