到实现方法的输入值。
清单 2. 定义 所有 pojo、实现、方法和参数
<services>
<pojo>
<name>AccountSearchImpl</name>
<description>com.simulator.service.AccountSearchImpl</description>
<methods filter="whitelisting">
<method>
<name>getAccountsByEquipment</name>
<description>web service method to retrieve account information by
equipment id</description>
<parameters>
<parameter>
<name>request</name>
<description>end point for account
search simulator service</description>
</parameter>
<parameter>
<name>equipId</name>
<description>the equipment id used as key for retrieving simulator
data</description>
</parameter>
</parameters>
</method>
</methods>
</pojo>
</services>
使用Spring的Web服务模拟器框架解决方案(10)
时间:2011-08-09 IBM Anthony Allegri
客户端服务层(模拟器)
模拟器客户端 服务层包含与模拟器 Web 服务交互所需的 Web 服务客户端和实现类。实现类根据从相关 JSP 中收集的 数据构造一个特定于模拟器的 SOAP 请求,并将信息发送到已映射的模拟器 Web 服务上,该服务由作为 已映射的 WebSphere Environment Provider 值检索的端点确定。响应对象将由 RPC Adapter servlet 转换成 JSON 对象,并回送给调用 JSP 中的用户。
在清单 3 中,equipment.setSim(equipId) 将来自输入值的请求对象填充到 JSP 中。endPoint 值被定义为 WebSphere Environment Provider 值。
清单 3. 传递到模拟器服务的请求对象的例子
public ESIGetAccountsByEquipmentResponseType getAccountByEquipment (
HttpServletRequest request, String endPoint, String equipId) {
String method = "getAccountsByEquipment";
ESIGetAccountsByEquipmentResponseType rc = new ESIGetAccountsByEquipmentResponseType();
ESIGetAccountsByEquipmentResponseType req = new ESIGetAccountsByEquipmentRequestType();
Equipment equipment = new Equipment ();
equipment.setSim(equipId);
req.setEquipment(equipment);
try {
InitialContext jndiContext = new InitialContext();
AccountSearch service = (AccountSearch) jndiContext
.lookup ("java:comp/env/service/AccountSearch");
AccountSearchPort port = (AccountSearchPort)service.getPort(AccountSearchPort.class);
((Stub) port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endPoint);
rc = port.getAccountsByEquipment(req);
} catch (java.lang.Exception e) {
String[] variables = new String[] { e.getLocalizedMessage() };
java.text.MessageFormat form = new java.text.MessageFormat(
"Remote system
|