Please help. I have written some java application to allow access to view log outside of Integration Monitoring. The program is written to retrieve the data from the event fields as a binary byte array, using the BrokerEvent.toBinData method. Then i tried to parse it to a readable string, however some characters are unreadable. Can someone please explain how i can convert the binary data to a readable string?
toBinData and fromBinData serialize a BrokerEvent object. The byte array undoubtedly contains structure and other control information that will not make any sense when converted to characters. Indeed, you probably cannot be sure where the boundaries are for the start and end of bytes that represent chars.
Might the toString methods do what you’re looking for?
Attached is my code. It gets the queue data using BrokerEvent.toBinData() method. Then i create a flow service to call this code as follow:
Get brokerQueueData.java service
Write objectToFile as “.ser” file type
Call pub.file:getFile and loadAs String
I can read the string contents, but there are extra chars that’s not readable and i’m not sure how to delete them. If you can help me, i would greatly appreciate it.
That last message was from Tiffani. She’s step out to a meeting so asked me to posted for her and i forgot and signed my own name. I am sort of working with her on this, but i don’t have much about webMethods. Thanks again.
The only thing that can reliably done with the byte array returned by toBinData is to pass it to fromBinData. You definitely cannot load the file using getFile with loadAs string and expect a usable string.
In the for loop: for(int i=0;i<be.length;i++)
{
QDoc[i] = IDataFactory.create();
IDataCursor pipelineCursor2 = QDoc[i].getCursor();
byte[] contentBytes = be[i].toBinData();
pipelineCursor2.last();
pipelineCursor2.insertAfter(“evtType”, be[i].getTypeName()); //pipelineCursor2.insertAfter(“content”, be[i].toString());
pipelineCursor2.insertAfter(“content”, contentBytes);
pipelineCursor2.destroy();
}
Assuming you’ve uncommented the first insertAfter is the second insertAfter interferring in some way. What to you see if the second insertAfter is commented out? Or if you use a different variable name for the string?
I know you’re busy yourself so i’m very thankful for taking the time to help me out. I really appreciated it. If i uncommented out the second insertAfter, i get the readable string. However, all i can see, is the event properties. But with the BrokerEvent.toBinData() method, i can see the actual data from the queued, but with extra chars that’s i can’t get rid off. I tried using the BrokerEvent.fromBinDat() method and all i get is null or client is already created. So i’m kind of stuck or lost
I wish I could dig in more deeply but alas I cannot. My advice is to disregard toBinData/fromBinData. Those will not do what you’re after. Instead, explore the toString() toFormattedString() variations. Or just use MWS for browsing queues.