【问题标题】:FOMUnsupportedTextTypeException: Unsupported Text Type: text/htmlFOMUnsupportedTextTypeException:不支持的文本类型:文本/html
【发布时间】:2015-02-05 09:31:41
【问题描述】:

我正在尝试使用 apache abdera 在休息调用后解析从 websphere 门户收到的响应原子提要。但是在解析时收到以下错误。有人可以告诉我问题是什么吗?

org.apache.abdera.parser.stax.FOMUnsupportedTextTypeException:不支持的文本类型:text/html

    Abdera abdera = new Abdera();
    AbderaClient abderaClient = new AbderaClient(abdera);
    Factory factory = abdera.getFactory();        
    Cookie[] cookies=request.getCookies();
    org.apache.commons.httpclient.Cookie ltpaCookieHttpCommons = new org.apache.commons.httpclient.Cookie();
    RequestOptions options = new RequestOptions(true);
    List<String> cookieStrings = new ArrayList<String>();
    options.setHeader("Cookie", (String[])cookieStrings.toArray(new String[cookieStrings.size()]));

    ClientResponse resp = abderaClient.get("http://localhost:10039/wps/contenthandler/!ut/p/digest!W9TQFjuU7ADCwtSkxDsxHg/searchfeed/search?queryLang=en&locale=en&resultLang=en&query=test&scope=com.ibm.lotus.search.ALL_SOURCES&start=0&results=10&output=application/xml", options);
    System.out.println(resp.getType());
    if (resp.getType() == ResponseType.SUCCESS) {
        System.out.println("!!!!!!Response success!!!!!!");
        Document<Feed> docFeed = resp.getDocument();
        // JSON Output
        Writer writer = abdera.getWriterFactory().getWriter("json");
        try { 
            Feed feed=docFeed.getRoot();

            abdera.getWriterFactory().getWriter("json").writeTo(feed, System.out);
        } catch(Exception e) {
            e.printStackTrace();
        }
    } else {

    }    

【问题讨论】:

    标签: websphere-portal apache-abdera


    【解决方案1】:

    问题是您解析的原子提要有一个带有text/html 的类型标签,它不在atom spec 中,所以abdera 会抛出上述错误。

    根据规范:

    当存在时,值 必须是“text”、“html”或“xhtml”之一

    您确定该提要是原子提要,而不是支持上述 MIME 类型的附件的 RSS 提要吗?

    【讨论】:

    • 它有效,来自webphere。我认为它有一些 ibm 特定的名称空间。我使用javascript手动解析它。
    • 它可能来自 websphere,所以你无能为力,但它不是有效的原子是我的观点,所以在先修改它之前不能使用 abdera。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    • 1970-01-01
    相关资源
    最近更新 更多