目录 上一页 下一页 索引

第 7 章

WAP 网关 API


本章介绍了 Sun Java System Content Delivery Server WAP 网关 API。此 API 从 HTTP 头中检索 MSISDN、设备配置文件以及其他特性。基于用户名和密码的身份验证在 WAP 网关集成中不是必需的。

图 7 是与 API 和访问点进行交互的通用系统组件的简单表示。其中还包括一些未与 API 进行交互、但与全面理解体系结构相关的组件。

图 7-WAP 网关适配器体系结构

此图以文本形式进行说明。

WAP 网关适配器从特定 WAP 网关解析 HTTP 头并获得 MSISDN。

有关本节中未介绍的类或方法的信息,请参见 $CDS_HOME/javadoc/cdsapi/index.html 中的 WAP 网关 API 的 Javadoc 工具的 HTML 输出。

7.1 WAPGatewayAdapter 类

公用的抽象 WAPGatewayAdapter 类定义从 HTTP 头获得 MSISDN 以及唯一设备 ID 的方法。它还用于定义检查是否支持或可以实现此方法的方法。

有关本节中未介绍的方法信息,请参见 $CDS_HOME/javadoc/cdsapi/index.html 中的 WAP 网关 API 的 Javadoc 工具的 HTML 输出。

7.1.1 doHandle()

此方法用于确定是否已实现了此类的其他方法。如果 method 已实现,则此方法应返回 true。如果 method 未实现,将返回 false

public abstract boolean doHandle(String method)throws WAPGatewayException 

7.1.2 getMSISDN()

解析 HTTP 头后以字符串形式返回 MSISDN。

public abstract String getMSISDN(HttpServletRequest request) throws WAPGatewayException 

7.1.3 getUniqueId()

解析 HTTP 头后以字符串形式返回唯一设备 ID。

public abstract String getUniqueId(HttpServletRequest request) throws WAPGatewayException 

7.2 使用 WAP 网关 API

Content Delivery Server 将为以下 WAP 网关提供 API 实现。

WAP 网关必须配置为将 MSISDN 或唯一设备 ID 转发到 Content Delivery Server。WAPGatewayManagerWAPGatewayAdapter 类可以从 cdsapi.jar(位于 $CDS_HOME/deployment/deployment-name/lib/cdslib 目录)中找到。要为任何其他 WAP 网关注册一个新类以扩展 WAPGatewayAdapter 类,请将类文件名添加到 $CDS_HOME/deployment/deployment-name/conf 目录中的 wapgateway.config 文件中。下面的语句是使用 Content Delivery Server 为 Nokia Activ Server 2.0.1 注册一个适配器的实例。

module.gateway.id=com.sun.content.server.service.gateway.nokia.NokiaActivServerWAPGateway 

将适配器置于 $CDS_HOME/deployment/deployment-name/lib/external 目录以便 Content Delivery Server 能够在执行期间找到该文件。

7.3 示例

以下代码示例显示了用于扩展 WAPGatewayAdapter 类的 Nokia Activ Server 的适配器的伪代码。

代码示例 10 WAPGatewayAdapter 类的样例扩展
package com.sun.content.server.service.gateway.sample; 
 
import com.sun.content.server.service.gateway.WAPGatewayAdapter; 
import com.sun.content.server.service.gateway.WAPGatewayException; 
import javax.servlet.http.HttpServletRequest; 
 
public class SampleWAPGateway extends WAPGatewayAdapter 
{ 
  /* Method to check if the passed method is implemented in this 
   * class or not. */ 
  public boolean doHandle(String method) throws WAPGatewayException 
  { 
    if (method.equals("getMSISDN")) 
      return true; 
    return false; 
  } 
 
  /* Gets the MSISDN from the header and returns as a string. */ 
  public String getMSISDN(HttpServletRequest request) 
  { 
    return request.getHeader("<key to retrieve>"); 
  } 
 
  /* This method is not implemented. */ 
  public String getUniqueId(HttpServletRequest req)throws WAPGatewayException 
  { 
    throw new WAPGatewayException("This method is not implemented"); 
  } 
} 
 


目录 上一页 下一页 索引 定制指南
Sun Java™ System Content Delivery Server,版本 2004Q1