Menu

HTTP server example

2011-02-24
2013-04-17
  • Nobody/Anonymous

    hello

    The project web page (http://xlloop.sourceforge.net/) has sample code of how to start a simple binary function server.  It says HTTP protocol is also supported but I don't see any example of how to start up a simple HTTP server.  In the .ini file section it explains how to configure the Excel client to work in HTTP mode.  But I don't see anything that explains how to start up an HTTP server.

    Can you provide an example?

    Thanks.

     
  • Nobody/Anonymous

    You start it as a Servlet in a server like Tomcat.  It's beyond the scope here to explain Servlets, but that's the key.

    Following is the code I used to create an XLLoop servlet:


    package com.mypackage;

    import javax.servlet.*;

    import org.boris.xlloop.handler.*;
    import org.boris.xlloop.http.*;

    public class MyFunctionServlet extends FunctionServlet
    {
    @Override
    public void init(final ServletConfig config) throws ServletException
    {
    FunctionInformationHandler infoHandler = new FunctionInformationHandler();
    MyFunctionHandler myHandler = new MyFunctionHandler();
    infoHandler.add(myHandler.getFunctionInformation());
    CompositeFunctionHandler compositeHandler = new CompositeFunctionHandler();
    compositeHandler.add(infoHandler);
    compositeHandler.add(myHandler);
    setHandler(compositeHandler);
    }
    }


    Here's an example of adding the new Servlet to the web.xml of tomcat:

    <servlet>
    <servlet-name>xlloopfunction</servlet-name>
    <servlet-class>com..mypackage.MyFunctionServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>xlloopfunction</servlet-name>
    <url-pattern>/service/xlloopfunction</url-pattern>
    </servlet-mapping>


    Here is the xlloop.ini file I used with the Excel add-in:

    protocol=http
    url=http://localhost:8080/myapp/service/xlloopfunction

     
  • Nobody/Anonymous

    Thanks.  That's exactly what I was looking for.

     

Log in to post a comment.