You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Rastislav Cesnek <ra...@whitestein.com> on 2013/01/15 10:41:50 UTC
Advice on specific CXF use
Hi.
I am looking for an advice on CXF use in the following scenario.
In a J2EE application, I need to publish/unpublish services dynamically
on the server side based on WSDLs (uploaded at runtime) and not have
specific service implementations running behind the services.
To be more specific:
- I need to create Service representations from WSDLs on the fly and
publish them (or unpublish them)
- I would like to use CXF to its full potential doing the SOAP stack
stuff (message processing, addressing, determining endpoint, operation,
etc.) based on the SOAP messages received
- (Possibly implement a custom data binding, i.e. convert the message
contents to a custom representation)
- Process all the messages that passed through CXF by a SINGLE
processor, which will then determine what to do with the message further.
Basic idea I have is to have a Servlet in the app which receives the
HTTP requests and then passes them to CXF (configured programmatically).
Can this be done? Any hints or advices on how this can be done are welcome.
Thx.
Re: Advice on specific CXF use
Posted by Rastislav Cesnek <ra...@whitestein.com>.
My experiments currently lead me to something like this (very simple
right now, WSDL and XSDs must come from DB, etc.):
I use CXFNonSpringServlet (so far I experimentally create the service in
init method):
Bus bus = getBus();
WSDLServiceFactory f = new WSDLServiceFactory(bus,
getClass().getResource("/TestService.wsdl"));
Service service = f.create();
service.setInvoker(new InvokerImpl());
service.setDataBinding(new SourceDataBinding(Node.class));
bus.getInInterceptors().add(WSDLGetInterceptor.INSTANCE);
bus.getInInterceptors().add(new ServiceInvokerInterceptor());
bus.getInInterceptors().add(new OutgoingChainInterceptor());
bus.getInInterceptors().add(new OneWayProcessorInterceptor());
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
ei.setAddress("/" + ei.getService().getName().getLocalPart() + "/"
+ ei.getBinding().getName().getLocalPart());
Endpoint ep = new EndpointImpl(bus, service, ei);
service.getEndpoints().put(ei.getName(), ep);
}
}
for (Endpoint ep : service.getEndpoints().values()) {
EndpointInfo ei = ep.getEndpointInfo();
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
BindingFactory bf = bfm.getBindingFactory(ei.getBinding().getBindingId());
Server server = new ServerImpl(bus, ep, null, bf);
server.start();
}
public class InvokerImpl implements Invoker {
@Override
public Object invoke(Exchange exchange, Object o) {
log.error("InvokerImpl.invoke");
return null;
}
}
On 17. 1. 2013 20:46, Daniel Kulp wrote:
> On Jan 15, 2013, at 4:41 AM, Rastislav Cesnek <ra...@whitestein.com> wrote:
>
>> Hi.
>>
>> I am looking for an advice on CXF use in the following scenario.
>>
>> In a J2EE application, I need to publish/unpublish services dynamically
>> on the server side based on WSDLs (uploaded at runtime) and not have
>> specific service implementations running behind the services.
>>
>> To be more specific:
>> - I need to create Service representations from WSDLs on the fly and
>> publish them (or unpublish them)
>> - I would like to use CXF to its full potential doing the SOAP stack
>> stuff (message processing, addressing, determining endpoint, operation,
>> etc.) based on the SOAP messages received
>> - (Possibly implement a custom data binding, i.e. convert the message
>> contents to a custom representation)
>> - Process all the messages that passed through CXF by a SINGLE
>> processor, which will then determine what to do with the message further.
>>
>> Basic idea I have is to have a Servlet in the app which receives the
>> HTTP requests and then passes them to CXF (configured programmatically).
>>
>> Can this be done? Any hints or advices on how this can be done are welcome.
> This is pretty much how the Provider<Source> based services would work in CXF. You can have a Provider<Source> class that is generic that you can publish/unpublish anytime using any WSDL. All the messages would come into the invoke(…) method where you could do whatever you need to it.
>
>
Please, notice that Whitestein Slovakia has moved to a new location.
Prosím, všimnite si že Whitestein Slovensko sa presťahovalo na novú adresu.
--
Rastislav Cesnek | rac@whitestein.com
Senior Software Engineer | Advanced Technologies
Whitestein Technologies s.r.o. | www.whitestein.com
Moskovská 13 | 811 08 Bratislava | Slovak Republic
Main +421 2 5443-5502
Re: Advice on specific CXF use
Posted by Daniel Kulp <dk...@apache.org>.
On Jan 15, 2013, at 4:41 AM, Rastislav Cesnek <ra...@whitestein.com> wrote:
> Hi.
>
> I am looking for an advice on CXF use in the following scenario.
>
> In a J2EE application, I need to publish/unpublish services dynamically
> on the server side based on WSDLs (uploaded at runtime) and not have
> specific service implementations running behind the services.
>
> To be more specific:
> - I need to create Service representations from WSDLs on the fly and
> publish them (or unpublish them)
> - I would like to use CXF to its full potential doing the SOAP stack
> stuff (message processing, addressing, determining endpoint, operation,
> etc.) based on the SOAP messages received
> - (Possibly implement a custom data binding, i.e. convert the message
> contents to a custom representation)
> - Process all the messages that passed through CXF by a SINGLE
> processor, which will then determine what to do with the message further.
>
> Basic idea I have is to have a Servlet in the app which receives the
> HTTP requests and then passes them to CXF (configured programmatically).
>
> Can this be done? Any hints or advices on how this can be done are welcome.
This is pretty much how the Provider<Source> based services would work in CXF. You can have a Provider<Source> class that is generic that you can publish/unpublish anytime using any WSDL. All the messages would come into the invoke(…) method where you could do whatever you need to it.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com