Hi Willem, hi Dan,

thanks for your help. At the moment I am using the RC. After I added the two lines to set the default bus it worked for both ways of publishing (Endpoint and JaxWsServerFactoryBean). And now that I know that this is possible I only use relative uris to publish my services.

Using the JaxWsClientFactoryBean I can also create a simple client. There are some issues when using the client but so far I have only used the RC. When I find the time I will try it out with the current trunk and check if my problems persist.

The things I came across are :
- if I invoke a remote operation with one of the parameters set to null I get an exception stating that a parameter is missing - I cannot use classes that are marked as final in the service interface (maybe that’s by purpose?). (_org.apache.ws.commons.schema.constants.Enum$EnumValueException_: Bad Enumeration value 'extension restriction') - the xml message send by the client has element names like arg11 arg00 instead of the names defined by the wsdl. But somehow it works properly. - in request from the client: every element defines a prefix for the ws-addressing namespace although the prefix is never used - in request from the client: the elements for my parameters define a prefix for the namespace of the element although the parent element already defines a prefix for this namespace

As I wrote these might be old issues which are already reported or solved. If some of them remain for the current trunk I will get back to you.

Thanks again!

Fabian

P.S. What is the current process for editing the docu wiki. Is everybody welcome to perform changes? I could add some lines on how to programmatically use the spring servlet with the note that you need to set the bus properly. On the other hand I am maybe the only guy who does that? And the recommendation to use a relative path should definetly be added to the docs (I did not see it there) ...



Willem Jiang wrote, On 31.05.2007 01:34:
Hi Fabian,

There is a Jetty transport factory which responsible is to handle the http transport with the embedded Jetty in CXF, we call the service which is published by that way, a standalone server. We also support to publish the service with CXFServlet transport. It is much like the Xfire Servlet dose. You definitely can start a Jetty HTTPServer and register the CXFServlet to it then publish the service with JAXWS API or JaxWsServerFactoryBean. But most important thing you need to take care is the bus instance, it is newer to Xfire user. You can find more information about the CXF bus from [1].
I also found there some error in the document [2], I will fix soon.

I just changed some of you below codes and ran with latest CXF trunk, it works. You can access the service with http://localhost:9000/services/GreeterImpl
You also can get the services list form http://localhost:9000/services

Server httpServer = new Server(9000);
ContextHandlerCollection contexts = new ContextHandlerCollection();
httpServer.setHandler(contexts);
Context root = new Context(contexts,"/services",Context.SESSIONS);
CXFServlet servlet = new CXFServlet();
root.addServlet(new ServletHolder(servlet), "/*");
httpServer.start();
// set the default bus which is initiated for CXFServlet for jaxws API or JaxWsServerFactoryBean to use
Bus bus = servlet.getBus();
// there is no bus definition in the JAXWS API, so we need to set the default bus.
BusFactory.setDefaultBus(bus);
// register service, the address should start with "/"
String uri = "/" + GreeterImpl.class.getSimpleName();
Endpoint endpoint = Endpoint.create(new GreeterImpl());
endpoint.publish(uri);


[1] http://cwiki.apache.org/CXF20DOC/cxf-architecture.html
[2] http://cwiki.apache.org/CXF20DOC/servlet-transport.html

Cheers,

Willem.


Fabian wrote:
Hi!

I started to have a look at CXF today. In XFire I was able to start a Jetty HTTPServer, register the XFireServlet and later make services available via the XFire ServiceRegistry.So I was able to use a Jetty HTTPServer I created myself. I would like to do the same with CXF.

Using the JaxWsServerFactoryBean as suggested in the Migration Guide does not work because I want to reuse the HTTPServer I already have and don't want to start a new one (under another port). So I thought the CXFServlet should be the proper replacement. But I am not sure what I need to do to register a new service. Calling Endpoint.create() as explained in http://cwiki.apache.org/CXF20DOC/servlet-transport.html does not work. (I can request the service list at http://localhost:8080/services but the list is empty). So I guess I have to do something with my Endpoint but what?

// jetty
Server httpServer = new Server(8080); Context xfireContext = new Context(httpServer, "/services"); xfireContext.addServlet(CXFServlet.class.getName(), "/*"); httpServer.start();
// register service
String uri = "http://localhost:8080/services/"; + ServiceImplementation.class.getSimpleName();
Endpoint.create(uri, new ServiceImplementation());

Maybe one of you can give me a tip which way to go here.

Thanks!

Fabian


P.S. In XFire it worked like this

Server httpServer = new Server(8080); Context xfireContext = new Context(httpServer, "/services"); xfireContext.addServlet(XFireServlet.class.getName(), "/*"); httpServer.start();

[....]

XFire xfire = XFireFactory.newInstance().getXFire();

// create service
AnnotationServiceFactory factory = new AnnotationServiceFactory(xfire.getTransportManager())
Service service = factory.create(serviceImplementation.getClass());
service.setInvoker(new BeanInvoker(serviceImplementation));

// register
ServiceRegistry serviceRegistry = xfire.getServiceRegistry()
serviceRegistry.register(service);







Reply via email to