![]() |
TidHTTP post asmx und xml
Hallo zusammen,
ich versuche ein xml von einem Server zu laden. Die Beschreibung der Funktion (xml) findet ihr hier: ![]() Bin neu auf dem Gebiet, und könnte ein paar Denkanstösse gebrauchen. Versucht habe ich es so:
Delphi-Quellcode:
Gruss, Jörn
procedure TForm6.Button1Click(Sender: TObject);
var HTTP: TIdHTTP; RequestBody: TStringStream; res : string; xmlStr : TStrings; begin xmlStr := TStringList.Create; xmlStr.Add('POST /partner/PartnerService17.asmx HTTP/1.1'); xmlStr.Add('Host: ifa17.test.crb.ch'); xmlStr.Add('Content-Type: text/xml; charset=utf-8'); xmlStr.Add('Content-Length: 598'); xmlStr.Add('SOAPAction: "http://www.crbnet.ch/crbox_partner/downloadNPK"'); xmlStr.Add('<?xml version="1.0" encoding="utf-8"?>'); xmlStr.Add('<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'); xmlStr.Add('xmlns:xsd="http://www.w3.org/2001/XMLSchema"'); xmlStr.Add('xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'); xmlStr.Add('<soap:Body>'); xmlStr.Add('<downloadNPK xmlns="http://www.crbnet.ch/crbox_partner">'); xmlStr.Add('<chapter>501</chapter>'); xmlStr.Add('<language>Deutsch</language>'); xmlStr.Add('<year>2017</year>'); xmlStr.Add('</downloadNPK>'); xmlStr.Add('</soap:Body>'); xmlStr.Add('</soap:Envelope>'); Memo2.Clear; HTTP := TIdHTTP.Create; try try RequestBody := TStringStream.Create(xmlStr.Text, TEncoding.UTF8); try res := HTTP.Post('http://ifa17.test.crb.ch/partner/PartnerService17.asmx', RequestBody); (* Folgende Fehlermeldung wird dann ausgelöst: --------------------------- Im Projekt HTTP_Post.exe ist eine Exception der Klasse EIdHTTPProtocolException mit der Meldung 'HTTP/1.1 500 Internal Server Error' aufgetreten. --------------------------- *) Memo2.Lines.Add('POST : '+res); res := HTTP.ResponseText; Memo2.Lines.Add('ResponseText : '+res); finally RequestBody.Free; end; except on E: EIdHTTPProtocolException do begin res := 'EIdHTTPProtocolException : '+E.Message + #13#10#13#10 + E.ErrorMessage; Memo2.Lines.Add(res); end; on E: Exception do begin res := 'Exception : '+E.Message; Memo2.Lines.Add(res); end; end; finally HTTP.Free; xmlStr.Free; end; end; |
AW: TidHTTP post asmx und xml
Manchmal hilft es wenn man exakt arbeitet und nicht nur so ungefähr in etwa.
Doku sagt:
Code:
Du machst
POST /partner/PartnerService17.asmx HTTP/1.1
Host: ifa17.test.crb.ch Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.crbnet.ch/crbox_partner/downloadNPK" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <downloadNPK xmlns="http://www.crbnet.ch/crbox_partner"> <chapter>string</chapter> <language>Deutsch or Francais or Italiano or English</language> <year>int</year> </downloadNPK> </soap:Body> </soap:Envelope>
Code:
POST /partner/PartnerService17.asmx HTTP/1.1
Host: ifa17.test.crb.ch Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.crbnet.ch/crbox_partner/downloadNPK" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <downloadNPK xmlns="http://www.crbnet.ch/crbox_partner"> <chapter>string</chapter> <language>Deutsch or Francais or Italiano or English</language> <year>int</year> </downloadNPK> </soap:Body> </soap:Envelope> |
AW: TidHTTP post asmx und xml
Hast Du mal versucht über "Komponente -> WSDL importieren" die ganze Arbeit einfach Delphi zu überlassen?
Das WSDL liegt ja hier bereit: ![]() Sherlock |
AW: TidHTTP post asmx und xml
Zitat:
|
AW: TidHTTP post asmx und xml
Zitat:
|
AW: TidHTTP post asmx und xml
Wir sind zu schnell...
Sherlock |
AW: TidHTTP post asmx und xml
Oder ich zu langsam :roll:
Danke Sherlock, habe es mit WSDL importieren gelöst... |
AW: TidHTTP post asmx und xml
:thumb:
Freut mich! Danke für die Rückmeldung. Sherlock |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:56 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