Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi FRITZ!Box neu anmelden (https://www.delphipraxis.net/132124-fritz-box-neu-anmelden.html)

m.r.m. 6. Apr 2009 17:58


FRITZ!Box neu anmelden
 
Hallo,
um meine FRITZ!Box abzumelden und mir anschließend eine neue IP-Adresse zu beschaffen verwende ich folgendes Script im Zusammenhang mit curl:

Code:
curl "http://fritz.box:49000/upnp/control/WANIPConn1" -H "Content-Type: text/xml; charset="utf-8"" -H "SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination" -d "<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'> <s:Body> <u:ForceTermination xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>"
Dies funktioniert auch wunderbar, allerdings würde ich das gerne in ein eigenes Programm integrieren ohne curl zu verwenden.
Ich habe es mit IdHTTP versucht, aber habe es nicht hinbekommen. Hat jemand eine Idee wie es funktionieren könnte?

Danke

m.r.m. 8. Apr 2009 11:53

Re: FRITZ!Box neu anmelden
 
Hier ist die Lösung:

Delphi-Quellcode:
procedure FBdisconnect;
var
  sock: TTcpClient;
  buffer: AnsiString;
begin
  sock := TTcpClient.Create(nil);
  sock.RemoteHost := 'fritz.box';
  sock.RemotePort := '49000';
  sock.Open;

  buffer :=
  'POST /upnp/control/WANIPConn1 HTTP/1.1'+#13+#10+
  'Host: fritz.box:49000'+#13+#10+
  'Accept: */*'+#13+#10+
  'Content-Type: text/xml; charset=utf-8'+#13+#10+
  'SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination'+#13+#10+
  'Content-Length: 276'+#13+#10+
  ''+#13+#10+
  '<?xml version=''1.0'' encoding=''utf-8''?> <s:Envelope s:encodingStyle=''http://schemas.xmlsoap.org/soap/encoding/'' xmlns:s=''http://schemas.xmlsoap.org/soap/envelope/''> '+
  '<s:Body> <u:ForceTermination xmlns:u=''urn:schemas-upnp-org:service:WANIPConnection:1'' /> </s:Body> </s:Envelope>';

  sock.SendBuf(buffer[1],length(buffer));
  sock.Close;
  sock.Free;
end;

Nersgatt 8. Apr 2009 12:02

Re: FRITZ!Box neu anmelden
 
Könntest Du bitte beim nächsten Mal Crossposts in verschiedenen Foren kenntlich machen (einfach das jeweilige Gegenstück im anderen Forum verlinken)?

Ralf Kaiser 10. Apr 2009 13:43

Re: FRITZ!Box neu anmelden
 
Zitat:

Zitat von m.r.m.
Hier ist die Lösung:

Hallo,

sind diese Fritz!Box-Kommandos (SOAP Actions) eigentlich irgendwo dokumentiert? Ich habe schon gesucht aber bisher nichts brauchbares gefunden.

Danke schon mal,
Ralf


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:06 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