You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Fatemeh Chitforoush <ch...@gmail.com> on 2008/07/29 11:49:57 UTC

Service Interface Extension in CXF

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-tp18708779p18708779.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Service Interface Extension in CXF

Posted by Daniel Kulp <dk...@apache.org>.
As long as everything meets the rules for JAXB, that should have worked.   If 
not, you'll probably need to create a small example that shows it failing so 
we can dig into it to see why.

Dan


On Sunday 03 August 2008 5:18:35 am Fatemeh Chitforoush wrote:
> 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-tp18708779p1872
> >>8166.html Sent from the cxf-user mailing list archive at Nabble.com.
> >
> > ---
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog



-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Service Interface Extension in CXF

Posted by Fatemeh Chitforoush <ch...@gmail.com>.
I also put a 0-arg default constructor for XChild, as you said, but still
throws the same exception!
My code is exactly the same as Child-Parent example (I posted here!) :S It
seems that it should work!!! I am totally confused :S


Arul Dhesiaseelan wrote:
> 
> Make sure you have a 0-arg default constructor in place for XChild as 
> this is required for JAXB.
> 
> -Arul
> 
> Fatemeh Chitforoush wrote:
>> 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-tp18708779p18825689.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Service Interface Extension in CXF

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Make sure you have a 0-arg default constructor in place for XChild as 
this is required for JAXB.

-Arul

Fatemeh Chitforoush wrote:
> 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
>>
>>
>>
>>
>>
>>
>>     
>
>   


Re: Service Interface Extension in CXF

Posted by Fatemeh Chitforoush <ch...@gmail.com>.
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.


Re: Service Interface Extension in CXF

Posted by Daniel Kulp <dk...@apache.org>.
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





Re: Service Interface Extension in CXF

Posted by Fatemeh Chitforoush <ch...@gmail.com>.
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.


Re: Service Interface Extension in CXF

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
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{
> ......
> }
>
>