Java 使用AppEngine获取Https URL

Java 使用AppEngine获取Https URL,java,google-app-engine,Java,Google App Engine,这一方表示可以通过提供的代码支持https。然而,Appengine SDK抱怨: java.net.InetAddress is not supported by Google App Engine's Java runtime environment java.net.Socket is not supported by Google App Engine's Java runtime environment javax.net.ssl.SSLSession is not suppor

这一方表示可以通过提供的代码支持https。然而,Appengine SDK抱怨:

java.net.InetAddress is not supported by Google App Engine's Java runtime environment

java.net.Socket is not supported by Google App Engine's Java runtime environment 

javax.net.ssl.SSLSession is not supported by Google App Engine's Java runtime environment

您必须使用URL获取API


这是参考资料

必须使用URL获取API

这是参考资料

请参见urlfetch(适用于Java和Python):

应用程序引擎应用程序可以与其他应用程序或 通过获取URL访问web上的其他资源。应用程序可以使用 URL获取服务,用于发出HTTP和HTTPS请求并接收 响应。URL获取服务使用谷歌的网络基础设施 为了提高效率和扩大规模

示例:

import java.net.MalformedURLException;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

// ...
        try {
            URL url = new URL("http://www.example.com/atom.xml");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;

            while ((line = reader.readLine()) != null) {
                // ...
            }
            reader.close();

        } catch (MalformedURLException e) {
            // ...
        } catch (IOException e) {
            // ...
        }

关于HTTP:

import java.net.MalformedURLException;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

// ...
        try {
            URL url = new URL("http://www.example.com/atom.xml");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;

            while ((line = reader.readLine()) != null) {
                // ...
            }
            reader.close();

        } catch (MalformedURLException e) {
            // ...
        } catch (IOException e) {
            // ...
        }
要获取的URL可以使用以下范围内的任何端口号: 80-90440-4501024-65535。如果URL中未提及该端口, 该方案暗示了该端口:http://... 是端口80,https://... 是443端口

请参阅urlfetch(适用于Java和Python):

应用程序引擎应用程序可以与其他应用程序或 通过获取URL访问web上的其他资源。应用程序可以使用 URL获取服务,用于发出HTTP和HTTPS请求并接收 响应。URL获取服务使用谷歌的网络基础设施 为了提高效率和扩大规模

示例:

import java.net.MalformedURLException;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

// ...
        try {
            URL url = new URL("http://www.example.com/atom.xml");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;

            while ((line = reader.readLine()) != null) {
                // ...
            }
            reader.close();

        } catch (MalformedURLException e) {
            // ...
        } catch (IOException e) {
            // ...
        }

关于HTTP:

import java.net.MalformedURLException;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

// ...
        try {
            URL url = new URL("http://www.example.com/atom.xml");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;

            while ((line = reader.readLine()) != null) {
                // ...
            }
            reader.close();

        } catch (MalformedURLException e) {
            // ...
        } catch (IOException e) {
            // ...
        }
要获取的URL可以使用以下范围内的任何端口号: 80-90440-4501024-65535。如果URL中未提及该端口, 该方案暗示了该端口:http://... 是端口80,https://... 是443端口


我的观点是,我们如何从appengine代码中进行“rest”调用?显然,是的。urlfetch执行HTTP或HTTPS请求,这基本上是调用给定的URL,这基本上是RESTful的。我的问题是我们如何从appengine代码执行“rest”调用?显然,是的。urlfetch执行HTTP或HTTPS请求,基本上是调用给定的URL,这基本上是RESTful的。