Sample program source code:
1 | import java.io.BufferedOutputStream; |
Detailed explanation of source code:
main method
Line numbers 30 to 37
The following data is obtained from the arguments at runtime:
Argument | Variable | Use |
---|---|---|
1 | hostName | CEP Server host name |
2 | engineName | CEP engine name |
3 | dataType | Event data format |
4 | charSet | Character set |
5 | eventTypeId | Event type ID |
6 | data | Event data |
7 | lWait | Data transmission wait time |
8 | loop | Data transmission count |
Line number 39
Creates a SoapClient object.
Line number 40
Calls a method for sending event data.
Event data, character set, data transmission count, and data transmission wait time are passed as arguments.
SoapClient constructor
Line numbers 49 and 50
Creates an end point address from the arguments.
Line number 52
Creates a URL object.
open method
Line number 61
Creates a connection destination "HttpURLConnection" from the URL object.
Line number 63
Specifies POST as the HTTP method to send SOAP messages using the POST method.
Line number 64
Specifies "content-type" as "text/xml". "content-type" must be "text/xml". (SOAP 1.1 specification)
Sets the event data character set.
Line number 65
Sets a flag to be output.
Line number 66
Connects to the data recipient.
sendMessage method
Line numbers 79 to 112
Loops the number of loop times specified in the argument.
Line number 80
Executes the open method, and connects to the data recipient.
Line number 81
Retrieves BufferedOutputStream.
Line number 83
Replaces %COUNTER% contained in the event data with the loop count.
This sends different event data every time.
This example assumes that the following event data is used:
"STR0001","CPN0001",%COUNTER%,"30"
Line number 84
Creates a SOAP message.
Line number 94
Writes the SOAP message using the specified character set.
Line number 96
Flushes BufferedOutputStream.
Line number 97
Closes BufferedOutputStream.
Line number 99 and 100
Retrieves InputStream from HttpURLConnection, and creates BufferedReader.
Line number 104
Writes sent results from BufferedReader to the standard output.
Line number 107 and 108
Closes InputStream and BufferedReader.
Line number 110
Disconnects HttpURLConnection.
Line number 111
Waits until the next event data is sent.
An example of sample execution is shown below.
In this example, debug information is output to the engine log by using DebugLogListener.
Command execution result
# java -cp ./ SoapClient localhost CepEngine CSV UTF-8 CSVEvent SOAP,CSV,%COUNTER% 1 3 <ENTER>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
Note that in the example above, newlines have been added (lines 2 to 4, 6 to 8, and 10 to 12) for readability only. The actual output does not have newlines.
Engine log output result
2012-07-29 13:01:20,693 [DEBUG] abc:length=1
abc[0]
operation :CSV: String
count :0: String
ID :SOAP: String
2012-07-29 13:01:20,730 [DEBUG] abc:length=1
abc[0]
operation :CSV: String
count :1: String
ID :SOAP: String
2012-07-29 13:01:20,768 [DEBUG] abc:length=1
abc[0]
operation :CSV: String
count :2: String
ID :SOAP: String
An example of sample execution is shown below.
In this example, debug information is output to the engine log by using DebugLogListener.
Note
In case XML data is sent through SOAP adapter, enclose the data with CDATA as described in the command execution result below.
Command execution result
# java -cp ./ SoapClient localhost CepEngine XML UTF-8 XMLEvent '<![CDATA[<?xml version="1.0"\
encoding="UTF-8"?><XMLEvent><ID>SOAP</ID> <operation>XML</operation>\ <count>%COUNTER%</count></XMLEvent>]]>' 1 3 <ENTER>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/env
elope/"><S:Body><ns2:notifyResponse xmlns:ns2="http://adapter.front.cep.cspf.fujitsu.com/"><re
turn>Code=0 Message=Sending message completed normally.</return></ns2:notifyResponse></S:Body>
</S:Envelope>
Note that in the command line example above, backslash ("\") and newlines have been added for readability only. The actual command line does not have backslash or newlines.
Note that in the output example above, newlines have been added (lines 4 to 6, 8 to 10, and 12 to 14) for readability only. The actual output does not have newlines.
Engine log output result
2012-07-29 13:02:21,860 [DEBUG] abc--0:length=1
abc--0[0]
operation :XML: String
count :0: String
ID :SOAP: String
2012-07-29 13:02:21,900 [DEBUG] abc--0:length=1
abc--0[0]
operation :XML: String
count :1: String
ID :SOAP: String
2012-07-29 13:02:21,935 [DEBUG] abc--0:length=1
abc--0[0]
operation :XML: String
count :2: String
ID :SOAP: String