You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Georgi Dimitrov <mr...@abv.bg> on 2010/05/17 14:31:36 UTC

CXF Distributed OSGI and RESTful

 
Hi People,

I was trying to expose one of my OSGI Services as a Restful Web Service (exposing that same service as a SOAP Web Service works). For that purpose I am writing the appropriate informations (e.g. properties) in the sd.xml and remote-services.xml files.

But when I try to reach the RESTful web Service through Web Browser I only get the following response:

" No services have been found. "

Could you help me with this, since I have no Idea what I've done wrong.

Regards,
George

Re: CXF Distributed OSGI and RESTful

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

On Mon, May 17, 2010 at 3:23 PM, yoMrJ <mr...@abv.bg> wrote:

>
> Sorry Sergey, something went wrong with my mail :) I suppose that were the
> <!-- tags - they broke partially my stupid mail account :D o0.
>
> no problems


> So here i try anew:
>
> this is the content of my sd.xml:
>
>  <service-decoration>
>       <match interface="test.MyService">
>         <add-property name="service.exported.interfaces"
> value="test.MyService" />
>          <add-property name="service.exported.configs"
> value="org.apache.cxf.rs" />
>         <add-property name="service.exported.intents" value="HTTP" />
>          <add-property name="org.apache.cxf.rs.address"
> value="/myservice"/>
>         <add-property name="org.apache.cxf.rs.httpservice.context"
> value="/rest/ws/myservice"/>
>          <add-property name="org.apache.cxf.rs.databinding" value="aegis"/>
>      </match>
>   </service-decoration>
>
>
you need to use either  "org.apache.cxf.rs.address" which is an absolute
address or "org.apache.cxf.rs.
httpservice.context".


> my remote-services.xml looks like following:
>
>   <service-description>
>    <provide interface="test.MyService" />
>    <property name="osgi.remote.interfaces">*</property>
>    <property name="osgi.remote.configuration.type">pojo</property>
>    <property
> name="osgi.remote.configuration.pojo.address">http://
> ${DOSGI_SERVER}:23990/dosgi/ws/myservice</property>
>  </service-description>
>
>
> MyService works flawlesly as a SOAP Web Service (by changing the
> configuration on sd.xml and remote-services.xml). Could you please tell me
> what are the actual steps to expose a OSGI Service as a RESTful Web
> Service.
> I suppose that I have to:
> 1) edit sd.xml
> 2) edit remote-services.xml
>

remote-services.xml is optional (you do not need it if you use the discovery
service) but here is an example

http://svn.apache.org/repos/asf/cxf/dosgi/trunk/samples/greeter_rest/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml

3) What else? Do I need some annotations or could I go without them?
>

see
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-IntegrationwithDistributedOSGi



> 4) Do I need some extra libraries and if so where should I put them?
>
> For JSON you need to install Jettison 1.2 or indeed any other JSON aware
bundle and list it as a provider


> 5) can MyService be exposed as a SOAP and RESTful simultaneously (in the
> same time)?
>

Do you mean such that a single bean *instance* can handle both SOAP and REST
requests ? In DOSGI this can not be done by configuring the properties only.
At the moment this can only be done by explicitly registering the same bean
instance as both SOAP and RESTful service (doing two OSGI service
registration calls) from a custom bundle activator

cheers, Sergey


> Thanks for your help!
>
> Cheers,
> George
>
>
>
>
>
>
>
>
>
>
>
>
> Sergey Beryozkin-5 wrote:
> >
> >
> > Hi
> >
> > How does your sd.xml look like (just would like to see the properties).
> > Also
> > make sure that JAX RS api packages are being imported, though there's an
> > option there to avoid importing them...
> >
> > cheers, Sergey
> >
> > On Mon, May 17, 2010 at 1:31 PM, Georgi Dimitrov <mr...@abv.bg> wrote:
> >
> >>
> >> Hi People,
> >>
> >> I was trying to expose one of my OSGI Services as a Restful Web Service
> >> (exposing that same service as a SOAP Web Service works). For that
> >> purpose I
> >> am writing the appropriate informations (e.g. properties) in the sd.xml
> >> and
> >> remote-services.xml files.
> >>
> >> But when I try to reach the RESTful web Service through Web Browser I
> >> only
> >> get the following response:
> >>
> >> " No services have been found. "
> >>
> >> Could you help me with this, since I have no Idea what I've done wrong.
> >>
> >> Regards,
> >> George
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/CXF-Distributed-OSGI-and-RESTful-tp28582737p28584051.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: CXF Distributed OSGI and RESTful

Posted by yoMrJ <mr...@abv.bg>.
Sorry Sergey, something went wrong with my mail :) I suppose that were the
<!-- tags - they broke partially my stupid mail account :D o0.

So here i try anew:

this is the content of my sd.xml:

 <service-decoration>
      <match interface="test.MyService">
         <add-property name="service.exported.interfaces"
value="test.MyService" />
         <add-property name="service.exported.configs"
value="org.apache.cxf.rs" />
         <add-property name="service.exported.intents" value="HTTP" />
         <add-property name="org.apache.cxf.rs.address" value="/myservice"/>
         <add-property name="org.apache.cxf.rs.httpservice.context"
value="/rest/ws/myservice"/>
         <add-property name="org.apache.cxf.rs.databinding" value="aegis"/>
      </match>
   </service-decoration>


my remote-services.xml looks like following:

  <service-description>
    <provide interface="test.MyService" />
    <property name="osgi.remote.interfaces">*</property>
    <property name="osgi.remote.configuration.type">pojo</property>
    <property
name="osgi.remote.configuration.pojo.address">http://${DOSGI_SERVER}:23990/dosgi/ws/myservice</property>
  </service-description>


MyService works flawlesly as a SOAP Web Service (by changing the
configuration on sd.xml and remote-services.xml). Could you please tell me
what are the actual steps to expose a OSGI Service as a RESTful Web Service.
I suppose that I have to:
1) edit sd.xml
2) edit remote-services.xml
3) What else? Do I need some annotations or could I go without them?
4) Do I need some extra libraries and if so where should I put them?

5) can MyService be exposed as a SOAP and RESTful simultaneously (in the
same time)?

Thanks for your help!

Cheers,
George












Sergey Beryozkin-5 wrote:
> 
> 
> Hi
> 
> How does your sd.xml look like (just would like to see the properties).
> Also
> make sure that JAX RS api packages are being imported, though there's an
> option there to avoid importing them...
> 
> cheers, Sergey
> 
> On Mon, May 17, 2010 at 1:31 PM, Georgi Dimitrov <mr...@abv.bg> wrote:
> 
>>
>> Hi People,
>>
>> I was trying to expose one of my OSGI Services as a Restful Web Service
>> (exposing that same service as a SOAP Web Service works). For that
>> purpose I
>> am writing the appropriate informations (e.g. properties) in the sd.xml
>> and
>> remote-services.xml files.
>>
>> But when I try to reach the RESTful web Service through Web Browser I
>> only
>> get the following response:
>>
>> " No services have been found. "
>>
>> Could you help me with this, since I have no Idea what I've done wrong.
>>
>> Regards,
>> George
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/CXF-Distributed-OSGI-and-RESTful-tp28582737p28584051.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF Distributed OSGI and RESTful

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

How does your sd.xml look like (just would like to see the properties). Also
make sure that JAX RS api packages are being imported, though there's an
option there to avoid importing them...

cheers, Sergey

On Mon, May 17, 2010 at 1:31 PM, Georgi Dimitrov <mr...@abv.bg> wrote:

>
> Hi People,
>
> I was trying to expose one of my OSGI Services as a Restful Web Service
> (exposing that same service as a SOAP Web Service works). For that purpose I
> am writing the appropriate informations (e.g. properties) in the sd.xml and
> remote-services.xml files.
>
> But when I try to reach the RESTful web Service through Web Browser I only
> get the following response:
>
> " No services have been found. "
>
> Could you help me with this, since I have no Idea what I've done wrong.
>
> Regards,
> George
>

Re: Re: Re: CXF Distributed OSGI and RESTful

Posted by yoMrJ <mr...@abv.bg>.
Hi Sergey,

Just checked out our App that has an OSGI Environment a new from our local
svn(Clean Configuration). Then just edited the config.ini to add the two
bundles:
cxf-dosgi-ri-samples-greeter-rest-interface-1.1.jar
cxf-dosgi-ri-samples-greeter-rest-impl-1.1.jar 

Then i checked in the OSGI console -> Bundles are ACTIVE and OK!

Trying to access the URL:
http://localhost:23990/greeter/greeter/greeting/Fred

gives me 404...
So, I can not confirm it is working without modifying anything - as it does
not.
Am I missing something?

Please answer those questions:
1) Which cxf bundles do I exactly need to add to my config.ini ?
2) Do I need to also specify the greeter and greeter2 services in the sd.xml
or not?

Cheers,
George
-- 
View this message in context: http://old.nabble.com/CXF-Distributed-OSGI-and-RESTful-tp28582737p28619062.html
Sent from the cxf-user mailing list archive at Nabble.com.