You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jeff Puro <je...@gmail.com> on 2012/03/20 03:41:05 UTC

JAX-WS method that accepts XML fragments as parameters

I am attempting to create a JAX-WS web service/method that will accept two
parameters passed in by a SOAP client. The first parameter is an XML string
and the second is an XSLT to apply to that XML. I'd preferably like the
parameters to map directly to either Source or Element objects, but it
seems like CXF isn't handling this properly. The wsdl that it creates
indicates that the types are base64Binary, and when I make the service
call, the xml is never parsed properly and the objects are null. After I
apply the XSLT to the XML, I would like to return a Source or Element
object to the client. Is this easily done? I've been searching the web for
a way to do this, but have not really found a way other than by
implementing the Provider interface. I have been able to implement this
whole thing visa vi the Provider method, but I feel like that is a non
standard way of doing this and I'm worried about web service
interoperability. Assuming I implement this with the out of the box
approach, it would be great if I could make my method look like the
following:

@WebService()

public class TransformServiceImpl implements TransformService {

public Source transform(Source xml, Source xslt) {

  //perform some work

  ....

  ..

  return result;

}

Thanks,

Jeff

Re: JAX-WS method that accepts XML fragments as parameters

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

May not answer your question directly, but IMO, if you wanna pass some  
xml files directly as the method parameter, you'd better use MTOM way,  
this can pass the xml files as attachment,  so that  avoid encoding it  
into soap body.

Also your requirement is a typical scenario that dispatch/provider way  
applicable, and the dispatch/provider is from jaxws spec so it's also  
a standard approach from my point of view.

Freeman
On 2012-3-20, at 上午10:41, Jeff Puro wrote:

> I am attempting to create a JAX-WS web service/method that will  
> accept two
> parameters passed in by a SOAP client. The first parameter is an XML  
> string
> and the second is an XSLT to apply to that XML. I'd preferably like  
> the
> parameters to map directly to either Source or Element objects, but it
> seems like CXF isn't handling this properly. The wsdl that it creates
> indicates that the types are base64Binary, and when I make the service
> call, the xml is never parsed properly and the objects are null.  
> After I
> apply the XSLT to the XML, I would like to return a Source or Element
> object to the client. Is this easily done? I've been searching the  
> web for
> a way to do this, but have not really found a way other than by
> implementing the Provider interface. I have been able to implement  
> this
> whole thing visa vi the Provider method, but I feel like that is a non
> standard way of doing this and I'm worried about web service
> interoperability. Assuming I implement this with the out of the box
> approach, it would be great if I could make my method look like the
> following:
>
> @WebService()
>
> public class TransformServiceImpl implements TransformService {
>
> public Source transform(Source xml, Source xslt) {
>
>  //perform some work
>
>  ....
>
>  ..
>
>  return result;
>
> }
>
> Thanks,
>
> Jeff

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com