经过一段时间将所有部分放在一起进行SAP SOAMANAGER Web服务Ping的Java 8仿真(请参阅SAP知识库#1947516),我不得不面对Oracle Service Bus v11.1.1.7(正在运行)在WebLogic Server v10.3.6.0上)似乎只支持使用的HEAD方法,但只支持GET。
注意:由于新手的限制,我不得不用httpX交换httpS;)
以下“Ping.java”代码的结果是
尝试在'httpX://pelican.xxx.de:42 / aua_xxx?wsdl'上执行HTTP'GET'
响应:代码'200'/消息'确定'
尝试在'httpX://pelican.xxx.de:42 / aua_xxx?wsdl'上执行HTTP'HEAD'
响应:代码'500'/消息'内部服务器错误'
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);
}
}
有没有人能解决这个问题? SAP SOAMANAGER能够使用GET吗? HEAD功能可以添加到OSB吗?
答案 0 :(得分:0)
OSB 11G has REST support. It's primitive compared to 12C, but you can switch based on $inbound/ctx:transport/ctx:request/http:http-method/text()
etc. The OSB service will need to be written to accept the particular REST operation to be meaningful.
However, you're not even calling the OSB endpoint. You're calling the URL that auto generates a WSDL删除网址中的目录。
删除?wsdl
,您将获得实际需要的回复。