public final class SamplePublishHTTP extends Object
com.avaya.collaboration.eventing
package
for more information about this interface.
The first sample below illustrates how the interface can be invoked from an
HTML form.
<form action="http://1.2.3.4/services/EventingConnector/events" method="post" enctype="multipart/form-data"> <table cellpadding="1" cellspacing="1" > <tr> <td align="center" colspan="2">Click to create event</td> </tr><tr height="5"/> <tr height="5"/> <tr> <td width="40%" align="right">event body<input type="file" name="eventBody" value="myFile"></td> </tr> <tr> <td width="40%" align="right">family <input type="text" name="family"></td> </tr> <tr> <td width="40%" align="right">type <input type="text" name="type"></td> </tr> <tr> <td width="40%" align="right">metadata-user <input type="text" name="metadata-user"></td> </tr> <tr> <td width="40%" align="right">metadata-correlationId <input type="text" name="metadata-correlationId"></td> </tr> <tr> <td width="40%" align="right">metadata-key45 <input type="text" name="metadata-key45"></td> </tr> <tr> <td width="40%" align="right"><input type="submit" name="submit" value="submit"></td> </tr> </table> </form>The second sample below shows how to invoke the interface from Java.
public void publish() { HttpClient httpClient = new DefaultHttpClient(); URI url = new URI("http://1.2.3.4/services/EventingConnector/events"); HttpPost httpPost = new HttpPost(url); MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("family", new StringBody("MyFamily")); reqEntity.addPart("type", new StringBody("EventOfInterest")); reqEntity.addPart("version", new StringBody("1.0")); reqEntity.addPart("metadata-user", new StringBody("userABCD")); reqEntity.addPart("metadata-correlationId", new StringBody("corr-id-VHKJHHH797ghg")); reqEntity.addPart("metadata-newData", new StringBody("someData")); reqEntity.addPart("eventBody", new FileBody(new File("C:\\Program Files\\Java\\jre7\\README.txt"))); httpPost.setEntity(reqEntity); HttpResponse response = httpClient.execute(httpPost); System.out.println(response.getStatusLine()); }
Copyright © 2014 Avaya. All Rights Reserved.