You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arul Dhesiaseelan <ar...@fluxcorp.com> on 2008/05/02 00:52:10 UTC
overloaded operation names in JAX-WS
Hi,
I am getting an IllegalArgumentException (An operation with name
[{http://example.com}getGroups] already exists in this service) when I
have overloaded methods in my web service.
Is it not supported to have overloaded web service methods in JAX-WS?
I have the following methods:
public Groups getGroups();
public Groups getGroups(String pattern);
Please clarify.
Cheers,
Arul
Re: overloaded operation names in JAX-WS
Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Thanks Ian. I am using CXF on both ends. So, your solution works great
for me.
Cheers,
Arul
Ian Roberts wrote:
> Arul Dhesiaseelan wrote:
>> Hi,
>>
>> I am getting an IllegalArgumentException (An operation with name
>> [{http://example.com}getGroups] already exists in this service) when
>> I have overloaded methods in my web service.
>>
>> Is it not supported to have overloaded web service methods in JAX-WS?
>>
>> I have the following methods:
>>
>> public Groups getGroups();
>> public Groups getGroups(String pattern);
>
> No, all the operations must have different names in the WSDL. If you
> are using CXF on both client and server side, you can do something like:
>
> @WebMethod
> public Groups getGroups();
>
> @WebMethod(operationName = "getGroupsByPattern")
> public Groups getGroups(String pattern);
>
> This would give the two operations different names in the WSDL, but
> you can use the Java interface as the serviceClass of a
> JaxWsProxyFactoryBean and call both methods via their overloaded name.
>
> Ian
>
> P.S. If you were to generate code from the WSDL you would get public
> Groups getGroupsByPattern(String arg0), of course.
>
Re: overloaded operation names in JAX-WS
Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
Arul Dhesiaseelan wrote:
> Hi,
>
> I am getting an IllegalArgumentException (An operation with name
> [{http://example.com}getGroups] already exists in this service) when I
> have overloaded methods in my web service.
>
> Is it not supported to have overloaded web service methods in JAX-WS?
>
> I have the following methods:
>
> public Groups getGroups();
> public Groups getGroups(String pattern);
No, all the operations must have different names in the WSDL. If you
are using CXF on both client and server side, you can do something like:
@WebMethod
public Groups getGroups();
@WebMethod(operationName = "getGroupsByPattern")
public Groups getGroups(String pattern);
This would give the two operations different names in the WSDL, but you
can use the Java interface as the serviceClass of a
JaxWsProxyFactoryBean and call both methods via their overloaded name.
Ian
P.S. If you were to generate code from the WSDL you would get public
Groups getGroupsByPattern(String arg0), of course.
--
Ian Roberts | Department of Computer Science
i.roberts@dcs.shef.ac.uk | University of Sheffield, UK