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
Antwort Antwort
jsp

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

TidHTTP post asmx und xml

  Alt 25. Sep 2018, 09: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
Schokohase
(Gast)

n/a Beiträge
 
#2

AW: TidHTTP post asmx und xml

  Alt 25. Sep 2018, 09:41
Manchmal hilft es wenn man exakt arbeitet und nicht nur so ungefähr in etwa.

Doku sagt:
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>
Du machst
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>
  Mit Zitat antworten Zitat
Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.763 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: TidHTTP post asmx und xml

  Alt 25. Sep 2018, 09:42
Hast Du mal versucht über "Komponente -> WSDL importieren" die ganze Arbeit einfach Delphi zu überlassen?
Das WSDL liegt ja hier bereit: http://ifa17.test.crb.ch/partner/Par...ce17.asmx?WSDL

Sherlock
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat
mjustin

Registriert seit: 14. Apr 2008
3.004 Beiträge
 
Delphi 2009 Professional
 
#4

AW: TidHTTP post asmx und xml

  Alt 25. Sep 2018, 11:15
Manchmal hilft es wenn man exakt arbeitet und nicht nur so ungefähr in etwa.

Doku sagt:
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"

...
Du machst
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"
...
Beides dürfte wenig Aussicht auf Erfolg haben: da TIdHTTP das POST /... und die Header sendet, muss man sie nicht in die Stringlist für den HTTP Body schreiben. Nur wenn man mit einem puren TCP Client HTTP Requests senden will, müssen diese Zeilen vor dem Body gesendet werden. TIdHTTP macht das komfortabel.
Michael Justin
  Mit Zitat antworten Zitat
Schokohase
(Gast)

n/a Beiträge
 
#5

AW: TidHTTP post asmx und xml

  Alt 25. Sep 2018, 11:27
Manchmal hilft es wenn man exakt arbeitet und nicht nur so ungefähr in etwa.

Doku sagt:
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"

...
Du machst
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"
...
Beides dürfte wenig Aussicht auf Erfolg haben: da TIdHTTP das POST /... und die Header sendet, muss man sie nicht in die Stringlist für den HTTP Body schreiben. Nur wenn man mit einem puren TCP Client HTTP Requests senden will, müssen diese Zeilen vor dem Body gesendet werden. TIdHTTP macht das komfortabel.
... und length bei Content-Length passt auch nicht ... und von daher sollte einleuchten, dass es sich hier um keine fertige Lösung handelt, sondern ein Hinweis: "Bitte nochmal anschauen, da passen so grundlegende Sachen noch gar nicht"
  Mit Zitat antworten Zitat
Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.763 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: TidHTTP post asmx und xml

  Alt 26. Sep 2018, 09:25
Wir sind zu schnell...

Sherlock
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat
jsp

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

AW: TidHTTP post asmx und xml

  Alt 26. Sep 2018, 09:36
Oder ich zu langsam
Danke Sherlock, habe es mit WSDL importieren gelöst...
  Mit Zitat antworten Zitat
Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.763 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: TidHTTP post asmx und xml

  Alt 26. Sep 2018, 12:15


Freut mich! Danke für die Rückmeldung.

Sherlock
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat
Antwort Antwort

 

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 04:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz