Discussion:
CXF without generated Java objects?
Burkard Stephan
2018-08-13 11:04:00 UTC
Permalink
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
Colm O hEigeartaigh
2018-08-16 09:14:15 UTC
Permalink
Post by Burkard Stephan
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.
Post by Burkard Stephan
Thanks for your help
Stephan
--
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com
Burkard Stephan
2018-08-16 11:09:33 UTC
Permalink
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 <***@apache.org>
Gesendet: Donnerstag, 16. August 2018 11:14
An: ***@cxf.apache.org
Betreff: Re: CXF without generated Java objects?
Post by Burkard Stephan
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.
Post by Burkard Stephan
Thanks for your help
Stephan
--
Colm O hEigeartaigh

Talend Community Coder
http:
Daniel Kulp
2018-08-29 18:47:23 UTC
Permalink
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
Post by Burkard Stephan
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-----
Gesendet: Donnerstag, 16. August 2018 11:14
Betreff: Re: CXF without generated Java objects?
Post by Burkard Stephan
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?
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml
Colm.
Post by Burkard Stephan
Thanks for your help
Stephan
--
Colm O hEigeartaigh
Talend Community Coder
http://coders.talend.com
--
Daniel Kulp
***@apache.org <mailto:***@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog>
Talend Community Coder - http://talend.com <http://coders.talend.com/>
Burkard Stephan
2018-09-05 14:35:40 UTC
Permalink
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 <***@apache.org>
Gesendet: Mittwoch, 29. August 2018 20:47
An: ***@cxf.apache.org; Burkard Stephan <***@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
Post by Burkard Stephan
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-----
Gesendet: Donnerstag, 16. August 2018 11:14
Betreff: Re: CXF without generated Java objects?
On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan
Post by Burkard Stephan
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?
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
est/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
est/resources/org/apache/cxf/systest/soap/xslt-server.xml
Colm.
Post by Burkard Stephan
Thanks for your help
Stephan
--
Colm O hEigeartaigh
Talend Community Coder
http://coders.talend.com
--
Daniel Kulp
***@apache.org <mailto:***@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog> Talend Community Coder - http://talend.com <http://
Daniel Kulp
2018-09-07 17:40:01 UTC
Permalink
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
Post by Burkard Stephan
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.
@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> {...}
@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-----
Gesendet: Mittwoch, 29. August 2018 20:47
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.
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
Post by Burkard Stephan
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-----
Gesendet: Donnerstag, 16. August 2018 11:14
Betreff: Re: CXF without generated Java objects?
On Mon, Aug 13, 2018 at 12:04 PM, Burkard Stephan
Post by Burkard Stephan
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?
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
est/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
https://github.com/apache/cxf/blob/master/systests/uncategorized/src/t
est/resources/org/apache/cxf/systest/soap/xslt-server.xml
Colm.
Post by Burkard Stephan
Thanks for your help
Stephan
--
Colm O hEigeartaigh
Talend Community Coder
http://coders.talend.com
--
Daniel Kulp
--
Daniel Kulp
***@apache.org <mailto:***@apache.org> - http://dankulp.com/blog <http://dankulp.com/blog>
Talend Community Coder - http://talend.com <http://coders.talend.com/>
Loading...