【发布时间】:2012-04-02 06:04:25
【问题描述】:
我们的目标是使用 Java 通过 SOAP 服务从 Liferay Portal 获取一些内容。我们现在正在使用 JournalArticleServiceSoap 成功加载文章。问题是该方法需要 group id 和 entry 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 门户网站很陌生,但它对我来说真的很奇怪。
顺便说一句,我们显然不是在这里寻找性能,关键只是从门户中远程获取一些特定的内容。如果您知道任何可行的解决方案,我们将不胜感激。
【问题讨论】:
-
您好,我跟踪代码发现,通过发送AssetEntryQuery()的普通对象,您可能没有准确的查询。查看 com.liferay.portlet.asset.service.persistence.AssetEntryFinderImpl 的方法 findEntries(AssetEntryQuery entryQuery) 条目
标签: java soap service liferay portal