Java 从Liferay门户获取文章

Java 从Liferay门户获取文章,java,soap,service,liferay,portal,Java,Soap,Service,Liferay,Portal,我们的目标是使用Java通过SOAP服务从Liferay Portal获取一些内容。我们正在使用JournalArticleServiceSoap成功加载文章。问题是,该方法需要组id和条目id,我们需要的是从特定组获取所有项目。因此,我们尝试使用AssetEntryServiceSoap首先获取ID,但失败了 AssetEntryServiceSoapServiceLocator aesssLocator = new AssetEntryServiceSoapServiceLocator();

我们的目标是使用Java通过SOAP服务从Liferay Portal获取一些内容。我们正在使用JournalArticleServiceSoap成功加载文章。问题是,该方法需要组id和条目id,我们需要的是从特定组获取所有项目。因此,我们尝试使用AssetEntryServiceSoap首先获取ID,但失败了

AssetEntryServiceSoapServiceLocator aesssLocator = new AssetEntryServiceSoapServiceLocator();
    com.liferay.client.soap.portlet.asset.service.http.AssetEntryServiceSoap assetEntryServiceSoap = null;

    URL url = null;
    try {
        url = new URL(
                "http://127.0.0.1:8080/tunnel-web/secure/axis/Portlet_Asset_AssetEntryService");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    try {
        assetEntryServiceSoap = aesssLocator
                .getPortlet_Asset_AssetEntryService(url);
    } catch (ServiceException e) {
        e.printStackTrace();
    }
    if (assetEntryServiceSoap == null) {
        return;
    }

    Portlet_Asset_AssetEntryServiceSoapBindingStub assetEntryServiceSoapBindingStub = (Portlet_Asset_AssetEntryServiceSoapBindingStub) assetEntryServiceSoap;
    assetEntryServiceSoapBindingStub.setUsername("bruno@7cogs.com");
    assetEntryServiceSoapBindingStub.setPassword("bruno");

    AssetEntrySoap[] entries;
    AssetEntryQuery query = new AssetEntryQuery();

    try {
        int count = assetEntryServiceSoap.getEntriesCount(query);
        System.out.println("Entries count: " + Integer.toString(count));
        entries = assetEntryServiceSoap.getEntries(query);
        if (entries != null) {
            System.out.println(Integer.toString(entries.length));
        }
        for (AssetEntrySoap aes : assetEntryServiceSoap.getEntries(query)) {
            System.out.println(aes.getEntryId());
        }
    } catch (RemoteException e1) {
        e1.printStackTrace();
    }
尽管getEntriesCount()返回一个正数,如83,但getEnries()始终返回一个空数组。我对Liferay portal很陌生,但它看起来真的很奇怪


顺便说一句,我们显然不是在寻找性能,关键是从门户远程获取一些特定的内容。如果您知道任何可行的解决方案,我们将非常感谢您的帮助。

通常AssetEntryQuery中会包含更多的信息,例如:

AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
assetEntryQuery.setClassNameIds(new long[] { ClassNameLocalServiceUtil.getClassNameId("com.liferay.portlet.journal.model.JournalArticle") });
assetEntryQuery.setGroupIds(new long[] { groupId });
因此,这将返回您指定的groupId的所有资产,它们也是日志文章


试试看,尽管正如您所说,Count方法返回一个正数,所以它可能不会有什么不同,但请尝试一下!)

您好,我跟踪了代码,发现通过发送AssetEntryQuery()的普通对象,您可能无法获得准确的查询。查看com.liferay.portlet.asset.service.persistence.AssetEntryFinderImpl的方法findEntries(AssetEntryQuery entryQuery)条目