cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ayush Gupta" <ay...@inquisant.com>
Subject RE: Does CXF Support Interfaces as Web Params?
Date Wed, 27 Feb 2008 19:17:36 GMT
Yes, I've used JAXB with interfaces and its painful but does work. 

However, it appears from the code in JAXBUtils that CXF explicitly excludes
interfaces even if they are annotated to be properly marshaled by JAXB (as
per https://jaxb.dev.java.net/guide/Mapping_interfaces.html)


-----Original Message-----
From: jim ma [mailto:mail2jimma@gmail.com] 
Sent: Tuesday, February 26, 2008 9:18 PM
To: cxf-user@incubator.apache.org
Subject: Re: Does CXF Support Interfaces as Web Params?

Kohsuke Kawaguchi's blog talked about this , you can get some information
from
this link:
http://weblogs.java.net/blog/kohsuke/archive/2006/06/jaxb_and_interf.html

On Wed, Feb 27, 2008 at 9:25 AM, Glen Mazza <glen.mazza@verizon.net> wrote:

> I think the answer is "no", neither CXF nor GlassFish Metro support
> interfaces as parameters.  It's either a JAX-WS or JAXB rule, I'm not
> certain.
>
> Glen
>
> Am Dienstag, den 26.02.2008, 15:07 -0800 schrieb Ayush Gupta:
> > In my web service, there is a method which takes an interface as its
> > parameter, instead of a concrete class. Reference code is at the bottom
> of
> > this email.
> >
> >
> >
> > When I run the client, I get an exception "Caused by:
> > javax.xml.bind.JAXBException:
com.passenger.test.ComplexObjectInterfaceis
> > not known to this context". Further investigation and digging through
> the
> > CXF code bought me to JAXBUtils. getValidClass(Class<?> cls) which is
> called
> > while building the JAXBContext. The code in JAXBUtils. getValidClass
> > explicitly excludes inclusion of any interfaces! I also tried setting
> the
> > XmlJavaTypeAdapter on the interface but that didn't work.
> >
> >
> >
> > So, does CXF Support Interfaces as Web Params? I'd appreciate anyone
> > throwing some light on this!
> >
> >
> >
> > Thanks
> >
> > -ayush
> >
> >
> >
> >
> >
> > Web Service Interface:
> >
> > public interface TestServiceInterface {
> >
> >     public void testMethod(MyInterface param);
> >
> > }
> >
> >
> >
> > Parameter Interface:
> >
> > public interface MyInterface{
> >
> >     String getText();
> >
> >     void setText(String t);
> >
> > }
> >
> >
> >
> >
> >
> > Parameter concrete class:
> >
> > public class MyClass implements MyInterface {
> >
> >     private String text;
> >
> >
> >
> >     public String getText() {
> >
> >         return text;
> >
> >     }
> >
> >
> >
> >     public void setText(String t) {
> >
> >         this.text = t;
> >
> >     }
> >
> > }
> >
> >
> >
> > Client:
> >
> >     Service service = Service.create(SERVICE_NAME);
> >
> >     service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING,
> > ENDPOINT_ADDRESS);
> >
> >     TestServiceInterface  serviceInterface  =
> > service.getPort(TestServiceInterface.class);
> >
> >     serviceInterface. testMethod(new MyClass());
> >
> >
> >
> >
> >
>
>


Mime
View raw message