I checked the example of blog-feed and fixed my problem.
Actually the code was right. It is the composite file that had sth.
wrong. In my composite file, I exposed service with the component:
<component name="FeedComponent">
<implementation.java class="rocku.java.infoshare.services.FeedImpl"
/>
<service name="Collection">
<t:binding.rss />
</service>
</component>
while in the blog-feed example, the RSS service was promoted:
<service name="BlogRSSAPIs" promote="BlogRSS">
<tuscany:binding.rss uri="http://localhost:8090/BlogRSSAPIs"/>
</service>
<component name="BlogRSS">
<implementation.java
class="com.tuscanyscatours.blog.feed.impl.RSSBlogFeedImpl"/>
</component>
I changed my composite file adding a promoted service and everything is OK.
So what's the difference between this two kind of service?
On Tue, Aug 16, 2011 at 3:37 PM, Simon Nash <[email protected]> wrote:
> Tianlong Wu wrote:
>
>> hello,
>> I was trying to build a rss feed service using tuscany.
>> I implemented the interface org.apache.tuscany.sca.**
>> binding.rss.collection.**Collection
>> like this:
>> public class FeedImpl implements Collection {
>>
>> public SyndEntry get(String id) throws NotFoundException {
>> // TODO Auto-generated method stub
>> SyndPerson author = new SyndPersonImpl( );
>> author.setEmail("editor@**example.org <[email protected]><mailto:
>> [email protected]>");
>>
>> author.setName("Example Person");
>> SyndEntry entry = new SyndEntryImpl( );
>> entry.setTitle("First Entry Title");
>>
>> entry.setLink("http://www.**example.org/item1<http://www.example.org/item1>
>> ");
>> SyndContent description = new SyndContentImpl( );
>> description.setValue("News about the Example project");
>> description.setType("text");
>> entry.setDescription(**description);
>> entry.setAuthors(Collections.**singletonList(author));
>> return entry;
>> }
>>
>> public SyndFeed getFeed() {
>> // TODO Auto-generated method stub
>> SyndPerson author = new SyndPersonImpl( );
>> author.setEmail("editor@**example.org <[email protected]><mailto:
>> [email protected]>");
>>
>> author.setName("Example Person");
>> SyndFeed feed = new SyndFeedImpl( );
>> feed.setTitle("Example Feed Output from ROME");
>> feed.setDescription("The Example Organization web site");
>> feed.setAuthors(Collections.**singletonList(author));
>> feed.setLink("http://www.**example.org/ <http://www.example.org/>
>> ");
>> feed.setPublishedDate(new Date( ));
>>
>> List<SyndEntry> entries = new ArrayList<SyndEntry>();
>>
>> try {
>> entries.add(this.get(""));
>> } catch (Exception e) {
>> // TODO: handle exception
>> }
>> feed.setEntries(entries);
>> return feed;
>> }
>>
>> public SyndFeed query(String queryString) {
>> // TODO Auto-generated method stub
>>
>> return getFeed();
>> }
>> }
>> and in my composite file there is:
>> <component name="FeedComponent">
>> <implementation.java class="rocku.java.infoshare.**services.FeedImpl"
>> />
>> <service name="Collection">
>> <t:binding.rss />
>> </service>
>> </component>
>>
>> The application run successfully. But when I open the URL(
>> http://localhost:8080/**FeedComponent<http://localhost:8080/FeedComponent>
>> )
>> in my browser, it outputs the following error:
>> HTTP ERROR: 500
>>
>> Invalid rss_2.0 feed, missing channel title
>> RequestURI=/FeedComponent
>>
>> Caused by:
>>
>> com.sun.syndication.io.**FeedException: Invalid rss_2.0 feed, missing
>> channel title
>> ......
>>
>> I found the JIRA page: https://issues.apache.org/**
>> jira/browse/TUSCANY-3111<https://issues.apache.org/jira/browse/TUSCANY-3111>.
>> It says that
>> adding a description to the feed would fix the problem. But I explicitly
>> set the title and
>> description in my code.
>>
>> Thanks for your time.
>>
>> The Tuscany travel sample contains an example of creating an RSS feed.
> See the contributions/blog-feed and launchers/blog-feed directories
> for details of how to do this successfully. The travel sample isn't
> part of the Tuscany binary distribution, so you'll need to download it
> separately from this page:
>
> http://tuscany.apache.org/sca-**java-travel-sample-1x-**releases.html<http://tuscany.apache.org/sca-java-travel-sample-1x-releases.html>
>
> Simon
>
>
> --
>> *******************************************************
>> Tianlong Wu
>>
>> Computer Science and Technology Dept.
>> Harbin Institute of Technology
>> NO.92 Xidazhi Street,150001
>> Harbin, Heilongjiang Province, P.R.China
>>
>
>
--
*****************************************************
Tianlong Wu
Computer Science and Technology Dept.
Harbin Institute of Technology
NO.92 Xidazhi Street,150001
Harbin, Heilongjiang Province, P.R.China