Date: Fri, 29 Mar 2024 01:39:18 +0100 (CET) Message-ID: <77917377.3795.1711672758756@de.help.internetx.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3794_443690699.1711672758756" ------=_Part_3794_443690699.1711672758756 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
cat requ= est.xml | curl -X POST -H 'Content-Type: application/xml' --data-binary @-= 'https://gateway.autodns.com'
#!/usr/b= in/perl use strict; use warnings; use LWP::UserAgent; my $debug=3D0; my $ua =3D LWP::UserAgent->new(); my $req =3D HTTP::Request->new( POST =3D> 'https://gateway.autodns.co= m' ); $ua->agent('AgentName/0.1 ' . $ua->agent); $ua->timeout(1200); $req->content_type('application/xml'); my $content =3D do { local $/; <STDIN> };; $req->content($content); print STDERR "HTTP Request (".localtime()."):\n" if $debug; my $res =3D $ua->request($req); if ($res->is_success) { print $res->decoded_content()."\n"; print STDERR "HTTP Response:\n".$res->as_string()."\n\n" if $deb= ug; } else { print STDERR $res->status_line()."\n"; }
<?php define( 'HOST', 'https://gateway.autodns.com' ); define( 'XML_FILE', 'request.xml' ); $xml =3D implode( "", file(XML_FILE) ); header( 'Content-Type: application/xml' ); echo requestCurl( $xml ); =20 function requestCurl( $data ) { =09$ch =3D curl_init( HOST ); =09curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); =09curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); =09curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, true ); =09if( !$data =3D curl_exec( $ch )) { =09=09echo 'Curl execution error.', curl_error( $ch ) ."\n"; =09=09return false; =09} =09curl_close( $ch ); =09return $data; } ?>
import j= ava.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; =20 /** * Communicates with the backend. *=20 * @author *=20 */ public class Communicator { =20 private static final String BACKEND_URL =3D "https://gateway.autodns.co= m/;"=20 =20 private static final Charset utf8Charset =3D Charset.forName("UTF-8"); =20 /** * sends the given request to the predefined backend url via http post = and reads the response *=20 * @param request * @return */ public String sendRequest(String request) { URL url; HttpURLConnection connection =3D null; try { =20 byte[] requestBytes =3D request.getBytes(utf8Charset); =20 // Create connection url =3D new URL(BACKEND_URL); connection =3D (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/xml"= ); connection.setRequestProperty("HTTP-Version", "HTTP/1.0"); connection.setRequestProperty("Content-Length", "" + Integer.to= String(requestBytes.length)); connection.setRequestProperty("Content-Language", "de-DE"); connection.setRequestProperty("charset", "utf-8"); connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); =20 // Send request DataOutputStream dataOutputStream =3D new DataOutputStream(conn= ection.getOutputStream()); dataOutputStream.write(requestBytes); dataOutputStream.flush(); =20 // Get Response InputStream is =3D connection.getInputStream(); BufferedReader reader =3D new BufferedReader(new InputStreamRea= der(is)); String line; StringBuffer response =3D new StringBuffer(); while((line =3D reader.readLine()) !=3D null) { response.append(line); response.append('\r'); } return response.toString(); } catch(Exception e) { e.printStackTrace(); return null; } finally { if(connection !=3D null) { try { connection.getOutputStream().close(); connection.getInputStream().close(); } catch(Throwable e) { } connection.disconnect(); } } } =20 }