|
Hi Markus,
is the server using a self-signed certificate? If not, i.e. it's just good ol' https with a cert issued by a trusted CA, you should be fine using the build in java http client with https, something likeā¦
-----------------------
public static String post( final String url, final String requestBody ) throws IOException, InterruptedException {
// Create a client (the client can be reused so for performance sensitive code, I wouldn't do this within the method)
final HttpClient client = HttpClient
.newBuilder()
.build();
// Construct a request to submit
final HttpRequest request = HttpRequest
.newBuilder()
.uri( URI.create( url ) )
.POST( BodyPublishers.ofString( requestBody, StandardCharsets.UTF_8 ) )
.build();
// Submit the request
final HttpResponse<String> response = client.send( request, HttpResponse.BodyHandlers.ofString( StandardCharsets.UTF_8 ) );
return response.body();
}
-----------------------
- hugi
> On 8 May 2023, at 14:34, Markus Ruggiero (rucotec) <markus.ruggiero@rucotec.ch> wrote:
>
> I need to make a https POST request to a 3rd party web server sending xml along in the body of the request. The server is supposed to return a html page which I should then display inside an iFrame.
>
> Does any body have some example code how to do such an https request? Easy to create the xml but I am not quite sure about the SSL/TLS part.
>
> Thanks a lot
> ---markus---
>
|
|