Sending XML to Ponder2

XML can be sent to Ponder2 from a stand-alone application, from a direct Java call, a Java RMI call, a Web Service call or from the Ponder2 Shell.

Stand-Alone Application

XML can be sent to Ponder2 from a simple application embedded within the Ponder2 Jar file. This application uses Web Services to make the call so the receiving Ponder2 instance must have already been set up to use Web Services. The execution takes the format:

java -classpath ponder2.jar:ponder2comms.jar... net.ponder2.comms.XMLRemoteWSClient epr execute [file]

where ... indicates many Jar files and the file argument is optional, don't include the "[: and :and ]" characters. If a file name is there, XML is expected and it is sent to Ponder2. If a file name is not included then the XML for the command is taken from standard input. See examples below. This example expects that Ponder2 has been started as detailed in communications with Web Services.

There are two basic commands available, one to send XML to Ponder2 and one to send an Event to Ponder2. First we will send some XML through to create an event and a policy, then we will send an event to trigger the policy.

The library setup is a little complicated so scripts have been included to facilitate the use of this method. On Windows the pssend.bat script can be used and on Unix the shell script pssend is available. So, to setup an Event and a Policy and to send such an event we can execute:

pssend execute PSxml/testsetup.xml
pssend execute < PSxml/sendevent.xml

The second example uses standard input instead of opening a given filename. If something goes wrong then pssend will exit with a return code of 1 and will print a short error message.

NB. The above assumes that you are using an epr of http://localhost:8080/axis/Ponder2.jws, if this is not the case then the file pssend or pssend.bat must be edited.

Java Call

If Ponder2 is running in the same VM as your Java application then you can send an XML string with the call:

   1 Util.Parse("<use name=\"...\"><more xml=\"ok\"/></use>");

This call returns a string which may have an error message if something went wrong. The method definition in the Util class is

   1 public static String parse(String xmlString);

Java RMI

If Ponder2 is running within another VM on the same or different machine then RMI may be used to send it XML:

   1 XMLRemoteInterface remotePS =
   2  (XMLRemoteInterface)Naming.lookup("//localhost/"+rmiName+port);
   3 result = remotePS.execute(xmlMessage);

So for the above XML you can use:

   1 result = remotePS.execute("<use name=\"...\"><more xml=\"ok\"/></use>");

The RMI method definition is

   1 public String execute(String xmlString) throws RemoteException;

The Ponder2.jws file may be inspected to see an example of the RMI call in action with its surrounding try/catch clause.

Web Service

Ponder2 can have XML commands and events sent to it using Web Service calls via Ponder2.jws. The Java signatures are shown here but if you use a different language you must refer to the Ponder2 WSDL.

To execute XML use the Web Service call execute with the signature:

   1 public String execute(String xmlMessage)

e.g.

   1 execute("<use name=\"...\"><more xml=\"ok\"/></use>");

To send an event into the SMC use the Web Service call event with the signature:

   1 public String event(String eventName, String[] args)

e.g.

   1 event("/Event/ReputationChange", "Fred", 55, 25, "Leave Now");


CategoryUsingPonder2

Ponder2SendingXML (last edited 2008-01-03 17:40:13 by localhost)