Consommer un flux RSS
cool-abdoul
Messages postés
103
Statut
Membre
-
cool-abdoul -
cool-abdoul -
Bonjour les amis,
je cherche à cosommer un plus ? Pouvez vous m'aider ?
* J'ai fait un test unitaire avec des System.out.println et je constate que je rentre dans le try mais
* et qu'une exception pête pour me renvoyer dans le catch
En fait la methode
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=vie"
));
ChangeXml wXml = new ChangeXml(fluxConso);
myChange = wXml.getSerializableChange();
qui me permet de consommer le flux RSS n'est jamais exécutée !
* je ne compreends pas !
* voici mon code !!
import change3.domain.ChangeXml;
import change3.domain.ChangeSerializable;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.Time;
import com.liferay.portal.kernel.webcache.WebCacheException;
import com.liferay.portal.kernel.webcache.WebCacheItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ChangeWebCacheItem implements WebCacheItem {
protected static Log logs = LogFactory.getLog(ChangeWebCacheItem.class);
private static final long _REFRESH_TIME = Time.MINUTE * 20;
private String symbole;
private boolean euro;
public ChangeWebCacheItem(String symbol, boolean euro) {
symbole = symbol;
this.euro = euro;
}
public Object convert(String arg0) throws WebCacheException {
ChangeSerializable myChange = null;
try {
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=vie"
));
ChangeXml wXml = new ChangeXml(fluxConso);
myChange = wXml.getSerializableChange();
} catch (Exception e) {
throw new WebCacheException();
}
return myChange;
}
/*
public static void main (String[] args) throws WebCacheException {
String symbole ="";
ChangeSerializable mychange = null;
System.out.println("Avant le try !");
try {
System.out.println("Debut du try ");
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=cac"));
System.out.println(fluxConso);
ChangeXml wXml = new ChangeXml(fluxConso);
mychange = wXml.getSerializableChange();
} catch (Exception e) {
throw new WebCacheException();
//System.out.println("message du catch !");
}
}
*/
}
je cherche à cosommer un plus ? Pouvez vous m'aider ?
* J'ai fait un test unitaire avec des System.out.println et je constate que je rentre dans le try mais
* et qu'une exception pête pour me renvoyer dans le catch
En fait la methode
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=vie"
));
ChangeXml wXml = new ChangeXml(fluxConso);
myChange = wXml.getSerializableChange();
qui me permet de consommer le flux RSS n'est jamais exécutée !
* je ne compreends pas !
* voici mon code !!
import change3.domain.ChangeXml;
import change3.domain.ChangeSerializable;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.Time;
import com.liferay.portal.kernel.webcache.WebCacheException;
import com.liferay.portal.kernel.webcache.WebCacheItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ChangeWebCacheItem implements WebCacheItem {
protected static Log logs = LogFactory.getLog(ChangeWebCacheItem.class);
private static final long _REFRESH_TIME = Time.MINUTE * 20;
private String symbole;
private boolean euro;
public ChangeWebCacheItem(String symbol, boolean euro) {
symbole = symbol;
this.euro = euro;
}
public Object convert(String arg0) throws WebCacheException {
ChangeSerializable myChange = null;
try {
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=vie"
));
ChangeXml wXml = new ChangeXml(fluxConso);
myChange = wXml.getSerializableChange();
} catch (Exception e) {
throw new WebCacheException();
}
return myChange;
}
/*
public static void main (String[] args) throws WebCacheException {
String symbole ="";
ChangeSerializable mychange = null;
System.out.println("Avant le try !");
try {
System.out.println("Debut du try ");
String fluxConso = HtmlUtil.stripComments(HttpUtil.URLtoString(
"http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=cac"));
System.out.println(fluxConso);
ChangeXml wXml = new ChangeXml(fluxConso);
mychange = wXml.getSerializableChange();
} catch (Exception e) {
throw new WebCacheException();
//System.out.println("message du catch !");
}
}
*/
}
A voir également:
- Consommer un flux RSS
- Tiny tiny rss - Télécharger - Flux RSS
- Capture flux - Télécharger - TV & Vidéo
- Rss owl - Télécharger - Flux RSS
- Enregistrer flux audio pc - Guide
- Rss bandit - Télécharger - Web & Internet