PDA

View Full Version : Rss Feed Viewer



gizzmo
17 Nov 2006, 6:11 AM
Hi,

I'm implementing the rss feed viewer into domino.
And as long as I adds the same rss files it works.
But when I try to load my own it does not work.
Should it be build in a certain way?

Regards Johan

jack.slocum
17 Nov 2006, 8:33 AM
Is your feed RSS 2.0 or ? Did you try your feed in the original site and it worked or not? Can you post the link to your feed?

gizzmo
17 Nov 2006, 1:25 PM
Hi,

I use RSS 2.0. The link to it is: http://pro2.procensor.se/Privat/jsv/Yahoo.nsf/myfeed.xml?OpenPage

But it works if I pass it through your page. But not through mine. So I think the problem is my proxy.
What content type do you set as output? I use a java servlet and the code look as follow:


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class YahooXmlProxy extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

try {

response.setContentType("text/xml");

// Create the URL
URL url = new URL(request.getParameter("url"));

// Open the url stream
InputStream stream = url.openStream();

// Create the output qriter
PrintWriter out = response.getWriter();

int buffer;

// Read and Write the url
while ((buffer = stream.read()) != -1) {
out.print((char) buffer);
}

}

catch (Exception e) {
System.out.println(e.getMessage() + " : " + e.toString());
e.printStackTrace();
}
}
}


This servlet let the feeds in your implementation through but not the one I created.

Johan

gizzmo
17 Nov 2006, 2:05 PM
I've just discovered that my servlet and implementation of the feed viewer works perfect IF I run it on a locally installed server. But if I try the same code on a public server on the Internet it doesn't work.

Can't figure out what's the problem is.

Johan

Herm
17 Nov 2006, 10:55 PM
It could be a java security thang. I recently had to make a change on one of my servers to allow code running in domino's jvm to access external resources through our corporate proxy. I googled the solution at the time. My config mgmt notes say:
Changed E:\lotus\domino\jvm\lib\security\java.policy

Granted rights to allow programs to change the proxy server used when http connections

//8/9/2006: PH. Allows java agents to access http via the proxy
permission java.util.PropertyPermission "http.proxyHost", "read,write";
permission java.util.PropertyPermission "http.proxyPort", "read,write";

gizzmo
19 Nov 2006, 1:23 PM
Herm, we don't use any proxy to connect to the internet.
And the only xml files (rss) I'm having trouble with is feeds coming from my own domain.

ex. http://mydomain.com/servlet/YahooXmlProxy?url=http://mydomain.com/db.nsf/rss?OpenPage

But this works.

http://mydomain.com/servlet/YahooXmlProxy?url=http://sports.yahoo.com/top/rss.xml

or

http://localhost/servlet/YahooXmlProxy?url=http://localhost/db.nsf/rss?OpenPage

jack.slocum
19 Nov 2006, 10:13 PM
Your code looks fine. If I'm not mistaken, doesn't URL.openStream also read the headers? If it does, you would also be printing out the headers with the XML which would make the XML invalid. I could very well be wrong though, it's been a while.

gizzmo
19 Nov 2006, 11:39 PM
I will look into it. But shouldn't other feeds, say yours, be invalid as well then?
It is only feeds from my own domain that doesn't work.

Herm
19 Nov 2006, 11:54 PM
So it's either your proxy or your server based db.nsf. Assuming your db has an OK ACL (reader to the RSS page for Anonymous) I would look at the servlet. What happens if you try (using your example terminology):

http://localhost/servlet/YahooXmlProxy?url=http://mydomain.com/db.nsf/rss?OpenPage

If that works, then the problem is the server hosted servlet. Maybe it can't resolve DNS back to itself? To make the server servlet bypass dns you could test:

http://mydomain.com/servlet/YahooXmlProxy?url=http://<serverIPaddr>/db.nsf/rss?OpenPage

where <serverIPaddr> is 127.0.0.1 or it's real address 10.1.1.10 or whatever.

Peter

gizzmo
20 Nov 2006, 3:04 PM
I tried load the outside feed on my local server as you said. And it worked.
So I then tried to replace my domain with the ip address as suggested.
And it also worked.

So it seems that it can't resolve DNS back to it self.
Now comes my next problem. Any idea how to fix that?

Herm
20 Nov 2006, 10:50 PM
This is now pretty off topic but I'm happy to help ...

First, you probably know that proxies can be dangerous things (for their owners) - make sure you don't leave it open to abuse. See the paragraph that starts 'For security reasons it's a good idea for any proxy you install on your web server should be limited in use' here: http://developer.yahoo.com/javascript/howto-proxy.html .

So, assuming that your server is just a windows, standalone 'test' machine and you want it to resolve 'mydomain.com' back to itself, you could:

- (In Windows) My Computer - Properties, change the computer name to 'mydomain.com'
- (or, in any OS) put an entry in the hosts file (you can google for how to do this) that looks like this:
# here is a comment, next line is the mapping
127.0.0.1 mydomain.com

To test, on the same server (in a command prompt), do: 'ping mydomain.com' and it should work.

gizzmo
22 Nov 2006, 2:34 PM
A quick solution that worked was to put an entry in my hostfile.
But as you said, that is not a good solution.
Will look into my DNS setting to see if I could change anything.

Thanks Herm. I know it got out of topic but I'm glad that you helped me.

Cheers

Herm
22 Nov 2006, 7:35 PM
Good stuff - very happy to hear that Johan. I'd be interested in how you go. Are you a domino developer? I'd love to see your demo results and any extensions.

Cheers, Peter
peter.herrmann at gmail dot com.

gizzmo
23 Nov 2006, 7:08 AM
Yes, I'm a domino developer.
Right know I just play with the yahoo api.

Has applied it to a movie database of mine.
Check it out: http://pro2.procensor.se/Privat/jsv/IMDB.nsf/Test?OpenForm

Herm
23 Nov 2006, 2:21 PM
Hey, nice work Johan. I see you load data as "movielist.xml" so you already have done some prep at the server side. Like the tag cloud. I see you have your yui js in the db (is that the prefab YUI db from Jake at codestore.net ?). I stuck it on the server.

I have been thinking about trying to get a client side js to better handle the xml generated from a <viewname>?readviewentries... request. I already do it with a yui TreeView (but it's not elegant, just tactical) and a datamodel has been built here http://www.openntf.org/Projects/pmt.nsf/ProjectHome?ReadForm&Query=Domino%20YUI (though I think it's gone cold).

I like the idea of doing a bit of work on better interfacing via readviewentries because it means there is no server side work (unless you choose to do it) and it would work with existing apps.

valc
18 Dec 2006, 10:18 AM
Hi Johan,

I'm a Domino developer and I too am looking at yui/domino integration.
I haven't looked through your code but I'd be interested in hearning how you have are generating the movies.xml file ? Are you wrapping tags in the view columns ?

Regards,

Val.

shivkanth_majji
3 Mar 2009, 2:40 PM
Hi ,

I am trying to use FeedGrid.js component from feed-viewer example in my application which has java backend. I tried using your java servlet code and it works i.e i can see the response back in firebug. But, FeedGrid is not able to render the data. I think it because of the header information in the returned XML.

I just want to know if these header tags cause a problem and is yes is there a way to remove these tags. Thanks in advance.

I am also attaching the sample XML returned by the servlet.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type
="text/css" media="screen" href="http://feeds2.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns
:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner
="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
<title>Ext JS Blog</title>

<link>http://extjs.com/blog</link>
<description>JavaScript UI Component Library</description>
<pubDate>Thu, 19 Feb 2009 18:21:33 +0000</pubDate>
<generator>http://wordpress.org/?v=2.6.2</generator>
<language>en</language>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds2.feedburner
.com/extblog" type="application/rss+xml" /><item>
<title>Pixel Bender Explorer: Bending Ext AIR Apps</title>
<link>http://feedproxy.google.com/~r/extblog/~3/oU6yeUSPB8s/</link>
<comments>http://extjs.com/blog/2009/02/19/pixel-bender-explorer/#comments</comments>
<pubDate>Thu, 19 Feb 2009 15:23:33 +0000</pubDate>
<dc:creator>Aaron Conran</dc:creator>

shivkanth_majji
3 Mar 2009, 5:15 PM
Hi Jack,

I would like know if it is possible to strip down your feed viewer component. What I am planning to do is too have a simple Grid or panel which displays a specific RSS feed. No MainPanel, FeedPanel etc. I would like to have FeedGrid only which keeps refreshing data from a RSS feed. No offense to your cool component but, cant fit that layout and presentation in our app.

I did try implementing it using your FeedGrid.js it does work i.e fires a request to the server and the server responds with the right data. But, FeedGrid simply doesnt render it. I think there is some dependency on either the css or some other file but, firebug doesn't show any error. Please do advice.

Thanks,

Shiv