| Join wMUsers | Blog at wMUsers | User Control Panel | Site Map | webMethods Jobs |For Employers |
![]() |
![]() |
Implementing the read() MethodOnce the above supporting methods are completed, the read() method must be implemented. public int read() throws IOException
{
if (pos >= buffer.length)
{
String line = reader.readLine();
if (line == null)
{
if (eof)
{
return -1;
}
eof = true;
buffer = ("</" + docType + ">").getBytes();
pos = 0;
}
else
{
buffer = formatRecord(line).getBytes();
pos=0;
}
}
return (int)buffer[pos++];
}
private String formatRecord(String line)
{
StringBuffer sbuffer = new StringBuffer();
sbuffer.append(newLine + "<" + nodeName + ">");
StringTokenizer st = new StringTokenizer(line, ",");
for (int i=0; st.hasMoreTokens(); i++)
{
sbuffer.append(newLine + "<" + fieldnames[i] + ">");
sbuffer.append(st.nextToken());
sbuffer.append("</" + fieldnames[i] + ">");
}
sbuffer.append(newLine + "</" + nodeName + ">" + newLine);
return sbuffer.toString();
}
Register the content handler with the webMethods Integration Server using the ServerAPI.registerContentHandler() method and the work is completed. SummaryThe advantage to using the content handlers in the article is that a partner does not need to modify its flat file format to submit documents to Trading Networks. In fact, because the content handler is transparent, the partner appears to be submitting a XML document. In addition, the above content handler can be registered to handle multiple types of text content from multiple partners. Two other important notes:
Go Deeper on the Subject: The wMUsers Discussion Forums Rupinder Singh has been working in the IT arena for about 10 years with experience in real-time defense systems, SGML parsers and application integration. He has worked on several integration projects in various roles using webMethods and J2EE application servers.
Rupinder is a consultant for Atos Origin and can be reached via email at |
| © All Rights Reserved, 2001-2008. |