Thursday, September 17, 2015

WSO2 ESB Feed Inbound Endpoint

Atom 1.0

Atom is the name of an XML-based Web content and metadata syndication format, and an application-level protocol for publishing and editing Web resources belonging to periodically updated websites. All Atom feeds must be well-formed XML documents, and are identified with the application/atom+xml media type.
General considerations:
  • All elements described in Atom must be in the http://www.w3.org/2005/Atom namespace.
  • All timestamps in Atom must conform to RFC 3339.
  • Unless otherwise specified, all values must be plain text (i.e., no entity-encoded html).

Sample Atom Feed

 
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
        <title>Example Feed</title>
        <subtitle>Insert witty or insightful remark here</subtitle>
        <link href="http://example.org/"/>
        <updated>2003-12-13T18:30:02Z</updated>
        <author>
                <name>WSO@ Inc</name>
                <email>WSO@@wso2.com</email>
        </author>
        <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
        <entry>
                <title>Atom-Powered Robots Run Amok</title>
                <link href="http://example.org/2003/12/13/atom03"/>
                <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
                <updated>2003-12-13T18:30:02Z</updated>
                <summary>Some text.</summary>
        </entry>
  
</feed>

RSS 2.0

RSS is a Web content syndication format. Its name is an acronym for Really Simple Syndication. RSS is dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.At the top level, a RSS document is a <rss> element, with a mandatory attribute called version, that specifies the version of RSS that the document conforms to. If it conforms to this specification, the version attribute must be 2.0. Subordinate to the <rss> element is a single <channel> element, which contains information about the channel (metadata) and its contents.

Sample RSS Feed

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
        <channel>
                <title>Example Feed</title>
                <description>Insert witty or insightful remark here</description>
                <link>http://example.org/</link>
                <lastBuildDate>Sat, 02 AUG 2015 18:30:02 GMT</lastBuildDate>
                <managingEditor>WSO2@wso2.com (WSO@ Inc)</managingEditor>
                <item>
                        <title>Atom-Powered Robots Run Amok</title>
                        <link>http://example.org/2003/12/13/atom03</link>
                        <guid isPermaLink="false">urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</guid>
                        <pubDate>Sat, 02 AUG 2015 18:30:02 GMT</pubDate>
                        <description>Some text.</description>
                </item>
        </channel>
</rss>


What is Feed Inbound

WSo2 Feed Inbound Developed Based on Apache Abdera   to Consume the Feeds. and inbound filter the feed and its allow only selected Elements of Feed into ESB. We can Configure the time interval to check to new feed updates after it will update to ESB if any new feed Update in given site. for the input URL Atom or RSS but out output will be in Atom format because Atom is the well structured format.

Feed Inbound Sample Configuration

Feed Inbound Configuration


<inboundEndpoint class="org.wso2.carbon.inbound.feedep.FeedEP"
     name="feed" onError="Fault" sequence="TestIn" suspend="false">
     <parameters>
         <parameter name="feed.type">Atom</parameter>
         <parameter name="interval">10000</parameter>
         <parameter name="feed.url">http://news.google.co.in/news?cf=all&amp;hl=en&amp;pz=1&amp;ned=in&amp;output=atom</parameter>
     </parameters>
 </inboundEndpoint>

Feed Inbound Sample Output

Feed Inbound Output


<feed xmlns="http://www.w3.org/2005/Atom">
    <entry>
        <title type="text">Wso2 ESB Feed Inbound Test Title</title>
        <updated>2015-08-31T16:29:00.000Z</updated>
        <content type="text">Feed Inbound Testing
        <link rel="self" href="/feed" />
            <author>
                <name>WSO Inc</name>
            </author>
        <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
        </content>
    </entry>
</feed>

 

Elements of <feed>

A Feed consists of some meta data, followed by any number of entries.

Required feed elements
Here’s a list of the required feed elements, each with a brief description, and an example.

Element
Description
idIdentifies the feed using a universally unique and permanent URI. If you have a long-term, renewable lease on your Internet domain name, then you can feel free to use your website’s address.
titleContains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank.
<title>Example, Inc.</title>
updatedIndicates the last time the feed was modified in a significant way.
<updated>2003-12-13T18:30:02Z</updated>
Recommended feed elements
Atom makes a number of additional requirements and recommendations for feed elements that you should to be aware of. They are as follows:

content  :  Contains or links to the complete content of the entry. Content must be provided if there is no alternate link, and should be provided if there is no summary. More info here.
           <content>complete story here</content>

author : Names one author of the entry. An entry may have multiple authors. An entry must contain at least one author element unless there is an author element in the enclosing feed, or there is an author element in the enclosed source element. More info here.
            <author>
               <name>WSO2 Inc</name>
            </author>

link : Identifies a related Web page. The type of relation is defined by the rel attribute. An entry is limited to one alternate per type and hreflang. An entry must contain an alternate link if there is no content element. More info here.
                <link rel="alternate" href="/feed/1234"/>