Hi!

I would like develop a embedded XFire HTTP Server that has registered a POJO
Web service.

The sample code (from the embedded XFire HTTP Server) defines the url of the
web service as:

http://<hostname>:<port>/Echo

I want to change this to:

http://<hostname>:<port>/test/service/Echo.

How will I go about this?

Thanks!

Regards,

Jonathan
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.server.http.XFireHttpServer;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.service.invoker.BeanInvoker;
import org.codehaus.xfire.test.Echo;
import org.codehaus.xfire.test.EchoImpl;
//import java.net.URL;

/**
 * Creates an Echo service and exposes it via HTTP.
 */
public class ServiceStarter
{
    XFireHttpServer server;
    
    public void start() 
    {
    	try{
            // Create an XFire Service
            ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
            Service service = serviceFactory.create(Echo.class);
            service.setInvoker(new BeanInvoker(new EchoImpl()));
            
            // Register the service in the ServiceRegistry
            XFire xfire = XFireFactory.newInstance().getXFire();
            xfire.getServiceRegistry().register(service);
            
            // Start the HTTP server
            server = new XFireHttpServer();
            server.setPort(8191);
            server.start();
    		
    	} catch (Exception e){
    		System.out.println("Error2: "+e.getMessage());
    		
    	}
    }
    
    public void stop() throws Exception
    {
        server.stop();
    }
}
public class EchoImpl
        implements Echo
{
    public String echo(String echo)
    {
        return echo;
    }
}
public interface Echo
{
    String echo(String echo);
}
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;


/**
 * @author BaMBaM
 *
 */
public class TestXFire {

	/**
	 * 
	 */
	public TestXFire() {
		try{
			ServiceStarter starter = new ServiceStarter();
			starter.start();

			
//			 Create a service model for the client
			ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
			Service serviceModel = serviceFactory.create(Echo.class);
			
//			 Create a client proxy
			XFireProxyFactory proxyFactory = new XFireProxyFactory();
			Echo echo = (Echo) proxyFactory.create(serviceModel, "http://localhost:8191/Echo";);

			System.out.println(echo.echo("Hello World"));

			starter.stop();


		} catch (Exception e){
			System.out.println("Error: "+e.getMessage());
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new TestXFire();

	}

}
---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to