You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by n99 <h....@sheffield.ac.uk> on 2012/06/06 12:31:07 UTC

Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Hello

I've scaffolded a web service server using Spring STS and MyEclipse for
spring and was interested in transforming the out going soap message.

First thing I wanted to transform was the namespace prefixing so my spring
config looked like this

	<jaxws:endpoint xmlns:tns="https://etc etc">
		<jaxws:dataBinding>
			<ref bean="data-binding"/>
        	</jaxws:dataBinding>
	</jaxws:endpoint>


      	<bean ref="data-binding" class="org.apache.cxf.jaxb.JAXBDataBinding">
        	<property name="namespaceMap">
	   	 	<map>
		   		<entry>
      	 			   <key>
		                      <value>http://thing</value>
		                   </key>
                		   <value>BeepBeep</value>
		   		</entry>
      			</map>
	        </property>
      </bean>

this worked fine and my soap message was outputted completely and correctly.

<as>
	<BeepBeep: b>
		<stuff/>
	</BeepBeep:b>
	<c>
	     <more stuff/>
	</c>
</as>

Second I needed to change the soap xml but more than the transform features
at http://cxf.apache.org/docs/transformationfeature.html allowed 

so I read up about the XSLTJaxbProvider at
http://cxf.apache.org/docs/jax-rs-advanced-xml.html and plugging in a rs
provider to a ws binding at
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CXFDataBindingsasJAXRSproviders
to create the following config


<jaxws:endpoint xmlns:tns="https://etc etc">
		<jaxws:dataBinding>
		     <ref bean="jaxrs-data-binding"/>
        </jaxws:dataBinding>
</jaxws:endpoint>

<bean id="jaxrs-data-binding"
class="org.apache.cxf.jaxrs.provider.JAXRSDataBinding">
      		   <property name="namespaceMap">
    	   <map>
   		<entry>
      	 	   <key>
                      <value>http://thing</value>
                   </key>
                   <value>BeepBeep</value>
   		</entry>
      		</map>
        </property>
        <property name="provider" ref="xsltProvider"/>
</bean>

        <bean id="xsltProvider"
class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider"> 
       		<property name="outTemplate"
value="classpath:/WEB-INF/templates/transform.xsl"/>
   	</bean>


now I get an JAXB Exception: Class not known to this context for classes b
and c and even if I have an empty xslt stylesheet I get the xml

<as/>

I have tinkered with the config to every end and added  @XmlSeeAlso all over
the place to no avail.

I guess I have to ask is what I've done possible in config? The fact that it
all works as expected before I try and wire in the rs provider as a ws
databinding might mean it's not?

Any advice greatly appreciated. Maybe there is a better way to use
xslt/manipulate the xml?

Thanks

--
View this message in context: http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-endpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by n99 <h....@sheffield.ac.uk>.
thanks to both of you for all your help.
I'll try again soon and see if I get the same error message..which could be
down to scaffolding off what looks like an odd wsdl. (although the pure
JAXWS path does seem to work..)
cheers

--
View this message in context: http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-endpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183p5709577.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,

On 08/06/12 15:30, Daniel Kulp wrote:
> On Thursday, June 07, 2012 02:56:01 AM n99 wrote:
>> Thanks for that
>> I will try the interceptor.
>>
>> But I'd like to the query the docs at:
>>
>> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CX
>> FDataBindingsasJAXRSproviders
>
> Interesting.  I didn't even know about that.   Cool.   More stuff Sergey did
> when I wasn't watching...  :-)

:-), this JAXRSDataBinding provider was added when one user said that he 
wrote an optimized non-JAXB XML binding provider for a JAX-RS endpoint 
and wanted to use it for processing SOAP requests too.
This provider can manage simple SOAP payloads only, but it's definitely 
for very specific use cases.

>
> Not sure what the issue is.   The XSLTJaxbProvider may not be able to handle
> the XMLStreamReader/Writer forms that the JAX-WS side of things require.
> In JAX-RS, the providers generally use the raw streams with only a couple
> updated to also handle StAX.
>
I have a test working now with the JAXWS frontend posting a payload and 
the JAXWS frontend effectively delegating to XSLTJaxbProvider to 
read/write the data available inside of soap:envelope, there were few 
issues there, but I do not think there were anything to do with the JAXB 
context not seeing some of the classes.

n99, I guess you should proceed with what Dan advised earlier on about 
using XSLT on the JAX-WS path, but please test if you are still 
interested in a day or so, the few minor fixes I'm about to commit would 
be useful for JAX-RS endpoints using XSLTJAXBProvider too

Thanks, Sergey

> Dan
>
>
>
>>
>> the config says
>>
>> <jaxws:endpoint xmlns:s="http://hello.com"
>>        serviceName="s:HelloWorld"
>>        endpointName="s:HelloWorldPort"
>>        id="hello_soap-databinding"
>>        implementor="org.apache.cxf.systest.jaxrs.jaxws.HelloWorldImpl"
>>        address="/hello-soap-databinding">
>>
>>        <jaxws:dataBinding>
>>            <ref bean="jaxrs-data-binding"/>
>>        </jaxws:dataBinding>
>>
>>    </jaxws:endpoint>
>>
>>    <bean id="jaxrs-data-binding"
>> class="org.apache.cxf.jaxrs.provider.JAXRSDataBinding">
>>        <property name="provider" ref="jaxbProviderSoap"/>
>>    </bean>
>>
>>    <bean id="jaxbProviderSoap"
>> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>
>>
>> which I think shows a JAX-RS provider being used ultimately in a CXF
>> DataBinding object?
>>
>>
>> Specifically it shows:
>>
>> a org.apache.cxf.jaxrs.provider.JAXBElementProvider being wired into a
>> org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
>> jaxws:dataBinding in a jaxws:endpoint
>>
>> I was configuring:
>>
>> a org.apache.cxf.jaxrs.provider.XSLTJaxbProvider being wired into a
>> org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
>> jaxws:dataBinding in a jaxws:endpoint
>>
>>
>> .....and org.apache.cxf.jaxrs.provider.XSLTJaxbProvider is a subclass of
>> org.apache.cxf.jaxrs.provider.JAXBElementProvider.......?
>>
>> Cheers
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-e
>> ndpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183p5709344.html
>> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

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

Blog: http://sberyozkin.blogspot.com

Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by n99 <h....@sheffield.ac.uk>.
Hi
Is this a bug then or a limitation of which JAXRS providers you can use as
described in that web page.....
Cheers

--
View this message in context: http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-endpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183p5709573.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday, June 07, 2012 02:56:01 AM n99 wrote:
> Thanks for that
> I will try the interceptor.
> 
> But I'd like to the query the docs at:
> 
> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CX
> FDataBindingsasJAXRSproviders

Interesting.  I didn't even know about that.   Cool.   More stuff Sergey did 
when I wasn't watching...  :-)

Not sure what the issue is.   The XSLTJaxbProvider may not be able to handle 
the XMLStreamReader/Writer forms that the JAX-WS side of things require.   
In JAX-RS, the providers generally use the raw streams with only a couple 
updated to also handle StAX.   

Dan



> 
> the config says
> 
> <jaxws:endpoint xmlns:s="http://hello.com"
>       serviceName="s:HelloWorld"
>       endpointName="s:HelloWorldPort"
>       id="hello_soap-databinding"
>       implementor="org.apache.cxf.systest.jaxrs.jaxws.HelloWorldImpl"
>       address="/hello-soap-databinding">
> 
>       <jaxws:dataBinding>
>           <ref bean="jaxrs-data-binding"/>
>       </jaxws:dataBinding>
> 
>   </jaxws:endpoint>
> 
>   <bean id="jaxrs-data-binding"
> class="org.apache.cxf.jaxrs.provider.JAXRSDataBinding">
>       <property name="provider" ref="jaxbProviderSoap"/>
>   </bean>
> 
>   <bean id="jaxbProviderSoap"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>
> 
> which I think shows a JAX-RS provider being used ultimately in a CXF
> DataBinding object?
> 
> 
> Specifically it shows:
> 
> a org.apache.cxf.jaxrs.provider.JAXBElementProvider being wired into a
> org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
> jaxws:dataBinding in a jaxws:endpoint
> 
> I was configuring:
> 
> a org.apache.cxf.jaxrs.provider.XSLTJaxbProvider being wired into a
> org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
> jaxws:dataBinding in a jaxws:endpoint
> 
> 
> .....and org.apache.cxf.jaxrs.provider.XSLTJaxbProvider is a subclass of
> org.apache.cxf.jaxrs.provider.JAXBElementProvider.......?
> 
> Cheers
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-e
> ndpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183p5709344.html
> Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by n99 <h....@sheffield.ac.uk>.
Thanks for that
I will try the interceptor.

But I'd like to the query the docs at:

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CXFDataBindingsasJAXRSproviders

the config says 

<jaxws:endpoint xmlns:s="http://hello.com"
      serviceName="s:HelloWorld"
      endpointName="s:HelloWorldPort"
      id="hello_soap-databinding"
      implementor="org.apache.cxf.systest.jaxrs.jaxws.HelloWorldImpl"
      address="/hello-soap-databinding">
      
      <jaxws:dataBinding>
          <ref bean="jaxrs-data-binding"/>
      </jaxws:dataBinding>
      
  </jaxws:endpoint>        
 
  <bean id="jaxrs-data-binding"
class="org.apache.cxf.jaxrs.provider.JAXRSDataBinding">
      <property name="provider" ref="jaxbProviderSoap"/>
  </bean>

  <bean id="jaxbProviderSoap"
class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>

which I think shows a JAX-RS provider being used ultimately in a CXF
DataBinding object?


Specifically it shows:

a org.apache.cxf.jaxrs.provider.JAXBElementProvider being wired into a
org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
jaxws:dataBinding in a jaxws:endpoint

I was configuring:

a org.apache.cxf.jaxrs.provider.XSLTJaxbProvider being wired into a
org.apache.cxf.jaxrs.provider.JAXRSDataBinding being used in a
jaxws:dataBinding in a jaxws:endpoint


.....and org.apache.cxf.jaxrs.provider.XSLTJaxbProvider is a subclass of
org.apache.cxf.jaxrs.provider.JAXBElementProvider.......?

Cheers











--
View this message in context: http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-endpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183p5709344.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Using jaxrs XSLTJaxbProvider with jaxws endpoint through JAXRSDataBinding. Is it possible?

Posted by Daniel Kulp <dk...@apache.org>.
 

You're slightly backwords...  :-)

You can use CXF DataBinding objects as JAX-RS providers, but not the other 
way around.   Thus, the JAX-RS XSLT thing isn't usable with a SOAP based 
service.

One option for you may be to configure in the SAAJ interceptor and then 
write a simple interceptor that would take the SAAJ model (it's a DOM) and 
manipulate the SAAJ model, possibly even via XSLT.

Dan


On Wednesday, June 06, 2012 03:31:07 AM n99 wrote:
> Hello
> 
> I've scaffolded a web service server using Spring STS and MyEclipse for
> spring and was interested in transforming the out going soap message.
> 
> First thing I wanted to transform was the namespace prefixing so my spring
> config looked like this
> 
> 	<jaxws:endpoint xmlns:tns="https://etc etc">
> 		<jaxws:dataBinding>
> 			<ref bean="data-binding"/>
>         	</jaxws:dataBinding>
> 	</jaxws:endpoint>
> 
> 
>       	<bean ref="data-binding"
> class="org.apache.cxf.jaxb.JAXBDataBinding"> <property
> name="namespaceMap">
> 	   	 	<map>
> 		   		<entry>
>       	 			   <key>
> 		                      <value>http://thing</value>
> 		                   </key>
>                 		   <value>BeepBeep</value>
> 		   		</entry>
>       			</map>
> 	        </property>
>       </bean>
> 
> this worked fine and my soap message was outputted completely and
> correctly.
> 
> <as>
> 	<BeepBeep: b>
> 		<stuff/>
> 	</BeepBeep:b>
> 	<c>
> 	     <more stuff/>
> 	</c>
> </as>
> 
> Second I needed to change the soap xml but more than the transform
> features at http://cxf.apache.org/docs/transformationfeature.html allowed
> 
> so I read up about the XSLTJaxbProvider at
> http://cxf.apache.org/docs/jax-rs-advanced-xml.html and plugging in a rs
> provider to a ws binding at
> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CX
> FDataBindingsasJAXRSproviders to create the following config
> 
> 
> <jaxws:endpoint xmlns:tns="https://etc etc">
> 		<jaxws:dataBinding>
> 		     <ref bean="jaxrs-data-binding"/>
>         </jaxws:dataBinding>
> </jaxws:endpoint>
> 
> <bean id="jaxrs-data-binding"
> class="org.apache.cxf.jaxrs.provider.JAXRSDataBinding">
>       		   <property name="namespaceMap">
>     	   <map>
>    		<entry>
>       	 	   <key>
>                       <value>http://thing</value>
>                    </key>
>                    <value>BeepBeep</value>
>    		</entry>
>       		</map>
>         </property>
>         <property name="provider" ref="xsltProvider"/>
> </bean>
> 
>         <bean id="xsltProvider"
> class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider">
>        		<property name="outTemplate"
> value="classpath:/WEB-INF/templates/transform.xsl"/>
>    	</bean>
> 
> 
> now I get an JAXB Exception: Class not known to this context for classes b
> and c and even if I have an empty xslt stylesheet I get the xml
> 
> <as/>
> 
> I have tinkered with the config to every end and added  @XmlSeeAlso all
> over the place to no avail.
> 
> I guess I have to ask is what I've done possible in config? The fact that
> it all works as expected before I try and wire in the rs provider as a ws
> databinding might mean it's not?
> 
> Any advice greatly appreciated. Maybe there is a better way to use
> xslt/manipulate the xml?
> 
> Thanks
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Using-jaxrs-XSLTJaxbProvider-with-jaxws-e
> ndpoint-through-JAXRSDataBinding-Is-it-possible-tp5709183.html Sent from
> the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com