W dniu 2012-12-27 13:30, pawelgolo pisze:
> W dniu niedziela, 23 grudnia 2012 21:51:30 UTC+1 u�ytkownik yild napisa�:
>> W dniu 2012-12-23 15:58, inf-el pisze:
>
> Mogliby�cie podrzuci�, czy mieli�cie taki problem, a je�li tak to jak uda�o si� Wam go obej��. Xml wylogowuj�cy wygl�da, �e zwraca poprawn� infomacj�, ale co z tego skoro nie mog� si� zalogowa�..
>
te b��dy spowodowane s� niew�a�ciwym namespace w xmlu...
wersja d�uga (dzisiaj przerabialem z wersji dobeforeexecute i
doafterexecute na WebNode.Execute ;) ):
type
TAuthHTTPRIO = class(THttpRIO)
private
FTokenID: string;
FSessionID: string;
FErrorMsg: string;
FXML: TXMLInterface;
function PrzetwarzanieXML(const AXML: string): boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Login(const AUserName: string; const APassword: string;
const AOddzialNFZ: string = '02'): boolean;
function Logout: boolean;
property SessionID: string read FSessionID;
property TokenID: string read FTokenID;
property ErrorMsg: string read FErrorMsg;
end;
const
SOAP_LoginSTR =
'<?xml version="1.0"?> ' +
'<SOAP-ENV:Envelope
xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"> ' +
'<SOAP-ENV:Body> ' +
'<login xmlns="
http://xml.kamsoft.pl/ws/kaas/login_types"> ' +
'<credentials> ' +
'<item><name>login</name><value><stringValue>${USERNAME}</stringValue></value></item>
' +
'<item><name>domain</name><value><stringValue>${DOMAIN}</stringValue></value></item>
' +
'</credentials> ' +
'<password>${PASSWORD}</password></login> ' +
'</SOAP-ENV:Body></SOAP-ENV:Envelope>';
SOAP_LogoutSTR =
'<?xml version="1.0"?> ' +
'<SOAP-ENV:Envelope
xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"> ' +
'<SOAP-ENV:Header><session xmlns="
http://xml.kamsoft.pl/ws/common"
id="${SESSION_ID}"/> ' +
'<authToken xmlns="
http://xml.kamsoft.pl/ws/common" id="${TOKEN_ID}"/> ' +
'</SOAP-ENV:Header><SOAP-ENV:Body> ' +
'<logout
xmlns="
http://xml.kamsoft.pl/ws/kaas/login_types"/></SOAP-ENV:Body></SOAP-ENV:Envelope>';
function TAuthHTTPRIO.Login(const AUserName: string; const APassword:
string; const AOddzialNFZ: string = '02'): boolean;
var
sendstr, recstr: string;
ss: TStringStream;
begin
sendstr := SOAP_LoginSTR;
sendstr := StringReplace(sendstr, '${DOMAIN}', AOddzialNFZ,
[rfReplaceAll]);
sendstr := StringReplace(sendstr, '${USERNAME}', AUserName,
[rfReplaceAll]);
sendstr := StringReplace(sendstr, '${PASSWORD}', APassword,
[rfReplaceAll]);
ss := TStringStream.Create;
try
WebNode.Execute(sendstr, ss);
recstr := UTF8ToWideString(RawByteString(ss.DataString));
// usuniecie namespaces - janxml cos z nimi nie dziala jak trzeba
recstr := StringReplace(recstr, '<soapenv:', '<',
[rfIgnoreCase, rfReplaceAll]);
recstr := StringReplace(recstr, '</soapenv:', '</',
[rfIgnoreCase, rfReplaceAll]);
recstr := StringReplace(recstr, '<ns3:', '<', [rfIgnoreCase,
rfReplaceAll]);
recstr := StringReplace(recstr, '</ns3:', '</',
[rfIgnoreCase, rfReplaceAll]);
recstr := StringReplace(recstr, '<ns1:', '<', [rfIgnoreCase,
rfReplaceAll]);
recstr := StringReplace(recstr, '</ns1:', '</',
[rfIgnoreCase, rfReplaceAll]);
result := PrzetwarzanieXML(recstr);
finally
FreeAndNil(ss);
end;
end;
function TAuthHTTPRIO.PrzetwarzanieXML(const AXML: string): boolean;
begin
result := FALSE;
FSessionID := '';
FTokenID := '';
FErrorMsg := '';
FXML.XMLString := AXML;
FXML.SetXmlRootNode;
if
Assigned(FXML.XmlCurrentNode.getChildByName(AnsiString('Header'))) then
begin
FXML.SetXmlNode('Header');
FXML.SetXmlNode('session');
FSessionID := FXML.GetXmlAttribStr('id');
FXML.SetXmlParentNode;
FXML.SetXmlNode('authToken');
FTokenID := FXML.GetXmlAttribStr('id');
FXML.SetXmlParentNode;
FXML.SetXmlParentNode;
result := TRUE;
end
else
if
Assigned(FXML.XmlParser.getChildByName(AnsiString('Body'))) then begin
FXML.SetXmlNode('Body');
if
Assigned(FXML.XmlCurrentNode.getChildByName(AnsiString('Fault'))) then begin
FXML.SetXmlNode('Fault');
FXML.SetXmlNode('faultcode');
FXML.SetXmlParentNode;
FXML.SetXmlNode('faultstring');
FErrorMsg := FXML.GetXmlText;
FXML.SetXmlParentNode;
FXML.SetXmlParentNode;
result := FALSE;
end
else
if
Assigned(FXML.XmlCurrentNode.getChildByName(AnsiString('logoutReturn')))
then begin
FXML.SetXmlNode('logoutReturn');
FErrorMsg := FXML.GetXmlText;
FXML.SetXmlParentNode;
result := TRUE;
end;
end;
end;
[jest jeszcze funkcja logout nie pokazana tutaj oraz jest drugi obiekt
class(THttpRIO) tylko do zapytaďż˝]
moj txmlinterface 'nie lubi' namespaces dlatego w login jest to wyci�te.
a w skr�cie
�ci�gasz programy soapui, oraz fiddler, uruchamiasz obydwa, fiddler
przechwytuje wszystkie pakiety http, uruchamiasz test case udost�pniony
przez nfz, sprawdzasz co jest wysy�ane jako xml, co jest odbierane...
podpinasz siďż˝ odpowiednio :P
Yild.