cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fatemeh Chitforoush <chitforo...@gmail.com>
Subject Re: Service Interface Extension in CXF
Date Sun, 03 Aug 2008 09:18:35 GMT

Thanx for your reply.

I changed the implementation as you said:

@WebService
@XmlSeeAlso({XChild.class})
public interface ChildServiceInterface extends  ParentServiceInterface{
     @WebMethod
     public String[] getXList();
}

and now, there is no exception during tomcat start-up, but as I call the
service from client, this exception is thrown by JAXB:
javax.xml.bind.JAXBException : XChild is not known to this context !!!!

Don't you know the solution?!

-- fatemeh


dkulp wrote:
> 
> 
> This is doable, but requires a little bit more setup....
> 
> First, the method signature must stay the same as what's in the  
> interface.   It needs to stay:
> public X[] getXList();
> We only invoke on the actual method object defined from the interface.
> 
> The key issue is getting the XChild classes available to JAXB.  The  
> EASIEST way to do that is to add an annotation to the Interface:
> @XmlSeeAlso({XChild.class})
> (might be able to add it to the impl instead, not really sure)
> 
> Dan
> 
> 
> 
> On Jul 30, 2008, at 4:15 AM, Fatemeh Chitforoush wrote:
> 
>>
>> Hi,
>>
>> Thanx for your reply :)
>> BTW, I'm using Spring too, and I think maybe the problem relates to  
>> the
>> service implementor, which returns XChild instead of X! In fact,  
>> this part
>> is not covered in your sample test :S Actually i need inherited  
>> services to
>> return objects of different classes (which also extends X)! What do  
>> you
>> think?!
>>
>> -- fatemeh
>>
>>
>> Arul Dhesiaseelan wrote:
>>>
>>> Basically, you override base interface method in  
>>> ChildServiceInterface.
>>> So, this should work by all means.
>>>
>>> I know for sure this works standalone CXF. I haven't tested in a  
>>> servlet
>>> container.
>>>
>>> Here is my standalone test, in case if you are interested.
>>>
>>> public interface ParentServiceInterface {
>>>  public String[] getXList();
>>> }
>>>
>>> @WebService
>>> public interface ChildServiceInterface extends  
>>> ParentServiceInterface{
>>>       @WebMethod
>>>       public String[] getXList();
>>> }
>>>
>>> public class ChildServiceImpl implements ChildServiceInterface {
>>>       public String[] getXList(){
>>>            return new String[] {"child"};
>>>       }
>>> }
>>>
>>> public class Server {
>>>  public static void main(String args[]) {
>>>    System.out.println("Starting Server");
>>>    ChildServiceImpl implementor = new ChildServiceImpl();
>>>    String address = "http://localhost:9000/child";
>>>    Endpoint.publish(address, implementor);
>>>  }
>>> }
>>>
>>> public class Client {
>>>  public static void main(String args[]) {
>>>    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>>    factory.setServiceClass(ChildServiceInterface.class);
>>>    factory.setAddress("http://localhost:9000/child");
>>>
>>>    ChildServiceInterface client =
>>> (ChildServiceInterface)factory.create();
>>>    System.out.println("Invoke getXList()....");
>>>    System.out.println(client.getXList()[0]);
>>>    System.exit(0);
>>>
>>>  }
>>> }
>>>
>>> HTH.
>>>
>>> Cheers,
>>> Arul
>>>
>>> Fatemeh Chitforoush wrote:
>>>> Hi,
>>>>
>>>> Does CXF support inheritance in service interfaces?
>>>> I want to have a common interface for a number of services, so I  
>>>> have a
>>>> parent interface, and all my service interfaces extend this parent
>>>> interface. When i try to fire up tomcat, this exception is thrown:
>>>> An opration  "an operation with name [] already exists in this  
>>>> service.
>>>> Does CXF support what I want?
>>>>
>>>> Sample code:
>>>> public interface ParentServiceInterface {
>>>>      public X[] getXList();
>>>> }
>>>>
>>>> public interface ChildServiceInterface extends  
>>>> ParentServiceInterface{
>>>>       @WebMethod
>>>>       public X[] getXList();
>>>> }
>>>>
>>>> public class ChildServiceImpl implements ChildServiceInterface {
>>>>       public XChild[] getXList(){
>>>>            .......
>>>>       }
>>>> }
>>>>
>>>> public class XChild extends X{
>>>> ......
>>>> }
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Service-Interface-Extension-in-CXF-tp18708779p18728166.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
> 
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Service-Interface-Extension-in-CXF-tp18708779p18797074.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message