You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Thomas Pischulski <ne...@googlemail.com> on 2012/04/13 15:45:51 UTC

DOSGi CXF WebService Interface and Implementation in different bundles

Hi,

currently I'm publishing web services via DOSGi in Equinox with the
single distribution bundle 1.3. I can successfully create the service
when both, the web service interface and the interface implementation
are located in the same bundle. However, when put both into separate
bundles the server gets still successfully created (also the published
*.wsdl-file stays the same) but I always receive "null" for any web
service request. For the client side I'm using the
ClientProxyFactoryBean factory. All requests to the server return
correct responses when interface and implementation of the server are
located in the same bundle.

My main goal is to access the server's interface.class file on the
client-side. I don't want to generate my stub with wsimport or wsdl2java.

In the approach that I tried to realize first I would get the solution
because both OSGi platforms can access an "interface-bundle" because
it's synced via SVN.

Cheers,

Thomas

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by Thomas Pischulski <ne...@googlemail.com>.
Hey David,

I'm using registerService() for webservice deployment. But I don't use
it for accessing the interface in the bundle that publishs the
webservice. I simply import it via MANIFEST but that doesn't seem to
work? I mean the published WSDL stays the same but I always get those
null responses.

On 4/13/2012 5:02 PM, David Bosschaert wrote:
> How are you publishing via DOSGi if you're not using 
> BundleContext.registerService()? OSGi Remote Services (and CXF
> DOSGi) only works with services in the OSGi Service Registry. So
> you either need to put them there by calling
> BundleContext.registerService() or you can use a component
> framework like Blueprint or DS to do that for you...
> 
> Cheers,
> 
> David
> 
> 
> On 13 April 2012 15:33, Thomas Pischulski <ne...@googlemail.com>
> wrote:
>> Hey David,
>> 
>> that's what I did even though I didn't use registerService() and 
>> ServiceTracker to access the interface. I thought exporting the 
>> interface from the "interface-share-bundle" and importing it into
>> the bundle (via MANIFEST) where I register my web service would
>> be enough? Also I was wondering why I always get null responses
>> after my client requests and there's no problem when both are
>> located in the same bundle.
>> 
>> Cheers,
>> 
>> Thomas
>> 
>> On 4/13/2012 3:55 PM, David Bosschaert wrote:
>>> Hi Thomas,
>>> 
>>> I'm not sure I fully follow your scenario.
>>> 
>>> I think the best way to do this is by using a shared interface 
>>> bundle. Like is done in the greeter demo: 
>>> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>>>
>>>
>>> 
Since you probably want to program against the API on the client
>>> side it generally makes sense to have the interface there
>>> available anyway, otherwise the only way you can access the
>>> service is via reflection.
>>> 
>>> So I would recommend to have an interfaces bundle which is
>>> shared between the client and the server, as is done with the
>>> greeter demo. Then things should work nicely. I think trying to
>>> read a .class file from the server may generally not be what
>>> you want.
>>> 
>>> Cheers,
>>> 
>>> David
>>> 
>>> On 13 April 2012 14:45, Thomas Pischulski
>>> <ne...@googlemail.com> wrote:
>>>> Hi,
>>>> 
>>>> currently I'm publishing web services via DOSGi in Equinox
>>>> with the single distribution bundle 1.3. I can successfully
>>>> create the service when both, the web service interface and
>>>> the interface implementation are located in the same bundle.
>>>> However, when put both into separate bundles the server gets
>>>> still successfully created (also the published *.wsdl-file
>>>> stays the same) but I always receive "null" for any web
>>>> service request. For the client side I'm using the
>>>> ClientProxyFactoryBean factory. All requests to the server
>>>> return correct responses when interface and implementation of
>>>> the server are located in the same bundle.
>>>> 
>>>> My main goal is to access the server's interface.class file
>>>> on the client-side. I don't want to generate my stub with
>>>> wsimport or wsdl2java.
>>>> 
>>>> In the approach that I tried to realize first I would get
>>>> the solution because both OSGi platforms can access an 
>>>> "interface-bundle" because it's synced via SVN.
>>>> 
>>>> Cheers,
>>>> 
>>>> Thomas

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by David Bosschaert <da...@gmail.com>.
How are you publishing via DOSGi if you're not using
BundleContext.registerService()? OSGi Remote Services (and CXF DOSGi)
only works with services in the OSGi Service Registry. So you either
need to put them there by calling BundleContext.registerService() or
you can use a component framework like Blueprint or DS to do that for
you...

Cheers,

David


On 13 April 2012 15:33, Thomas Pischulski <ne...@googlemail.com> wrote:
> Hey David,
>
> that's what I did even though I didn't use registerService() and
> ServiceTracker to access the interface. I thought exporting the
> interface from the "interface-share-bundle" and importing it into the
> bundle (via MANIFEST) where I register my web service would be enough?
> Also I was wondering why I always get null responses after my client
> requests and there's no problem when both are located in the same bundle.
>
> Cheers,
>
> Thomas
>
> On 4/13/2012 3:55 PM, David Bosschaert wrote:
>> Hi Thomas,
>>
>> I'm not sure I fully follow your scenario.
>>
>> I think the best way to do this is by using a shared interface
>> bundle. Like is done in the greeter demo:
>> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>>
>>  Since you probably want to program against the API on the client
>> side it generally makes sense to have the interface there available
>> anyway, otherwise the only way you can access the service is via
>> reflection.
>>
>> So I would recommend to have an interfaces bundle which is shared
>> between the client and the server, as is done with the greeter
>> demo. Then things should work nicely. I think trying to read a
>> .class file from the server may generally not be what you want.
>>
>> Cheers,
>>
>> David
>>
>> On 13 April 2012 14:45, Thomas Pischulski <ne...@googlemail.com>
>> wrote:
>>> Hi,
>>>
>>> currently I'm publishing web services via DOSGi in Equinox with
>>> the single distribution bundle 1.3. I can successfully create the
>>> service when both, the web service interface and the interface
>>> implementation are located in the same bundle. However, when put
>>> both into separate bundles the server gets still successfully
>>> created (also the published *.wsdl-file stays the same) but I
>>> always receive "null" for any web service request. For the client
>>> side I'm using the ClientProxyFactoryBean factory. All requests
>>> to the server return correct responses when interface and
>>> implementation of the server are located in the same bundle.
>>>
>>> My main goal is to access the server's interface.class file on
>>> the client-side. I don't want to generate my stub with wsimport
>>> or wsdl2java.
>>>
>>> In the approach that I tried to realize first I would get the
>>> solution because both OSGi platforms can access an
>>> "interface-bundle" because it's synced via SVN.
>>>
>>> Cheers,
>>>
>>> Thomas

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by Thomas Pischulski <ne...@googlemail.com>.
Hey Sergey,

uhm ok that sounds plausible. Any suggestions?

Cheers,

Thomas

On 4/13/2012 5:02 PM, Sergey Beryozkin wrote:
> On 13/04/12 15:33, Thomas Pischulski wrote:
>> Hey David,
>>
>> that's what I did even though I didn't use registerService() and
>> ServiceTracker to access the interface. I thought exporting the
>> interface from the "interface-share-bundle" and importing it into the
>> bundle (via MANIFEST) where I register my web service would be enough?
> Importing via MANIFEST simply makes sure whatever is imported is
> available to the importing bundle when it needs it, right ? But DOSGI is
> activated at the higher-level
> 
>> Also I was wondering why I always get null responses after my client
>> requests and there's no problem when both are located in the same bundle.
> I guess this is because it's just OSGI then, when everything is located
> in the same bundle.
> 
> Cheers, Sergey
> 
>>
>> Cheers,
>>
>> Thomas
>>
>> On 4/13/2012 3:55 PM, David Bosschaert wrote:
>>> Hi Thomas,
>>>
>>> I'm not sure I fully follow your scenario.
>>>
>>> I think the best way to do this is by using a shared interface
>>> bundle. Like is done in the greeter demo:
>>> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>>>
>>>   Since you probably want to program against the API on the client
>>> side it generally makes sense to have the interface there available
>>> anyway, otherwise the only way you can access the service is via
>>> reflection.
>>>
>>> So I would recommend to have an interfaces bundle which is shared
>>> between the client and the server, as is done with the greeter
>>> demo. Then things should work nicely. I think trying to read a
>>> .class file from the server may generally not be what you want.
>>>
>>> Cheers,
>>>
>>> David
>>>
>>> On 13 April 2012 14:45, Thomas Pischulski<ne...@googlemail.com>
>>> wrote:
>>>> Hi,
>>>>
>>>> currently I'm publishing web services via DOSGi in Equinox with
>>>> the single distribution bundle 1.3. I can successfully create the
>>>> service when both, the web service interface and the interface
>>>> implementation are located in the same bundle. However, when put
>>>> both into separate bundles the server gets still successfully
>>>> created (also the published *.wsdl-file stays the same) but I
>>>> always receive "null" for any web service request. For the client
>>>> side I'm using the ClientProxyFactoryBean factory. All requests
>>>> to the server return correct responses when interface and
>>>> implementation of the server are located in the same bundle.
>>>>
>>>> My main goal is to access the server's interface.class file on
>>>> the client-side. I don't want to generate my stub with wsimport
>>>> or wsdl2java.
>>>>
>>>> In the approach that I tried to realize first I would get the
>>>> solution because both OSGi platforms can access an
>>>> "interface-bundle" because it's synced via SVN.
>>>>
>>>> Cheers,
>>>>
>>>> Thomas
> 
> 

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 13/04/12 15:33, Thomas Pischulski wrote:
> Hey David,
>
> that's what I did even though I didn't use registerService() and
> ServiceTracker to access the interface. I thought exporting the
> interface from the "interface-share-bundle" and importing it into the
> bundle (via MANIFEST) where I register my web service would be enough?
Importing via MANIFEST simply makes sure whatever is imported is 
available to the importing bundle when it needs it, right ? But DOSGI is 
activated at the higher-level

> Also I was wondering why I always get null responses after my client
> requests and there's no problem when both are located in the same bundle.
I guess this is because it's just OSGI then, when everything is located 
in the same bundle.

Cheers, Sergey

>
> Cheers,
>
> Thomas
>
> On 4/13/2012 3:55 PM, David Bosschaert wrote:
>> Hi Thomas,
>>
>> I'm not sure I fully follow your scenario.
>>
>> I think the best way to do this is by using a shared interface
>> bundle. Like is done in the greeter demo:
>> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>>
>>   Since you probably want to program against the API on the client
>> side it generally makes sense to have the interface there available
>> anyway, otherwise the only way you can access the service is via
>> reflection.
>>
>> So I would recommend to have an interfaces bundle which is shared
>> between the client and the server, as is done with the greeter
>> demo. Then things should work nicely. I think trying to read a
>> .class file from the server may generally not be what you want.
>>
>> Cheers,
>>
>> David
>>
>> On 13 April 2012 14:45, Thomas Pischulski<ne...@googlemail.com>
>> wrote:
>>> Hi,
>>>
>>> currently I'm publishing web services via DOSGi in Equinox with
>>> the single distribution bundle 1.3. I can successfully create the
>>> service when both, the web service interface and the interface
>>> implementation are located in the same bundle. However, when put
>>> both into separate bundles the server gets still successfully
>>> created (also the published *.wsdl-file stays the same) but I
>>> always receive "null" for any web service request. For the client
>>> side I'm using the ClientProxyFactoryBean factory. All requests
>>> to the server return correct responses when interface and
>>> implementation of the server are located in the same bundle.
>>>
>>> My main goal is to access the server's interface.class file on
>>> the client-side. I don't want to generate my stub with wsimport
>>> or wsdl2java.
>>>
>>> In the approach that I tried to realize first I would get the
>>> solution because both OSGi platforms can access an
>>> "interface-bundle" because it's synced via SVN.
>>>
>>> Cheers,
>>>
>>> Thomas


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by Thomas Pischulski <ne...@googlemail.com>.
Hey David,

that's what I did even though I didn't use registerService() and
ServiceTracker to access the interface. I thought exporting the
interface from the "interface-share-bundle" and importing it into the
bundle (via MANIFEST) where I register my web service would be enough?
Also I was wondering why I always get null responses after my client
requests and there's no problem when both are located in the same bundle.

Cheers,

Thomas

On 4/13/2012 3:55 PM, David Bosschaert wrote:
> Hi Thomas,
> 
> I'm not sure I fully follow your scenario.
> 
> I think the best way to do this is by using a shared interface
> bundle. Like is done in the greeter demo: 
> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>
>  Since you probably want to program against the API on the client
> side it generally makes sense to have the interface there available
> anyway, otherwise the only way you can access the service is via
> reflection.
> 
> So I would recommend to have an interfaces bundle which is shared 
> between the client and the server, as is done with the greeter
> demo. Then things should work nicely. I think trying to read a
> .class file from the server may generally not be what you want.
> 
> Cheers,
> 
> David
> 
> On 13 April 2012 14:45, Thomas Pischulski <ne...@googlemail.com>
> wrote:
>> Hi,
>> 
>> currently I'm publishing web services via DOSGi in Equinox with
>> the single distribution bundle 1.3. I can successfully create the
>> service when both, the web service interface and the interface
>> implementation are located in the same bundle. However, when put
>> both into separate bundles the server gets still successfully
>> created (also the published *.wsdl-file stays the same) but I
>> always receive "null" for any web service request. For the client
>> side I'm using the ClientProxyFactoryBean factory. All requests
>> to the server return correct responses when interface and
>> implementation of the server are located in the same bundle.
>> 
>> My main goal is to access the server's interface.class file on
>> the client-side. I don't want to generate my stub with wsimport
>> or wsdl2java.
>> 
>> In the approach that I tried to realize first I would get the
>> solution because both OSGi platforms can access an
>> "interface-bundle" because it's synced via SVN.
>> 
>> Cheers,
>> 
>> Thomas

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by Thomas Pischulski <ne...@googlemail.com>.
It also seems like it's more of a problem how I create my client
proxy. When I register the webservice everything works fine and I can
also successfully make service calls via SoapUI.
As mentioned in my first post, I'm using ClientProxyFactoryBean for
generating my client and I'm importing IHelloService.class via
MANIFEST from the "interface-sharing-bundle": http://pastebin.com/yPsj46DX
When I run it with interface and implementation seperated in different
bundles my output looks like that:

Apr 15, 2012 9:15:08 AM
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service
{http://interfaces.helloservice.webaudraga.tis.iai.inf.tud.de/}IHelloService
from class
de.tud.inf.iai.tis.webaudraga.interfaces.helloservice.IHelloService
Client proxy: org.apache.cxf.frontend.ClientProxy@2b9179ee
[FRONTEND] Calling Webservice ...
[FRONTEND] Webservice ANSWER: null

Note here that my service calls still deliver correct responses in
SoapUI.

When I put both in the same bundle, everything's fine

Apr 15, 2012 9:16:22 AM
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service
{http://interfaces.helloservice.webaudraga.tis.iai.inf.tud.de/}IHelloService
from class
de.tud.inf.iai.tis.webaudraga.interfaces.helloservice.IHelloService
Client proxy: org.apache.cxf.frontend.ClientProxy@460f774f
[FRONTEND] Calling Webservice ...
[FRONTEND] Webservice ANSWER: Aloha World



On 4/13/2012 3:55 PM, David Bosschaert wrote:
> Hi Thomas,
> 
> I'm not sure I fully follow your scenario.
> 
> I think the best way to do this is by using a shared interface
> bundle. Like is done in the greeter demo: 
> http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html
>
>  Since you probably want to program against the API on the client
> side it generally makes sense to have the interface there available
> anyway, otherwise the only way you can access the service is via
> reflection.
> 
> So I would recommend to have an interfaces bundle which is shared 
> between the client and the server, as is done with the greeter
> demo. Then things should work nicely. I think trying to read a
> .class file from the server may generally not be what you want.
> 
> Cheers,
> 
> David
> 
> On 13 April 2012 14:45, Thomas Pischulski <ne...@googlemail.com>
> wrote:
>> Hi,
>> 
>> currently I'm publishing web services via DOSGi in Equinox with
>> the single distribution bundle 1.3. I can successfully create the
>> service when both, the web service interface and the interface
>> implementation are located in the same bundle. However, when put
>> both into separate bundles the server gets still successfully
>> created (also the published *.wsdl-file stays the same) but I
>> always receive "null" for any web service request. For the client
>> side I'm using the ClientProxyFactoryBean factory. All requests
>> to the server return correct responses when interface and
>> implementation of the server are located in the same bundle.
>> 
>> My main goal is to access the server's interface.class file on
>> the client-side. I don't want to generate my stub with wsimport
>> or wsdl2java.
>> 
>> In the approach that I tried to realize first I would get the
>> solution because both OSGi platforms can access an
>> "interface-bundle" because it's synced via SVN.
>> 
>> Cheers,
>> 
>> Thomas

Re: DOSGi CXF WebService Interface and Implementation in different bundles

Posted by David Bosschaert <da...@gmail.com>.
Hi Thomas,

I'm not sure I fully follow your scenario.

I think the best way to do this is by using a shared interface bundle.
Like is done in the greeter demo:
http://cxf.apache.org/distributed-osgi-greeter-demo-walkthrough.html

Since you probably want to program against the API on the client side
it generally makes sense to have the interface there available anyway,
otherwise the only way you can access the service is via reflection.

So I would recommend to have an interfaces bundle which is shared
between the client and the server, as is done with the greeter demo.
Then things should work nicely. I think trying to read a .class file
from the server may generally not be what you want.

Cheers,

David

On 13 April 2012 14:45, Thomas Pischulski <ne...@googlemail.com> wrote:
> Hi,
>
> currently I'm publishing web services via DOSGi in Equinox with the
> single distribution bundle 1.3. I can successfully create the service
> when both, the web service interface and the interface implementation
> are located in the same bundle. However, when put both into separate
> bundles the server gets still successfully created (also the published
> *.wsdl-file stays the same) but I always receive "null" for any web
> service request. For the client side I'm using the
> ClientProxyFactoryBean factory. All requests to the server return
> correct responses when interface and implementation of the server are
> located in the same bundle.
>
> My main goal is to access the server's interface.class file on the
> client-side. I don't want to generate my stub with wsimport or wsdl2java.
>
> In the approach that I tried to realize first I would get the solution
> because both OSGi platforms can access an "interface-bundle" because
> it's synced via SVN.
>
> Cheers,
>
> Thomas