Web Services SAP SOAMANAGER ping到Oracle Service Bus Web服务终结点失败

mspsb9vt  于 2023-08-06  发布在  Oracle
关注(0)|答案(1)|浏览(160)

过了一段时间,为了对SAP SOAMANAGER Web Service Ping进行Java 8模拟(请参阅SAP Knowledge Database #1947516),我不得不面对Oracle Service Bus v11.1.1.7(运行在WebLogic Server v10.3.6.0上)似乎只支持使用的HEAD方法,但只支持GET。

  • 注意:由于新手限制,我不得不将httpS与httpX交换;)*

以下代码“Ping.java”的结果是
正在尝试执行HTTP 'GET' on 'httpX://pelican.xxx.de:42/aua_xxx?wsdl'
响应:代码“200”/消息“OK”
正在尝试执行HTTP 'HEAD' on 'httpX://pelican.xxx.de:42/aua_xxx?wsdl'
响应:代码'500' / message '内部服务器错误'

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吗?

nszi6y05

nszi6y051#

OSB 11G支持REST。与12C相比,它很原始,但您可以基于$inbound/ctx:transport/ctx:request/http:http-method/text()等进行切换。OSB服务需要被写入以接受特定的REST操作才有意义。
但是,您甚至没有调用OSB端点。您正在调用服务的auto generates a WSDL的URL。
删除?wsdl,您将获得实际想要的响应。

相关问题