WebSphere brand IBM WebSphere Premises Server, Version 6.1.x

Gateway Web service

WebSphere® Premises Server 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:

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-L17 WebSphere Premises Server
 * (c) Copyright IBM Corp. 2008  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 Premises Server 
 * 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

/*
 * IBM Confidential OCO Source Material
 * (C) COPYRIGHT International Business Machines Corp., 2007.
 * The source code for this program is not published or otherwise divested
 * of its trade secrets, irrespective of what has been deposited with the
 * U. S. Copyright Office.
 */
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);
	}

}

Library | Support | Terms of use

(c) Copyright IBM Corporation 2004, 2008. All rights reserved.
U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.