You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Burkard Stephan <St...@visana.ch> on 2018/08/13 11:04:00 UTC

CXF without generated Java objects?

Hi CXF users

I have built a CXF web service (with Apache Camel on top) that calls another downstream web service as client. 

I am transforming requests and responses with XSLT. Therefore I would not need the generated Java objects at all. But CXF generates them during the Maven build. 

For example the configuration of the downstream endpoint is like this (I simplified names): 

    @Bean(name = "myEndpoint")
    public CxfEndpoint client(final CamelContext camelContext,
            final MyTokenInterceptor myTokenInterceptor) {
        final CxfComponent cxfComponent = new CxfComponent(camelContext);
        final CxfEndpoint serviceEndpoint = new CxfEndpoint("", cxfComponent);

        QName serviceName = new QName([namespace], "[serviceName]");
        QName portName = new QName([namespace], "[portName]");
        serviceEndpoint.setServiceName(serviceName);
        serviceEndpoint.setPortName(portName);

        serviceEndpoint.setAddress([endpointUrl]);
        serviceEndpoint.setDataFormat(DataFormat.PAYLOAD);
        serviceEndpoint.getOutInterceptors().add(myTokenInterceptor);
        serviceEndpoint.setLoggingFeatureEnabled(true);
        return serviceEndpoint;
    }

Is it possible to configure a CXF endpoint that does not generate the classes? Or does CXF need them anyway to do its job?

I also read about the [XSLT feature](http://cxf.apache.org/docs/xslt-feature.html) of CXF. The configuration examples reference an implementor class, but how would this class look like, what are input and return types of the operations if I don't have generated classes? Unfortunately I did not found a good example project that uses this feature. Is there such a project in the CXF repository?

Thanks for your help
Stephan
 


Re: CXF without generated Java objects?

Posted by Daniel Kulp <dk...@apache.org>.
> Is it also possible to just annotate the class with "@WebServiceProvider" (without annotation arguments) and add port, wsdl location etc in the endpoint configuration?

Instead of using  the pure jaxws Endpoint.create/publish and new EndpointImpl, you MAY be able to use the JaxWsServerFactoryBean.   Definitely more to configure, but the JaxWsServerFactoryBean (and it’s parent class and contained JaxWsServiceFactoryBean) have a bunch of setters and such for configuring the things that are normally queried via the annotations.  Thus, it’s possible, but you’ll likely need to dig in to a bunch of those things to figure out all the incantations that will be required.  


Dan



> On Sep 5, 2018, at 10:35 AM, Burkard Stephan <St...@visana.ch> wrote:
> 
> Great, exactly what I was looking for.
> 
> I have written a Provider<Source> implementation. Because a "god" implementation in the invoke method of the provider is evil, I have built some kind of a dispatcher that delegates the implementation of the web service operations to their own classes. 
> 
> Therefore the Provider<Source> code is now completely generic - except for the annotations:
> 
> @WebServiceProvider(portName = "GreeterPort", serviceName = "GreeterService",
>        targetNamespace = "http://apache.org/hello_world_soap_http",
>        wsdlLocation = "/wsdl/hello_world_wrap.wsdl")
> @ServiceMode()
> public class SourceProvider implements Provider<Source> {...}
> 
> 
> Is it also possible to just annotate the class with "@WebServiceProvider" (without annotation arguments) and add port, wsdl location etc in the endpoint configuration?
> 
> My endpoint config currently looks like this: 
> 
>    @Bean
>    public Endpoint greeterEndpoint() {
>        EndpointImpl endpoint = new EndpointImpl(cxfBus, SourceProvider());
>        endpoint.getFeatures().add(new LoggingFeature());
>        endpoint.publish(servicePath);
>        return endpoint;
>    }
> 
> Thanks a lot 
> Stephan
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Daniel Kulp <dk...@apache.org> 
> Gesendet: Mittwoch, 29. August 2018 20:47
> An: users@cxf.apache.org; Burkard Stephan <St...@visana.ch>
> Betreff: Re: CXF without generated Java objects?
> 
> 
> The JAX-WS “Provider” interface is used to create services that consume generic XML.  You could then use normal javax.xml.transform stuff to transform the XML.  
> 
> You could look at the jaxws_dispatch_provider sample:
> 
> https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider <https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider>
> 
> 
> It has a GreeterDOMSourcePayloadProvider which implements Provider<DOMSource>.
> 
> 
> Dan
> 
> 
> 
>> On Aug 16, 2018, at 7:09 AM, Burkard Stephan <St...@visana.ch> wrote:
>> 
>> Hi Colm
>> 
>> Thanks. The "xslt-server" in this test is a "normal" CXF endpoint that
>> 
>> - references the WSDL (and generates Java objects from it)
>> - references an implementor class 
>> org.apache.cxf.systest.soap.DoubleItImpl that creates a response
>> 
>> Then the generated response is post-processed with XSL. 
>> 
>> ==> Is this the targeted use case for the XSLT feature? 
>> 
>> 
>> In my case the service implementation is completely XSL. Therefore
>> 
>> - I don't need generated Java objects
>> - I don't need an implementor class
>> 
>> I just want to
>> 
>> - check request security (CXF validators)
>> - transform the client request (XSLT feature)
>> - continue with the result from the transformation  (this can be a 
>> response, but also a request for a downstream call, it depends)
>> 
>> ==> Can I create a CXF web service without Java objects/implementation? 
>> 
>> Thanks
>> Stephan
>> 
>> 
>> -----Ursprüngliche Nachricht-----
>> Von: Colm O hEigeartaigh <co...@apache.org>
>> Gesendet: Donnerstag, 16. August 2018 11:14
>> An: users@cxf.apache.org
>> Betreff: Re: CXF without generated Java objects?
>> 
>> On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan 
>> <Stephan.Burkard@visana.ch
>>> wrote:
>> 
>>> 
>>> I also read about the [XSLT feature](http://cxf.apache.
>>> org/docs/xslt-feature.html) of CXF. The configuration examples 
>>> reference an implementor class, but how would this class look like, 
>>> what are input and return types of the operations if I don't have generated classes?
>>> Unfortunately I did not found a good example project that uses this 
>>> feature. Is there such a project in the CXF repository?
>>> 
>> 
>> For an example project that uses the XSLT feature, please refer to the following system test:
>> 
>> Client code:
>> 
>> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
>> est/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
>> 
>> Server spring configuration:
>> 
>> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
>> est/resources/org/apache/cxf/systest/soap/xslt-server.xml
>> 
>> Colm.
>> 
>> 
>>> 
>>> Thanks for your help
>>> Stephan
>>> 
>>> 
>>> 
>> 
>> 
>> --
>> Colm O hEigeartaigh
>> 
>> Talend Community Coder
>> http://coders.talend.com
> 
> --
> Daniel Kulp
> dkulp@apache.org <ma...@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog> Talend Community Coder - http://talend.com <http://coders.talend.com/>

-- 
Daniel Kulp
dkulp@apache.org <ma...@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog>
Talend Community Coder - http://talend.com <http://coders.talend.com/>

AW: CXF without generated Java objects?

Posted by Burkard Stephan <St...@visana.ch>.
Great, exactly what I was looking for.

I have written a Provider<Source> implementation. Because a "god" implementation in the invoke method of the provider is evil, I have built some kind of a dispatcher that delegates the implementation of the web service operations to their own classes. 

Therefore the Provider<Source> code is now completely generic - except for the annotations:

@WebServiceProvider(portName = "GreeterPort", serviceName = "GreeterService",
        targetNamespace = "http://apache.org/hello_world_soap_http",
        wsdlLocation = "/wsdl/hello_world_wrap.wsdl")
@ServiceMode()
public class SourceProvider implements Provider<Source> {...}


Is it also possible to just annotate the class with "@WebServiceProvider" (without annotation arguments) and add port, wsdl location etc in the endpoint configuration?

My endpoint config currently looks like this: 

    @Bean
    public Endpoint greeterEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(cxfBus, SourceProvider());
        endpoint.getFeatures().add(new LoggingFeature());
        endpoint.publish(servicePath);
        return endpoint;
    }

Thanks a lot 
Stephan


-----Ursprüngliche Nachricht-----
Von: Daniel Kulp <dk...@apache.org> 
Gesendet: Mittwoch, 29. August 2018 20:47
An: users@cxf.apache.org; Burkard Stephan <St...@visana.ch>
Betreff: Re: CXF without generated Java objects?


The JAX-WS “Provider” interface is used to create services that consume generic XML.  You could then use normal javax.xml.transform stuff to transform the XML.  

You could look at the jaxws_dispatch_provider sample:

https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider <https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider>


It has a GreeterDOMSourcePayloadProvider which implements Provider<DOMSource>.


Dan



> On Aug 16, 2018, at 7:09 AM, Burkard Stephan <St...@visana.ch> wrote:
> 
> Hi Colm
> 
> Thanks. The "xslt-server" in this test is a "normal" CXF endpoint that
> 
> - references the WSDL (and generates Java objects from it)
> - references an implementor class 
> org.apache.cxf.systest.soap.DoubleItImpl that creates a response
> 
> Then the generated response is post-processed with XSL. 
> 
> ==> Is this the targeted use case for the XSLT feature? 
> 
> 
> In my case the service implementation is completely XSL. Therefore
> 
> - I don't need generated Java objects
> - I don't need an implementor class
> 
> I just want to
> 
> - check request security (CXF validators)
> - transform the client request (XSLT feature)
> - continue with the result from the transformation  (this can be a 
> response, but also a request for a downstream call, it depends)
> 
> ==> Can I create a CXF web service without Java objects/implementation? 
> 
> Thanks
> Stephan
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Colm O hEigeartaigh <co...@apache.org>
> Gesendet: Donnerstag, 16. August 2018 11:14
> An: users@cxf.apache.org
> Betreff: Re: CXF without generated Java objects?
> 
> On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan 
> <Stephan.Burkard@visana.ch
>> wrote:
> 
>> 
>> I also read about the [XSLT feature](http://cxf.apache.
>> org/docs/xslt-feature.html) of CXF. The configuration examples 
>> reference an implementor class, but how would this class look like, 
>> what are input and return types of the operations if I don't have generated classes?
>> Unfortunately I did not found a good example project that uses this 
>> feature. Is there such a project in the CXF repository?
>> 
> 
> For an example project that uses the XSLT feature, please refer to the following system test:
> 
> Client code:
> 
> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
> est/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
> 
> Server spring configuration:
> 
> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
> est/resources/org/apache/cxf/systest/soap/xslt-server.xml
> 
> Colm.
> 
> 
>> 
>> Thanks for your help
>> Stephan
>> 
>> 
>> 
> 
> 
> --
> Colm O hEigeartaigh
> 
> Talend Community Coder
> http://coders.talend.com

--
Daniel Kulp
dkulp@apache.org <ma...@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog> Talend Community Coder - http://talend.com <http://coders.talend.com/>

Re: CXF without generated Java objects?

Posted by Daniel Kulp <dk...@apache.org>.
The JAX-WS “Provider” interface is used to create services that consume generic XML.  You could then use normal javax.xml.transform stuff to transform the XML.  

You could look at the jaxws_dispatch_provider sample:

https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider <https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jaxws_dispatch_provider>


It has a GreeterDOMSourcePayloadProvider which implements Provider<DOMSource>.


Dan



> On Aug 16, 2018, at 7:09 AM, Burkard Stephan <St...@visana.ch> wrote:
> 
> Hi Colm
> 
> Thanks. The "xslt-server" in this test is a "normal" CXF endpoint that
> 
> - references the WSDL (and generates Java objects from it)
> - references an implementor class org.apache.cxf.systest.soap.DoubleItImpl that creates a response
> 
> Then the generated response is post-processed with XSL. 
> 
> ==> Is this the targeted use case for the XSLT feature? 
> 
> 
> In my case the service implementation is completely XSL. Therefore 
> 
> - I don't need generated Java objects
> - I don't need an implementor class
> 
> I just want to 
> 
> - check request security (CXF validators)
> - transform the client request (XSLT feature)
> - continue with the result from the transformation 
>  (this can be a response, but also a request for a downstream call, it depends)
> 
> ==> Can I create a CXF web service without Java objects/implementation? 
> 
> Thanks
> Stephan
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Colm O hEigeartaigh <co...@apache.org> 
> Gesendet: Donnerstag, 16. August 2018 11:14
> An: users@cxf.apache.org
> Betreff: Re: CXF without generated Java objects?
> 
> On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan <Stephan.Burkard@visana.ch
>> wrote:
> 
>> 
>> I also read about the [XSLT feature](http://cxf.apache.
>> org/docs/xslt-feature.html) of CXF. The configuration examples 
>> reference an implementor class, but how would this class look like, 
>> what are input and return types of the operations if I don't have generated classes?
>> Unfortunately I did not found a good example project that uses this 
>> feature. Is there such a project in the CXF repository?
>> 
> 
> For an example project that uses the XSLT feature, please refer to the following system test:
> 
> Client code:
> 
> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
> 
> Server spring configuration:
> 
> https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml
> 
> Colm.
> 
> 
>> 
>> Thanks for your help
>> Stephan
>> 
>> 
>> 
> 
> 
> --
> Colm O hEigeartaigh
> 
> Talend Community Coder
> http://coders.talend.com

-- 
Daniel Kulp
dkulp@apache.org <ma...@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog>
Talend Community Coder - http://talend.com <http://coders.talend.com/>

AW: CXF without generated Java objects?

Posted by Burkard Stephan <St...@visana.ch>.
Hi Colm

Thanks. The "xslt-server" in this test is a "normal" CXF endpoint that

- references the WSDL (and generates Java objects from it)
- references an implementor class org.apache.cxf.systest.soap.DoubleItImpl that creates a response

Then the generated response is post-processed with XSL. 

==> Is this the targeted use case for the XSLT feature? 


In my case the service implementation is completely XSL. Therefore 

- I don't need generated Java objects
- I don't need an implementor class

I just want to 

- check request security (CXF validators)
- transform the client request (XSLT feature)
- continue with the result from the transformation 
  (this can be a response, but also a request for a downstream call, it depends)

==> Can I create a CXF web service without Java objects/implementation? 

Thanks
Stephan


-----Ursprüngliche Nachricht-----
Von: Colm O hEigeartaigh <co...@apache.org> 
Gesendet: Donnerstag, 16. August 2018 11:14
An: users@cxf.apache.org
Betreff: Re: CXF without generated Java objects?

On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan <Stephan.Burkard@visana.ch
> wrote:

>
> I also read about the [XSLT feature](http://cxf.apache.
> org/docs/xslt-feature.html) of CXF. The configuration examples 
> reference an implementor class, but how would this class look like, 
> what are input and return types of the operations if I don't have generated classes?
> Unfortunately I did not found a good example project that uses this 
> feature. Is there such a project in the CXF repository?
>

For an example project that uses the XSLT feature, please refer to the following system test:

Client code:

https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java

Server spring configuration:

https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml

Colm.


>
> Thanks for your help
> Stephan
>
>
>


--
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Re: CXF without generated Java objects?

Posted by Colm O hEigeartaigh <co...@apache.org>.
On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan <Stephan.Burkard@visana.ch
> wrote:

>
> I also read about the [XSLT feature](http://cxf.apache.
> org/docs/xslt-feature.html) of CXF. The configuration examples reference
> an implementor class, but how would this class look like, what are input
> and return types of the operations if I don't have generated classes?
> Unfortunately I did not found a good example project that uses this
> feature. Is there such a project in the CXF repository?
>

For an example project that uses the XSLT feature, please refer to the
following system test:

Client code:

https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java

Server spring configuration:

https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml

Colm.


>
> Thanks for your help
> Stephan
>
>
>


-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com