Err... Why not host your cxf services as a servlet in Tomcat, and run your other web site as the ROOT webapp?

Or insert favourite servlet container above.

Andrew.


On 23 Feb 2009, at 19:06, Garry Watkins <garry.watk...@gmail.com> wrote:

I have an application that I need both a web server, and webservices
to run together on the same port.  How do I configure cxf to work?

Example

I need to run on http://192.168.10.100:9000/
   From this directory I will serve misc html and resources for a flex
application

Then I need to run two different web services

http://192.168.10.100:9000/ws/SomeWebService1
http://192.168.10.100:9000/ws/SomeWebService2

How do I set this up?

This is what I have so far.  Please help I have been beating myself up
all morning.  I would also prefer to do this without the spring
configuration.  I already have a zillion jars so I don't really want
that many more.

TIA

Garry

   private void setupHTTPServer(Properties props) throws Exception {
       SelectChannelConnector con = new SelectChannelConnector();
       String ipAddress = props.getProperty(HTTP_IP_ADDRESS);
       con.setHost(ipAddress);

       int port = 8080;
       try {
           port =
Integer.parseInt(props.getProperty("slx.http.port"));
       }
       catch(NumberFormatException nfe){
           // do nothing default to 8080
       }
           con.setPort(port);

           JettyHTTPServerEngineFactory sef = new
JettyHTTPServerEngineFactory();
           JettyHTTPServerEngine eng =
sef.createJettyHTTPServerEngine(port, "http");
           eng.setConnector(con);

           List<Handler> handlers = new ArrayList<Handler>();
       ResourceHandler resource_handler = new ResourceHandler();
       resource_handler.setResourceBase("../webServerRoot");
       handlers.add(resource_handler);

       ServletHandler servlet_handler = new ServletHandler();
       servlet_handler.addServletWithMapping(, "/MasterStatus");
servlet_handler.addServletWithMapping(SendEmployeesServlet.class, "/
SendEmployees");

       handlers.add(servlet_handler);

       eng.setHandlers(handlers);
   }

   private void setupServices(Properties props) throws Exception {
       String ipAddress = props.getProperty(HTTP_IP_ADDRESS);
       String port = props.getProperty(HTTP_PORT);
       Enumeration<?> keys = props.keys();
       while(keys.hasMoreElements()){
           String key = (String)keys.nextElement();
           if (key.startsWith(WEB_SERVICE_URL)){
String url = props.getProperty(key).replace("{http.ipAddress}",
ipAddress).replace("{http.port}", port);

               String subKey = key.replaceFirst(WEB_SERVICE_URL, "");
               String implKey = WEB_SERVICE_IMPL + subKey;
               String implClassName = props.getProperty(implKey);

               Class<?> klass = Class.forName(implClassName);
Constructor<?> konstr = klass.getConstructor(new Class[]{});
               Object svcImpl = konstr.newInstance(new Object[]{});

JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
               svrFactory.setServiceClass(klass);
               svrFactory.setAddress(url);
               svrFactory.setServiceBean(svcImpl);

               svrFactory.create();
           }
       }
   }

Reply via email to