You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Bertrand TROLARD <be...@erdil.fr> on 2011/02/24 11:55:18 UTC

JAX-WS Severals @WebService same implementation

Hi,
I'm new to CXF.

I try to use JAX-WS to and I want to have severals web-services with the 
same java class for the implementation.
For these web-services, I want to use the same bean.

Each web-service has more and more fontions, but every "client" can't 
have access to all fonctions (url dependant).
I create inherited class to get a different @WebService annotation for 
each web-service.
The bean will be the last derived class.

@WebService(targetNamespace = "http://service2/", endpointInterface = 
"my.class.Service2", portName = "Service2Port", serviceName = 
"Service2Service")
class ServiceImpl2 extends ServiceImpl1 {
}

@WebService(targetNamespace = "http://service1/", endpointInterface = 
"my.class.Service1", portName = "Service1Port", serviceName = 
"Service1Service")
class Service1Impl implement Service1, Service2{
}

The cxf configuration file.
<jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
         implementor="#commonBean"
         endpointName="tns:Service1Port"
         serviceName="tns:Service1" address="/Service1Test">
</jaxws:endpoint>

<jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
         implementor="#commonBean"
         endpointName="tns:Service2Port"
         serviceName="tns:Service2" address="/Service2Test">
</jaxws:endpoint>

<bean id="commonBean" class="my.class.Service2Impl" init-method="start" >
...
</bean>

But for each web-service I got the same WSDL wich is the Service2.wsdl.


When I do that with XFire and it works fine. The service.xml file looks 
like:

<service>
<name>Service1</name>
<serviceClass>my.interface.Service1</serviceClass>
<scope>application</scope>
<serviceBean>#commonBean</serviceBean>
</service>

<service>
<name>Service2</name>
<serviceClass>my.interface.Service2</serviceClass>
<scope>application</scope>
<serviceBean>#commonBean</serviceBean>
</service>

<bean id="commonBean" class="my.class.Service12Impl" init-method="start" >
</bean>


class Service12Impl implement Service1, Service2 {
   ...
}


Is it possible to do the same with CXF ?

Thank a lot,

Bertrand

Re: JAX-WS Severals @WebService same implementation

Posted by Bertrand TROLARD <be...@erdil.fr>.
Hello,
adding an implementorClass="Service2" attribute to the jaxws:endpoint works.
I have now different wsdl and different functions for each service.

<jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
          implementor="#commonBean"
	 implementorClass="my.interface.Service1"
          endpointName="tns:Service1Port"
          serviceName="tns:Service1" address="/Service1Test">
</jaxws:endpoint>

<jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
          implementor="#commonBean"
	 implementorClass="my.interface.Service2"
          endpointName="tns:Service2Port"
          serviceName="tns:Service2" address="/Service2Test">
</jaxws:endpoint>

Thank you.
Bertrand
*
*
> You MIGHT be able to add an implementorClass="Service2" attribute to the
> jaxws:endpoint.    That would tell it the class to actually look at.   I'm not
> 100% sure that works though.
>
> It would probably be good to provide an endpointInterface attribute to
> jaxws:endpoint to override the value in the @WebService annotation.  We can
> pretty much override everything else (endpoint name, service name, etc...).
> Overriding that would make sense.   Feel free to log a feature request (and a
> patch would be REAL nice).   :-)
>
> Dan
>
>
> On Thursday 24 February 2011 5:55:18 AM Bertrand TROLARD wrote:
>> Hi,
>> I'm new to CXF.
>>
>> I try to use JAX-WS to and I want to have severals web-services with the
>> same java class for the implementation.
>> For these web-services, I want to use the same bean.
>>
>> Each web-service has more and more fontions, but every "client" can't
>> have access to all fonctions (url dependant).
>> I create inherited class to get a different @WebService annotation for
>> each web-service.
>> The bean will be the last derived class.
>>
>> @WebService(targetNamespace = "http://service2/", endpointInterface =
>> "my.class.Service2", portName = "Service2Port", serviceName =
>> "Service2Service")
>> class ServiceImpl2 extends ServiceImpl1 {
>> }
>>
>> @WebService(targetNamespace = "http://service1/", endpointInterface =
>> "my.class.Service1", portName = "Service1Port", serviceName =
>> "Service1Service")
>> class Service1Impl implement Service1, Service2{
>> }
>>
>> The cxf configuration file.
>> <jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
>>           implementor="#commonBean"
>>           endpointName="tns:Service1Port"
>>           serviceName="tns:Service1" address="/Service1Test">
>> </jaxws:endpoint>
>>
>> <jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
>>           implementor="#commonBean"
>>           endpointName="tns:Service2Port"
>>           serviceName="tns:Service2" address="/Service2Test">
>> </jaxws:endpoint>
>>
>> <bean id="commonBean" class="my.class.Service2Impl" init-method="start">
>> ...
>> </bean>
>>
>> But for each web-service I got the same WSDL wich is the Service2.wsdl.
>>
>>
>> When I do that with XFire and it works fine. The service.xml file looks
>> like:
>>
>> <service>
>> <name>Service1</name>
>> <serviceClass>my.interface.Service1</serviceClass>
>> <scope>application</scope>
>> <serviceBean>#commonBean</serviceBean>
>> </service>
>>
>> <service>
>> <name>Service2</name>
>> <serviceClass>my.interface.Service2</serviceClass>
>> <scope>application</scope>
>> <serviceBean>#commonBean</serviceBean>
>> </service>
>>
>> <bean id="commonBean" class="my.class.Service12Impl" init-method="start">
>> </bean>
>>
>>
>> class Service12Impl implement Service1, Service2 {
>>     ...
>> }
>>
>>
>> Is it possible to do the same with CXF ?
>>
>> Thank a lot,
>>
>> Bertrand


Re: JAX-WS Severals @WebService same implementation

Posted by Daniel Kulp <dk...@apache.org>.
You MIGHT be able to add an implementorClass="Service2" attribute to the 
jaxws:endpoint.    That would tell it the class to actually look at.   I'm not 
100% sure that works though.  

It would probably be good to provide an endpointInterface attribute to 
jaxws:endpoint to override the value in the @WebService annotation.  We can 
pretty much override everything else (endpoint name, service name, etc...).    
Overriding that would make sense.   Feel free to log a feature request (and a 
patch would be REAL nice).   :-)

Dan


On Thursday 24 February 2011 5:55:18 AM Bertrand TROLARD wrote:
> Hi,
> I'm new to CXF.
> 
> I try to use JAX-WS to and I want to have severals web-services with the
> same java class for the implementation.
> For these web-services, I want to use the same bean.
> 
> Each web-service has more and more fontions, but every "client" can't
> have access to all fonctions (url dependant).
> I create inherited class to get a different @WebService annotation for
> each web-service.
> The bean will be the last derived class.
> 
> @WebService(targetNamespace = "http://service2/", endpointInterface =
> "my.class.Service2", portName = "Service2Port", serviceName =
> "Service2Service")
> class ServiceImpl2 extends ServiceImpl1 {
> }
> 
> @WebService(targetNamespace = "http://service1/", endpointInterface =
> "my.class.Service1", portName = "Service1Port", serviceName =
> "Service1Service")
> class Service1Impl implement Service1, Service2{
> }
> 
> The cxf configuration file.
> <jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
>          implementor="#commonBean"
>          endpointName="tns:Service1Port"
>          serviceName="tns:Service1" address="/Service1Test">
> </jaxws:endpoint>
> 
> <jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
>          implementor="#commonBean"
>          endpointName="tns:Service2Port"
>          serviceName="tns:Service2" address="/Service2Test">
> </jaxws:endpoint>
> 
> <bean id="commonBean" class="my.class.Service2Impl" init-method="start" >
> ...
> </bean>
> 
> But for each web-service I got the same WSDL wich is the Service2.wsdl.
> 
> 
> When I do that with XFire and it works fine. The service.xml file looks
> like:
> 
> <service>
> <name>Service1</name>
> <serviceClass>my.interface.Service1</serviceClass>
> <scope>application</scope>
> <serviceBean>#commonBean</serviceBean>
> </service>
> 
> <service>
> <name>Service2</name>
> <serviceClass>my.interface.Service2</serviceClass>
> <scope>application</scope>
> <serviceBean>#commonBean</serviceBean>
> </service>
> 
> <bean id="commonBean" class="my.class.Service12Impl" init-method="start" >
> </bean>
> 
> 
> class Service12Impl implement Service1, Service2 {
>    ...
> }
> 
> 
> Is it possible to do the same with CXF ?
> 
> Thank a lot,
> 
> Bertrand

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

Re: JAX-WS Severals @WebService same implementation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Thu, Feb 24, 2011 at 11:11 AM, Bertrand TROLARD
<be...@erdil.fr> wrote:
> Hi,
>
> They are available at these 2 address, but the two services give the same
> WSDL and so the same "functions".
> The two services don't implement the same interface. I want two different
> wsdl and so not the same functions. One service could inherited the second.
>

Most likely you are 'hitting' an issue to do with ServletController
overriding the addresses of the endpoint destinations.
It prevents multiple Java-first JAX-WS endpoints from sharing a single
CXFServlet or say a single Java-First JAX-WS endpoint from being
accessed via multiple CXFServlet roots. I've 'struggled' with this
issue during the last few days while working on the transformations
demo.

WSDL-First JAX-WS endpoints, with JAX-WS clients using their own
WSDLs, seem to be fine, at least in my demo, and JAX-RS endpoints are
ok too. A "disable-address-updates" servlet parameter, set to true,
needs to be used to overcome this limitation - it does not help with
Java-First JAX-WS endpoints though.

Alternatively, try introducing two Servlets listening on say :

/services1/*
and
/services2/*

and access the first endpoint as /service1/ServiceTest1,and the 2nd
one as /service2/ServiceTest2

In meantime, I'll open a JIRA for the address overwriting be avoided
by default. The problem there is that ?wsdl and /services queries
depend on it - but hope that can be be fixed

thanks, Sergey

> Thank you for your time.
> Bertrand
>
>> Hi
>>
>> Are you using a single CXFServlet declaration with the pattern such as
>> "/services/*"?
>> An expect the first service be available at /services/Service1Test and
>> the 2nd one at /services/Service2Test ?
>>
>> Cheers, Sergey
>>
>> On Thu, Feb 24, 2011 at 10:55 AM, Bertrand TROLARD
>> <be...@erdil.fr>  wrote:
>>>
>>> Hi,
>>> I'm new to CXF.
>>>
>>> I try to use JAX-WS to and I want to have severals web-services with the
>>> same java class for the implementation.
>>> For these web-services, I want to use the same bean.
>>>
>>> Each web-service has more and more fontions, but every "client" can't
>>> have
>>> access to all fonctions (url dependant).
>>> I create inherited class to get a different @WebService annotation for
>>> each
>>> web-service.
>>> The bean will be the last derived class.
>>>
>>> @WebService(targetNamespace = "http://service2/", endpointInterface =
>>> "my.class.Service2", portName = "Service2Port", serviceName =
>>> "Service2Service")
>>> class ServiceImpl2 extends ServiceImpl1 {
>>> }
>>>
>>> @WebService(targetNamespace = "http://service1/", endpointInterface =
>>> "my.class.Service1", portName = "Service1Port", serviceName =
>>> "Service1Service")
>>> class Service1Impl implement Service1, Service2{
>>> }
>>>
>>> The cxf configuration file.
>>> <jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
>>>        implementor="#commonBean"
>>>        endpointName="tns:Service1Port"
>>>        serviceName="tns:Service1" address="/Service1Test">
>>> </jaxws:endpoint>
>>>
>>> <jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
>>>        implementor="#commonBean"
>>>        endpointName="tns:Service2Port"
>>>        serviceName="tns:Service2" address="/Service2Test">
>>> </jaxws:endpoint>
>>>
>>> <bean id="commonBean" class="my.class.Service2Impl" init-method="start">
>>> ...
>>> </bean>
>>>
>>> But for each web-service I got the same WSDL wich is the Service2.wsdl.
>>>
>>>
>>> When I do that with XFire and it works fine. The service.xml file looks
>>> like:
>>>
>>> <service>
>>> <name>Service1</name>
>>> <serviceClass>my.interface.Service1</serviceClass>
>>> <scope>application</scope>
>>> <serviceBean>#commonBean</serviceBean>
>>> </service>
>>>
>>> <service>
>>> <name>Service2</name>
>>> <serviceClass>my.interface.Service2</serviceClass>
>>> <scope>application</scope>
>>> <serviceBean>#commonBean</serviceBean>
>>> </service>
>>>
>>> <bean id="commonBean" class="my.class.Service12Impl" init-method="start">
>>> </bean>
>>>
>>>
>>> class Service12Impl implement Service1, Service2 {
>>>  ...
>>> }
>>>
>>>
>>> Is it possible to do the same with CXF ?
>>>
>>> Thank a lot,
>>>
>>> Bertrand
>>>
>
>

Re: JAX-WS Severals @WebService same implementation

Posted by Bertrand TROLARD <be...@erdil.fr>.
Hi,

They are available at these 2 address, but the two services give the 
same WSDL and so the same "functions".
The two services don't implement the same interface. I want two 
different wsdl and so not the same functions. One service could 
inherited the second.

Thank you for your time.
Bertrand

> Hi
>
> Are you using a single CXFServlet declaration with the pattern such as
> "/services/*"?
> An expect the first service be available at /services/Service1Test and
> the 2nd one at /services/Service2Test ?
>
> Cheers, Sergey
>
> On Thu, Feb 24, 2011 at 10:55 AM, Bertrand TROLARD
> <be...@erdil.fr>  wrote:
>> Hi,
>> I'm new to CXF.
>>
>> I try to use JAX-WS to and I want to have severals web-services with the
>> same java class for the implementation.
>> For these web-services, I want to use the same bean.
>>
>> Each web-service has more and more fontions, but every "client" can't have
>> access to all fonctions (url dependant).
>> I create inherited class to get a different @WebService annotation for each
>> web-service.
>> The bean will be the last derived class.
>>
>> @WebService(targetNamespace = "http://service2/", endpointInterface =
>> "my.class.Service2", portName = "Service2Port", serviceName =
>> "Service2Service")
>> class ServiceImpl2 extends ServiceImpl1 {
>> }
>>
>> @WebService(targetNamespace = "http://service1/", endpointInterface =
>> "my.class.Service1", portName = "Service1Port", serviceName =
>> "Service1Service")
>> class Service1Impl implement Service1, Service2{
>> }
>>
>> The cxf configuration file.
>> <jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
>>         implementor="#commonBean"
>>         endpointName="tns:Service1Port"
>>         serviceName="tns:Service1" address="/Service1Test">
>> </jaxws:endpoint>
>>
>> <jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
>>         implementor="#commonBean"
>>         endpointName="tns:Service2Port"
>>         serviceName="tns:Service2" address="/Service2Test">
>> </jaxws:endpoint>
>>
>> <bean id="commonBean" class="my.class.Service2Impl" init-method="start">
>> ...
>> </bean>
>>
>> But for each web-service I got the same WSDL wich is the Service2.wsdl.
>>
>>
>> When I do that with XFire and it works fine. The service.xml file looks
>> like:
>>
>> <service>
>> <name>Service1</name>
>> <serviceClass>my.interface.Service1</serviceClass>
>> <scope>application</scope>
>> <serviceBean>#commonBean</serviceBean>
>> </service>
>>
>> <service>
>> <name>Service2</name>
>> <serviceClass>my.interface.Service2</serviceClass>
>> <scope>application</scope>
>> <serviceBean>#commonBean</serviceBean>
>> </service>
>>
>> <bean id="commonBean" class="my.class.Service12Impl" init-method="start">
>> </bean>
>>
>>
>> class Service12Impl implement Service1, Service2 {
>>   ...
>> }
>>
>>
>> Is it possible to do the same with CXF ?
>>
>> Thank a lot,
>>
>> Bertrand
>>


Re: JAX-WS Severals @WebService same implementation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Are you using a single CXFServlet declaration with the pattern such as
"/services/*"?
An expect the first service be available at /services/Service1Test and
the 2nd one at /services/Service2Test ?

Cheers, Sergey

On Thu, Feb 24, 2011 at 10:55 AM, Bertrand TROLARD
<be...@erdil.fr> wrote:
> Hi,
> I'm new to CXF.
>
> I try to use JAX-WS to and I want to have severals web-services with the
> same java class for the implementation.
> For these web-services, I want to use the same bean.
>
> Each web-service has more and more fontions, but every "client" can't have
> access to all fonctions (url dependant).
> I create inherited class to get a different @WebService annotation for each
> web-service.
> The bean will be the last derived class.
>
> @WebService(targetNamespace = "http://service2/", endpointInterface =
> "my.class.Service2", portName = "Service2Port", serviceName =
> "Service2Service")
> class ServiceImpl2 extends ServiceImpl1 {
> }
>
> @WebService(targetNamespace = "http://service1/", endpointInterface =
> "my.class.Service1", portName = "Service1Port", serviceName =
> "Service1Service")
> class Service1Impl implement Service1, Service2{
> }
>
> The cxf configuration file.
> <jaxws:endpoint xmlns:tns="http://service1/" id="id_service1"
>        implementor="#commonBean"
>        endpointName="tns:Service1Port"
>        serviceName="tns:Service1" address="/Service1Test">
> </jaxws:endpoint>
>
> <jaxws:endpoint xmlns:tns="http://service2/" id="id_service2"
>        implementor="#commonBean"
>        endpointName="tns:Service2Port"
>        serviceName="tns:Service2" address="/Service2Test">
> </jaxws:endpoint>
>
> <bean id="commonBean" class="my.class.Service2Impl" init-method="start" >
> ...
> </bean>
>
> But for each web-service I got the same WSDL wich is the Service2.wsdl.
>
>
> When I do that with XFire and it works fine. The service.xml file looks
> like:
>
> <service>
> <name>Service1</name>
> <serviceClass>my.interface.Service1</serviceClass>
> <scope>application</scope>
> <serviceBean>#commonBean</serviceBean>
> </service>
>
> <service>
> <name>Service2</name>
> <serviceClass>my.interface.Service2</serviceClass>
> <scope>application</scope>
> <serviceBean>#commonBean</serviceBean>
> </service>
>
> <bean id="commonBean" class="my.class.Service12Impl" init-method="start" >
> </bean>
>
>
> class Service12Impl implement Service1, Service2 {
>  ...
> }
>
>
> Is it possible to do the same with CXF ?
>
> Thank a lot,
>
> Bertrand
>