首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

使用 Spring 的 Web 服务模拟器框架解决方案(8)技术实现步骤5

使用 Spring 的 Web 服务模拟器框架解决方案(8)技术实现步骤5

模拟器服务层在模拟器服务层内部,从请求对象中提取出 “transaction” 键,然后使用它来指定将要检索、使用并作为 POJO 响应返回的 XML 文件。然后,在清单 4 中,从请求对象中提取出 Equipment ID,然后作为 XML 检索键传递给处理层。在该层中,会应用验证用例所需的业务逻辑,然后返回响应。        
同样在清单 4 中,第一个 try 语句从请求中传递一个键,生成器将使用它查找将被转换为响应 POJO 的 XML 文件。        
清单 4. 从请求对象中构造键供数据生成器层定位 Spring XML 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    public ESIGetAccountsByEquipmentResponseType getAccountsByEquipment(
        ESIGetAccountsByEquipmentRequestType getAccountsByEquipmentInput)
            throws java.rmi.RemoteException {
            
    String methodName = "getAccountsByEquipment";
     
    // return object
    ESIGetAccountsByEquipmentResponseType rc = new
    ESIGestAccountsByEquipmentResponseType();
     
    // request value used for simulator xml retrieval key
    String sim = getAccountsByEquipmentInput.getEquipment().getSim();
     
    if (log.isLoggable(WsLevel.FINER) {
        log.entering(className, methodName);
    }
     
    try {
     
        rc = (ESIGetAccountsByEquipmentResponseType) com.simulator.DataGenerator
                .getDataByBeanId(
                        "ESIGetAcountByEquipmentResponseType",
                        ACTION_KEY_EQUIPMENT, sim);
        return rc;
    } catch (org.springframework.beans.factory.BeanDefinitionStoreException ioe) {
         
        // return default equipment response
        rc = (ESIGetAccountsByEquipmentResponseType) com.simulator.DataGenerator
                .getDataByDefault("ESIGetAccountsByEquipmentResponseType",
                        ACTION_KEY_EQUIPMENT, DEFAULT_EQUIPMENT_CODE);
        log.logp(WsLevel.SEVERE, className, methodName, ioe
                .getResourceDescription());
        return rc;
    } catch (Exception e) {
        rc.setStatus(getCommonStatusType(e));
        return rc;
    } finally {
        if (log.isLoggable(WsLevel.FINER)) {
                log.exiting(className, methodName);
        }
    }
}

返回列表