IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Servlet using Tamino Java API

    Posted Thu June 14, 2001 01:01 AM

    Does anyone have a working Servlet which uses Tamino Java API for simple querying…

    I can make a Java program work with Tamino Java API. Porting the same program to servlets gives me some errors. I know there is something I am missing, so if some one has a example servlet he can point me to, I would appreciate that.


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: Servlet using Tamino Java API

    Posted Thu June 14, 2001 10:47 AM

    I have a servlet using Tamino Java API. It works like an standard application. I can send it to you (specify your e-mail) or you can send me your servlet by mail for see it.


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 3.  RE: Servlet using Tamino Java API

    Posted Fri June 15, 2001 05:01 PM

    Hi Sumeet,
    Here’s a sample of a simple insert servlet. You would have to create a simple input HTML form and Tamino database to run it. Hope this helps you.
    Keep in touch.

    Chetan.

    import javax.servlet.;
    import javax.servlet.http.
    ;
    import java.sql.;
    import java.util.
    ;
    import java.io.;
    import java.text.
    ;
    import com.softwareag.tamino.API.dom.;
    import com.docuverse.dom.
    ;

    public class InsertParm extends HttpServlet {
    public String args = {“http://training1/tamino/mydb/fly”};
    public void init(ServletConfig config)
    throws ServletException {
    super.init(config);
    }

    // Process HTTP Post request
    public void doPost (HttpServletRequest request,HttpServletResponse response) throws
    ServletException, IOException {
    try{
    TaminoClient tamino=new TaminoClient( parseArgs(args) );

    /* Begin of session /
    tamino.startSession();

    / Get parameters from HTML /
    response.setContentType(“text/html”);
    PrintWriter out = response.getWriter();
    String empid = request.getParameter(“empid”);
    String lastname = request.getParameter(“lastname”);
    String firstname = request.getParameter(“firstname”);
    String street = request.getParameter(“street”);
    String city = request.getParameter(“city”);
    String zip = request.getParameter(“zip”);

    / Create a new Document /
    BasicDocument doc=new BasicDocument();

    / Create a new Root Element /
    BasicElement employee = new BasicElement(doc,“employee”);
    BasicElement c = new BasicElement(doc,“empid”);
    c.appendChild(new BasicText(doc,empid));
    employee.appendChild(c);

    / Create a new sub element Address /
    BasicElement empinfo = new BasicElement(doc,“empinfo”);
    BasicElement name = new BasicElement(doc,“name”);
    c = new BasicElement(doc,“lastname”);
    c.appendChild(new BasicText(doc,lastname));
    name.appendChild(c);

    c = new BasicElement(doc,“firstname”);
    c.appendChild(new BasicText(doc,firstname));
    name.appendChild(c);

    empinfo.appendChild(name);
    employee.appendChild(empinfo);

    / Create a new sub element Address /
    BasicElement adresse = new BasicElement(doc,“address”);
    c = new BasicElement(doc,“street”);
    c.appendChild(new BasicText(doc,street));
    adresse.appendChild(c);

    c = new BasicElement(doc,“city”);
    c.appendChild(new BasicText(doc,city));
    adresse.appendChild(c);

    c = new BasicElement(doc,“zip”);
    c.appendChild(new BasicText(doc,zip));
    adresse.appendChild(c);
    empinfo.appendChild(adresse);

    / Now the DOM Element employee is complete. Use method printTree of class TaminoClient to printout the just created document tree /
    TaminoClient.printTree(employee);

    / use method insert of class TaminoClient to insert the document into tamino database , default collection*/
    System.out.println(“Before Insert !!” );
    TaminoResult tr= tamino.insert(employee);
    System.out.println(“After Insert !!” );
    /* end of transaction /
    tamino.commit(false);

    / start a query to test the new document and show the result element on the screen /
    tr = tamino.query(“employee[//name/lastname="Doe"]”);
    if (tr.getElement() != null ){
    TaminoClient.printTree(tr.getElement());
    }
    else
    System.out.println(“employee[lastname="Doe"] not found” );

    / end of session /
    tamino.endSession();
    }
    /
    call class TaminoError to catch the error /
    catch (com.softwareag.tamino.API.dom.TaminoError e){
    System.out.println("Tamino Error Text: " + e.errorText );
    System.out.println("Tamino Error Code: " + e.responseCode );
    }
    }

    / Definition of method parseArgs */
    public static final String parseArgs(String args){
    if (args.length >= 1)
    return args[0];
    else {
    System.out.println(“\n>> Tamino Demo Programs << \n”);
    System.exit(0);
    return null;
    }
    }
    }


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods