After some while to put all the pieces together for a Java 8 simulation of the SAP SOAMANAGER Web Service Ping (see SAP Knowledge Database #1947516), I had to face, that the Oracle Service Bus v11.1.1.7 (running on WebLogic Server v10.3.6.0) just seems to to support the used HEAD method but only GET.
NOTE: I had to exchange httpS with httpX due to newbie restrictions ;)
The outcome of the following code of "Ping.java" is
Trying to perform a HTTP 'GET' on 'httpX://pelican.xxx.de:42/aua_xxx?wsdl'
response: code '200' / message 'OK'
Trying to perform a HTTP 'HEAD' on 'httpX://pelican.xxx.de:42/aua_xxx?wsdl'
response: code '500' / message 'Internal Server Error'
import java.lang.System;
import java.io.IOException;
import java.net.URL;
import java.net.HttpURLConnection;
/**
* to be able to use SSL you have to add the root certificate to the java keystore:
* keytool.exe -import -noprompt -trustcacerts -alias rootca2015 -file rootca2015.cer -keystore D:\jdk\jre\lib\security\cacerts -storepass changeit
*
* ...and then use THIS java instance when calling the class:
* D:\jdk\jre\bin\java Ping https://host.de:4242/test user123 pass123
*/
public final class Ping {
private static void request(final String url, final String user, final String pass, final String protocol)
{
System.out.println("\nTrying to perform a HTTP '" + protocol + "' on '" + url + "'");
HttpURLConnection httpUrlConnection = null;
try
{
httpUrlConnection = (HttpURLConnection) new URL(url).openConnection();
}
catch (java.net.MalformedURLException mue)
{
System.out.println("\nMalformedURLException: " + mue);
System.exit(42);
}
catch (IOException ioe)
{
System.out.println("\nIOException: " + ioe);
System.exit(42);
}
if ( user != null )
{
httpUrlConnection.setRequestProperty ("Authorization", "Basic " + java.util.Base64.getEncoder().encodeToString(((new String(user + ":" + pass)).getBytes())));
}
try
{
httpUrlConnection.setRequestMethod(protocol);
}
catch (java.net.ProtocolException pe)
{
System.out.println("\nProtocolException: " + pe);
System.exit(42);
}
int responseCode = 0;
String responseMessage = null;
try
{
responseCode = httpUrlConnection.getResponseCode();
responseMessage = httpUrlConnection.getResponseMessage();
}
catch (java.net.UnknownHostException uhe)
{
System.out.println("\nUnknownHostException: " + uhe);
}
catch (IOException ioe)
{
System.out.println("\nIOException: " + ioe);
System.exit(42);
}
System.out.println("\nresponse: code '" + responseCode + "' / message '" + responseMessage + "'");
}
public static void main(final String[] args)
{
if ( args.length < 1 || args.length == 2 || args.length > 3 )
{
System.out.println("\nUSUAGE: java HeadPing URL [username password], for example java Ping https://host.de:4242/test user123 pass123\n");
}
String url=args[0];
String user=null;
String pass=null;
if (args.length == 3 )
{
user=args[1];
pass=args[2];
}
System.out.println("\nINFO: response code for HTTP_OK is '" + HttpURLConnection.HTTP_OK + "'!\n");
request(url, user, pass, "GET");
request(url, user, pass, "HEAD");
System.exit(42);
}
}
Does anyone has a solution for this problem? Is the SAP SOAMANAGER able to use GET? Can the HEAD capability added to the OSB?