AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TidHTTP post asmx und xml

Ein Thema von jsp · begonnen am 25. Sep 2018 · letzter Beitrag vom 26. Sep 2018
 
jsp

Registriert seit: 9. Aug 2003
50 Beiträge
 
#1

TidHTTP post asmx und xml

  Alt 25. Sep 2018, 10:36
Hallo zusammen,

ich versuche ein xml von einem Server zu laden.
Die Beschreibung der Funktion (xml) findet ihr hier:
http://ifa17.test.crb.ch/partner/Par...op=downloadNPK

Bin neu auf dem Gebiet, und könnte ein paar Denkanstösse gebrauchen.
Versucht habe ich es so:

Delphi-Quellcode:
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;
Gruss, Jörn
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06: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 by Thomas Breitkreuz