![]() |
SOAP web service | WS-Security authentication
Hallo,
ich versuche einen Client zu erstellen, der einen SOAP Webservice verwendet. Dazu verwende ich den Embarcadero C++Builder 10 Seattle. Wenn ich eine Anfrage an den Webservice sende, erhälte ich folgende Fehlermeldung: Zitat:
Delphi-Quellcode:
In SoapUI konnte ich eine erfolgreiche Anfrage senden indem ich bei "username" und "password" den Benutzernamen und das Password, sowie bei "WSS-Password Type" "PasswordText" ausgewählt habe.
POST https://**** HTTP/1.1
SOAPAction: "****" Content-Type: text/xml; charset=utf-8 User-Agent: CodeGear SOAP 1.3 Host: **** Content-Length: 349 Connection: Keep-Alive Cache-Control: no-cache <?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><****><****>****</****></****></SOAP-ENV:Body></SOAP-ENV:Envelope> Die Anfrage von SoapUI sah folgendermaßen aus:
Delphi-Quellcode:
Wie kann ich den header der Anfrage in meiner Anwendung hinzufügen?
POST https://**** HTTP/1.1
Accept-Encoding: gzip,deflate Content-Type: text/xml;charset=UTF-8 SOAPAction: "http://****" Content-Length: 1069 Host: **** Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> <soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-****"><wsse:Username>****</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">****</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">****</wsse:Nonce><wsu:Created>2017-08-30T12:48:09.048Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header> <soapenv:Body> <tem:****> <!--Optional:--> <tem:****>****</tem:****> </tem:****> </soapenv:Body> </soapenv:Envelope> Ich habe bisher nur Beispiele gefunden, wie die basic authentification im http header hinzugefügt wird. Viele Grüße Thomas |
AW: SOAP web service | WS-Security authentication
In Delphi mache ich das mit der Komponente HTTPRIO - müsste ja in C++ fast genauso sein. In dem Ereignis BeforeExecute kann man den ganzen Stream so basteln, wie man Lust hat... Ist nicht besonders elegant; funktioniert aber.
Delphi-Quellcode:
procedure TForm1.HTTPRIO1BeforeExecute(const MethodName: string; SOAPRequest: TStream);
begin with TStringList.Create do try SOAPRequest.Position:=0; LoadFromStream(SOAPRequest, TEncoding.UTF8); Text:=StringReplace(Text, '<SOAP-ENV:Body>', '<SOAP-ENV:Header>und mein ganzer Header-Kram kommt hier rein'+'</SOAP-ENV:Header><SOAP-ENV:Body>', [rfReplaceAll]); SOAPRequest.Position:=0; SOAPRequest.Size:=0; SaveToStream(SOAPRequest, TEncoding.UTF8); finally Free; end; end; |
AW: SOAP web service | WS-Security authentication
Zitat:
Ich konnte den Request damit entsprechend anpassen, dass es funktioniert. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz