com.sapportals.portal.ivs.http

Interface IHTTP

All Known Subinterfaces:
IHTTPService

public interface IHTTP

Title: HTTP and HTTPS gateway.
Description: Encapsulation a communications link between the application and a URL. Simplify the reading from the resource referenced by the URL. The idea is for the developer to have the least possible interaction with the URL connection and management. By using simple API, the developer can retrieve text from web sites over the net while using cookies, header properties and request properties. This API make it transparent to the developer whether the protocol used is http or https, leaving all https configuration to the portal service itself. Sample code:

  Attributes reqParams = new BasicAttributes();
  Attribute reqParam = new BasicAttribute("parama");
  reqParam.add("xxx");
  reqParams.put(reqParam);

  Attributes headerParams = new BasicAttributes();
  Attribute headerParam = new BasicAttribute("Cookie");
  headerParam.add(cookieName+"="+cookieValue);
  headerParams.put(headerParam);
  String text = ihttp.getContentAsText(
     url, // URL.
     "GET", // Method.
     reqParams, // Header properties (for cookies).
     headerParams, // Request properties.
     true, // Allow cookies.
     true, // Allow redirect.
     true, // Use caches.
     0, // ifModifiedSince.
     "", ""); // User name, password.

Copyright: Copyright (c) 2002 Company: SAP Ra'anana Israel


Method Summary
 String getContentAsText(String url, String method, Attributes headerProperties, Attributes requestProperties, boolean allowCookies, boolean allowRedirect, boolean usecaches, long ifModifiedSince, String basicAuthenticatedUserName, String basicAuthenticatedPassword)
          Retrieves the contents of the given URL or null in case of failure.
 String getContentAsText(String url, String method, Attributes headerProperties, Attributes requestProperties, String basicAuthenticatedUserName, String basicAuthenticatedPassword)
          Retrieves the contents of the given URL or null in case of failure.
 

Method Detail

getContentAsText

String getContentAsText(String url,
                        String method,
                        Attributes headerProperties,
                        Attributes requestProperties,
                        boolean allowCookies,
                        boolean allowRedirect,
                        boolean usecaches,
                        long ifModifiedSince,
                        String basicAuthenticatedUserName,
                        String basicAuthenticatedPassword)
                        throws HTTPCodeErrorException
Retrieves the contents of the given URL or null in case of failure.
Also retrieves the contents of the given SSL URL or null in case of failure. All server's SSL configuration are fixed and will be used for all connections.
This method only returns text as content type.

Parameters:
url - A pointer to a "resource" on the World Wide Web from which the content is retrieved from.
method - The method to use in the url request. (GET,POST). The default (if null is retrieved) is GET.
headerProperties - The general request's header properties.
requestProperties - The general request's properties.
allowCookies - If true will allow cookies to be stored. If false, will block all cookies.
allowRedirect - If true will allow redirection. If false, will get the empty page.
usecaches - a boolean indicating whether or not to allow caching. Some protocols do caching of documents. Occasionally, it is important to be able to "tunnel through" and ignore the caches (e.g., the "reload" button in a browser). If the UseCaches flag on a connection is true, the connection is allowed to use whatever caches it can. If false, caches are to be ignored. The default value defaults to true.
ifModifiedSince - Some protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time. A nonzero value gives a time as the number of milliseconds since January 1, 1970, GMT. The object is fetched only if it has been modified more recently than that time. The default value of this field is 0, indicating that the fetching must always occur.
basicAuthenticatedUserName - If basic authentication in the target web site is needed, the value will be the user name required.
basicAuthenticatedPassword - If basic authentication in the target web site is needed, the value will be the password required. Note!! null value in one or two params: basicAuthenticatedUserName or basicAuthenticatedPassword will ignore any basic authentication.
Returns:
The URL's text content. In case of failure the value will be null.
Throws:
HTTPCodeErrorException - deprecated. Never thrown anymore.
Since:
6.0
See Also:
java.net.URLConnection#getContent(java.lang.String), URLConnection.setRequestProperty(String key,String value), URLConnection.setUseCaches(boolean usecaches), URLConnection.setIfModifiedSince(long ifmodifiedsince)

getContentAsText

String getContentAsText(String url,
                        String method,
                        Attributes headerProperties,
                        Attributes requestProperties,
                        String basicAuthenticatedUserName,
                        String basicAuthenticatedPassword)
                        throws HTTPCodeErrorException
Retrieves the contents of the given URL or null in case of failure. Also retrieves the contents of the given SSL URL or null in case of failure. All server's SSL configuration are fixed and will be used for all connections. Some properties gets default values:

allowCookies=true
allowRedirect=true
usecaches=true
ifModifiedSince=0

This method only return text as content type.

Parameters:
url - A pointer to a "resource" on the World Wide Web from which the content is retrieved from.
method - The method to use in the url request. (GET,POST). The default (if null is retrieved) is GET.
headerProperties - The general request's header properties.
requestProperties - The general request's properties.
allowCookies - If true will allow cookies to be stored. If false, will block all cookies.
basicAuthenticatedUserName - If basic authentication in the target web site is needed, the value will be the user name required.
basicAuthenticatedPassword - If basic authentication in the target web site is needed, the value will be the password required. Note!! null value in one or two params: basicAuthenticatedUserName or basicAuthenticatedPassword will ignore any basic authentication.
Returns:
The URL's text content. In case of failure the value will be null.
Throws:
HTTPCodeErrorException - deprecated. Never thrown anymore.
Since:
6.0
See Also:
java.net.URLConnection#getContent(java.lang.String), URLConnection.setRequestProperty(String key,String value), URLConnection.setUseCaches(boolean usecaches), URLConnection.setIfModifiedSince(long ifmodifiedsince)
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] EP-RUNTIME [sap.com] tc/ep/connectivity/services/api api EP-PIN


Copyright 2011 SAP AG Complete Copyright Notice