I have a client that can fire a SOAP request to an endpoint. The end point starts with https
but no HttpsURLConnection
is used in the client. I want to ask if the SOAP request will still be sent with TLS because of the end point being https?
The client implementation:
String endPoint = "https://some_endpoint";
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
SOAPMessage soapRequest = //create the soap req.
SOAPMessage soapResponse = soapConnection.call( soapRequest, endPoint);
In fact it does HTTPSURLConnection if its URL starts with https under the hood, need not to specifically specify.
If URL= https://someexample.org //its by default HTTPSURLConnection
If URL=http://someexample.org //its by default HTTPURLConnection
Use following code to prove that it does under the hood.
Execute below once with http URL, then again same code with https URL. In both case it will work same. It means, it does HTTPSURLConnection under the hood.
String endPoint = "https://someURL.mockable.io";
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
String soapString = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" "
+ "soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\"><soap:Body xmlns:m=\"http://www.example.org/stock\">"
+ "<m:GetStockPriceResponse><m:Price>34.5</m:Price></m:GetStockPriceResponse></soap:Body></soap:Envelope>";
InputStream is = new ByteArrayInputStream(soapString.getBytes());
SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);
SOAPMessage soapResponse = soapConnection.call(request, endPoint);
System.out.println(soapResponse);