jSoapServer is a open source embedded Soap Server in java, the source code and lasted version could be got from http://jsoapserver.sourceforge.net. The newest version of it is 0.2.8.

After downloaded, you may like to run the server to check what it done and how it looks, the start scripts are stored in the folder “bin”. it works, with a default service “test”, you should input “http://localhost:8090/test” in internet navigator to check the WSDL.

It is great that jSoapServer could run in “embedded” mode, it means that the server could start with your application without Tomcat, Weblogic, or others J2EE containers.

You can got how to run it in the source code “SoapServer.java”. You can see that there are two files needed for SoapServer, one is “jSoapServer.xml” , another is "source/org/jSoapServer/deployRPC.wsdd". The preceding file targets to set the Soap/TCP environment, and the later one  targets to build WSDL for each services hosted.

When I tried to embedded it in my own source code, I found that the service registering always returned “null”, I checked the source code, I found that the second file needed could not be found in the folder/jar files, so I decided to do some crack on it.

Further more, almost all of the configuration items in “jSoapServer.xml” could keep the default value, the hot point may be the listen port number. I want my system looks clean and more less dependency, so I want to remove the “jSoapServer.xml” dependency and make my code to configure the server.

The following source code shows how to do it,enjoy it in your code.

public static void main(String args[])
    {
        try
        {
            // creating a new soap server
            SoapServer myServer = new SoapServer()
            {
               public String loadDeploymentStringTemplate(String serviceClassName,String serviceName)
                    throws IOException
                {
                    return "<deployment"
                        + "    xmlns=\"
http://xml.apache.org/axis/wsdd/\""
                        + "    xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\" >"
                        + "    <service name=\"@serviceName@\" provider=\"java:RPC\">"
                        + "        <parameter name=\"typeMappingVersion\" value=\"1.1\"/>"
                        + "          <parameter name=\"scope\" value=\"Request\"/>"
                        + "          <parameter name=\"className\" value=\"@serviceClassName@\" />"
                        + "        <parameter name=\"allowedMethods\" value=\"*\" />"
                        + "    </service>"
                        + "</deployment>";

                }
            };

            // configuring the server properties
            QuickServerConfig config = new QuickServerConfig();
            config.setBindAddr("0.0.0.0");
            config.setName("Bank flow service");
            config.setPort(8090);
            config.setClientEventHandler("org.jSoapServer.SoapHandler");
            config.setClientBinaryHandler("org.jSoapServer.SoapHandler");
            config.setClientExtendedEventHandler("org.jSoapServer.SoapHandler");
            config.setClientData("org.jSoapServer.SoapData");
            DefaultDataMode mode = new DefaultDataMode();
            mode.setDataModeIn("Binary");
            mode.setDataModeOut("Binary");
            config.setDefaultDataMode(mode);

            ServerMode servermode = new ServerMode();
            servermode.setBlocking(true);
            config.setServerMode(servermode);

            config.setTimeout(60000);
            config.setTimeoutMsg("-Error, Timeout");

            InitServerHooks ks = new InitServerHooks();
            ks.addClassName("org.jSoapServer.SetupLoggingHook");
            config.setInitServerHooks(ks);

            config.setMaxConnection( -1);
            config.setMaxConnectionMsg("Server Busy. Max Connection Reached");

            config.setConsoleLoggingLevel("WARNING");
            config.setConsoleLoggingFormatter("org.quickserver.util.logging.MiniFormatter");

            ObjectPoolConfig opc = new ObjectPoolConfig();
            opc.setMaxActive( -1);
            opc.setMaxIdle(50);

            ThreadObjectPoolConfig topc = new ThreadObjectPoolConfig();
            topc.setMaxActive(200);
            topc.setMaxIdle(50);
            opc.setThreadObjectPoolConfig(topc);

            ClientHandlerObjectPoolConfig chopc = new ClientHandlerObjectPoolConfig();
            chopc.setMaxActive( -1);
            chopc.setMaxIdle(50);
            opc.setClientHandlerObjectPoolConfig(chopc);

            ByteBufferObjectPoolConfig bbopc = new ByteBufferObjectPoolConfig();
            bbopc.setMaxActive(500);
            bbopc.setMaxIdle(50);
            opc.setByteBufferObjectPoolConfig(bbopc);

            ClientDataObjectPoolConfig cdopc = new ClientDataObjectPoolConfig();
            cdopc.setMaxActive( -1);
            cdopc.setMaxIdle(50);
            opc.setClientDataObjectPoolConfig(cdopc);

            config.setObjectPoolConfig(opc);

            if(myServer.initService(config))
            {
                myServer.deployRpcSoapService("org.jSoapServer.SoapService","test");
                myServer.startServer();
            }
        }
        catch(AppException e)
        {
            System.err.println("Error in server : " + e);
            e.printStackTrace();
        }
    }


Jeason Zhao (沈胜衣,斛律光) ------雪饮再现,一个人的江湖
我知道我是谁,我是沈胜衣,默默的活着,就像空气。