1

スタンドアロンのJavaアプリを書いています。HTTPSプロトコルを使用してSOAPWebサービスを呼び出すには、デフォルトのシステム(Windows XP、7)プロキシ設定を使用する必要があります。

システムプロキシ設定を決定するには、ProxySelectorクラスを使用します。コードは次のとおりです。

System.setProperty("java.net.useSystemProxies", "true");
List proxies = ProxySelector.getDefault().select(new URI("https://www.google.com/"));
for (Iterator iter = proxies.iterator(); iter.hasNext();) {
    Proxy proxy = (Proxy) iter.next();
    InetSocketAddress address = (InetSocketAddress) proxy.address();
    if (address == null) {
        UTLogger.getLogger().debug("No proxy (direct connection)");
    } else {
        if (proxy.type().equals(Proxy.Type.HTTP)) {
            System.setProperty("http.proxyHost", address.getHostName());
            System.setProperty("http.proxyPort", String.valueOf(address.getPort()));
            System.setProperty("https.proxyHost", address.getHostName());
            System.setProperty("https.proxyPort", String.valueOf(address.getPort()));
        } else if (proxy.type().equals(Proxy.Type.SOCKS)) {
            System.setProperty("socksProxyHost", address.getHostName());
            System.setProperty("socksProxyPort", String.valueOf(address.getPort()));
        }
    }
}
System.setProperty("java.net.useSystemProxies", "false");

そして、これが私が接続を初期化する方法です:

SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[]{new TrustDummy()}, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
servicePort = new MyPort(new URL(wsdlLocation), new QName(nameSpaceURI, localPart)).getMyPortSoap();

なぜないのか分かりませんProxy.Type.HTTPSか?Webサービスメソッドを呼び出すと、次のエラーが発生します。

httpプロキシセットの場合:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: ht tps://...?wsdl. It failed with: Got Unrecognized SSL message, plaintext connection? while opening stream from ht tps://...?wsdl.

およびhttpsプロキシセットを使用:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: ht tps://...?wsdl. It failed with: Got Unable to tunnel through proxy. Proxy returns "HTTP/1.0 403 Forbidden" while opening stream from ht tps://...?wsdl.

私はそれを間違っていますか?

4

0 に答える 0