IBM WebSphere Sensor Events -GATEWAY
2011-11-16 23:35
465 查看
WebSphere® Sensor Events provides a gateway Web services interface for you to write and send events.
To avoid overloading, two methods for the gateway Web service are provided:
Return codes:
Web service endpoint: http://localhost:port/ibmse/services/EventPublish
Web service WSDL: http://localhost:port//ibmse/services/EventPublish?wsdl
To avoid overloading, two methods for the gateway Web service are provided:
public int publish (string sensoreventXML); public int sensoreventpublish (string eventType , string eventTopic ,string sensoreventXML);
Return codes:
0: success -1: failure -2: deadletter
Web service endpoint: http://localhost:port/ibmse/services/EventPublish
Web service WSDL: http://localhost:port//ibmse/services/EventPublish?wsdl
Example of the gateway Web service WSDL
/********************************************************************************** * Licensed Materials - Property of IBM * 5724-Y62 WebSphere Sensor Events * (c) Copyright IBM Corp. 2008, 2009 All rights reserved. * * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. * * DISCLAIMER OF WARRANTIES. The following code is sample code created by * IBM Corporation. This sample code is part of the WebSphere Sensor Events * and is warranted to perform its intended function only if used un-modified. * If you modify this code then it is considered provided "AS IS", without * warranty of any kind. Notwithstanding the foregoing, IBM shall not be liable * for any damages arising out of your use of the sample code, even if they have * been advised of the possibility of such damages. ***********************************************************************************/ package com.ibm.sensorevent.ws.simulator; import java.io.Serializable; import javax.xml.namespace.QName; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import javax.xml.rpc.Call; import javax.xml.rpc.encoding.XMLType; import javax.xml.rpc.ParameterMode; import com.ibm.sensorevent.model.IBMSensorEvent; import com.ibm.sensorevent.model.ISensorEvent; import com.ibm.sensorevent.model.converter.CBEConverter; import com.ibm.sensorevent.model.payload.PortalReportPayload; public class publishClient implements Serializable { private static final long serialVersionUID = 0L; public static String wsdlURL="http://localhost:9080/ibmse/services/EventPublish?wsdl"; public static String endpoint="http://localhost:9080/ibmse/services/EventPublish"; public publishClient(){ super(); } public String createSensorEvent() { String xml = null; try { ISensorEvent ise = IBMSensorEvent.getPortalReportInstance("EDDR/report/portal"); ise.getHeader().setSourceId("P2"); PortalReportPayload payload = (PortalReportPayload) ise.getPayload(); payload.setValue("ON"); System.out.println(ise); System.out.println(); CBEConverter converter = CBEConverter.getInstance(); xml = converter.toXMLString(ise); } catch (Exception e) { e.printStackTrace(); } return xml; } public void DIIPublish(String xml) { try{ // publish to sensor event web service // Define the service. QName serviceName = new QName("http://gateway.sensorevent.ibm.com","EventPublishService"); Service service = ServiceFactory.newInstance().createService(serviceName); Call call = (Call) service.createCall(); call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, ""); call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped"); call.setTargetEndpointAddress(endpoint); call.removeAllParameters(); QName portName = new QName("http://gateway.sensorevent.ibm.com","EventPublish"); call.setPortTypeName(portName); QName operationName = new QName("http://gateway.sensorevent.ibm.com", "publish"); call.setOperationName(operationName); call.addParameter( "sensoreventXML", // parameter name XMLType.XSD_STRING, // parameter XML type QName String.class, // parameter Java type class ParameterMode.IN); // parameter mode call.setReturnType(XMLType.XSD_STRING); Object[] args = { xml }; System.out.println("response = " + (String) call.invoke(args)); catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { publishClient client = new publishClient(); String eventxml = client.createSensorEvent(); client.DIIPublish(eventxml); } }
Example of a Java™ client using the gateway Web service
/********************************************************************************** * Licensed Materials - Property of IBM * 5724-Y62 WebSphere Sensor Events * (c) Copyright IBM Corp. 2008, 2009 All rights reserved. * * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. * * DISCLAIMER OF WARRANTIES. The following code is sample code created by * IBM Corporation. This sample code is part of the WebSphere Sensor Events * and is warranted to perform its intended function only if used un-modified. * If you modify this code then it is considered provided "AS IS", without * warranty of any kind. Notwithstanding the foregoing, IBM shall not be liable * for any damages arising out of your use of the sample code, even if they have * been advised of the possibility of such damages. ***********************************************************************************/ package com.ibm.sensorevent.ws.simulator; import java.io.Serializable; import javax.xml.namespace.QName; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import javax.xml.rpc.Call; import javax.xml.rpc.encoding.XMLType; import javax.xml.rpc.ParameterMode; import com.ibm.sensorevent.model.IBMSensorEvent; import com.ibm.sensorevent.model.ISensorEvent; import com.ibm.sensorevent.model.converter.CBEConverter; import com.ibm.sensorevent.model.payload.PortalReportPayload; public class publishClient implements Serializable { private static final long serialVersionUID = 0L; public static String wsdlURL="http://localhost:9082/ibmse/services/EventPublish?wsdl"; public static String endpoint="http://localhost:9082/ibmse/services/EventPublish"; /** * @param args */ public publishClient(){ super(); } public String createSensorEvent (){ String xml = null; try{ ISensorEvent ise = IBMSensorEvent.getPortalReportInstance("EDDR/report/portal"); ise.getHeader().setAssetId("ASSED_ID_VALUE"); //ise.getHeader().setEventType("EDDR/report/portal"); ise.getHeader().setGeoLocation("GEO_LOCATION_VALUE"); ise.getHeader().setOriginatingEventId("ORIGINATING_EVENT_ID_VALUE"); ise.getHeader().setPriority((short) 75); ise.getHeader().setSourceId("P2"); //ise.getHeader().setTargetId("PremisesServer"); ise.getHeader().setDateTime(System.currentTimeMillis()); PortalReportPayload payload = (PortalReportPayload) ise.getPayload(); payload.setValue("ON"); System.out.println(ise); System.out.println(); CBEConverter converter = CBEConverter.getInstance(); xml = converter.toXMLString(ise); //System.out.println(xml); } catch ( Exception e){ //System.out.println("exception = " + e.getMessage()); e.printStackTrace(); } return xml; } public void DIIPublish(String xml){ try{ // publish to sensor event web service // Define the service. QName serviceName = new QName("http://gateway.sensorevent.ibm.com","EventPublishService"); Service service = ServiceFactory.newInstance().createService(serviceName); Call call = (Call) service.createCall(); call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, ""); call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped"); call.setTargetEndpointAddress(endpoint); call.removeAllParameters(); QName portName = new QName("http://gateway.sensorevent.ibm.com","EventPublish"); call.setPortTypeName(portName); QName operationName = new QName("http://gateway.sensorevent.ibm.com", "publish"); call.setOperationName(operationName); call.addParameter( "sensoreventXML", // parameter name XMLType.XSD_STRING, // parameter XML type QName String.class, // parameter Java type class ParameterMode.IN); // parameter mode call.setReturnType(XMLType.XSD_STRING); Object[] args = { xml }; System.out.println("response = " + (String) call.invoke(args)); } catch ( Exception e){ //System.out.println("exception = " + e.getMessage()); e.printStackTrace(); } } public static void main(String[] args) { publishClient client = new publishClient(); String eventxml = client.createSensorEvent(); client.DIIPublish(eventxml); } }
相关文章推荐
- [Sterling WMS] 关注RFID 无线射频识别技术产品Mojix和WebSphere Sensor Events
- Build a taskagent on WebSphere Sensor Events 6.2
- 对IBM sensor events 的理解
- IBM WebSphere Application Server 诊断和调优
- 配置自动启动IBM WebSphere MQ
- IBM WebSphere Portal v8.5独立服务器(Linux)数据库迁移_DB2版本
- 顺利参加完IBM websphere大会回来
- Building hybrid mobile applications with PhoneGap and IBM WebSphere Portlet Factory
- 关于websphere的ibm-web-ext.xmi文件,该如何处理
- J2CA0056I: 连接管理器接收到来自资源 jdbc/gywork 的资源适配器的致命连接错误。接收到的异常为 com.ibm.websphere.ce.cm.StaleConnectionException: JZ006: 捕获到 IO 例外:com
- 山东大学IBM WebSphere认证课自拟题
- 利用 IBM Tivoli Directory Server V5.2 实现 WebSphere Application Server V6.0.x 的全局安全性并保护 WAS 管理控制台
- [每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR
- 通向架构师的道路(第十六天)IBM Websphere与IBM HttpServer的集成
- IBM:甲骨文整合BEA有利WebSphere发展
- 使用 IBM WebSphere Business Services Fabric 行业内容包加速 CBS 开发,第 1 部分:建模阶段
- IBM WebSphere Javacore分析
- IBM WebSphere Application Server 诊断和调优---宕机问题分析(一)
- IBM WebSphere MQ讲解2
- IBM WebSphere Portal6 最佳项目实践