問(wèn)題描述
我正在嘗試使用最新的 Smackx 中繼來(lái)獲取并訂閱一個(gè) pubsub 節(jié)點(diǎn).但是,openfire 只是向我發(fā)送了一個(gè)錯(cuò)誤:找不到項(xiàng)目 (404).
I'm trying to use the latest Smackx trunk to get and then subscribe to a pubsub node. However, openfire just sends me a back an error: item not found (404).
我正在從 ColdFusion 實(shí)例化 java 對(duì)象,所以我的代碼片段可能看起來(lái)很有趣,但也許有人能告訴我我忘記了什么.
I am instantiating the java objects from ColdFusion, so my code snippets might look funny but maybe someone will be able to tell me what I've forgotten.
這是我創(chuàng)建節(jié)點(diǎn)的方式:
Here's how I create the node:
ftype = createObject("java", "org.jivesoftware.smackx.pubsub.FormType");
cform = createObject("java", "org.jivesoftware.smackx.pubsub.ConfigureForm").init(ftype.submit);
cform.setPersistentItems(true);
cform.setDeliverPayloads(true);
caccess = createObject("java", "org.jivesoftware.smackx.pubsub.AccessModel");
cform.setAccessModel(caccess.open);
cpublish = createObject("java", "org.jivesoftware.smackx.pubsub.PublishModel");
cform.setPublishModel(cpublish.open);
cform.setMaxItems(99);
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection);
myNode = manager.createNode("subber", cform);
這就是我試圖達(dá)到它的方式(在不同的代碼部分中):
And here's how I am trying to get to it (in a different section of code):
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection);
myNode = manager.getNode("subber");
在創(chuàng)建節(jié)點(diǎn)后,我似乎可以像這樣發(fā)布到它:
Immediately upon creating the node I seem to be able to publish to it like so:
payload = createObject("java", "org.jivesoftware.smackx.pubsub.SimplePayload").init("book","pubsub:test:book","<book xmlns='pubsub:test:book'><title>Lord of the Rings</title></book>");
item = createObject("java", "org.jivesoftware.smackx.pubsub.Item").init(payload);
myNode.publish(item);
但是,導(dǎo)致我的代碼出錯(cuò)的是 getNode() 調(diào)用.
However, it is the getNode() call that is causing my code to error.
我已經(jīng)通過(guò)檢查我的 openfire 服務(wù)器使用的數(shù)據(jù)庫(kù)來(lái)驗(yàn)證正在創(chuàng)建節(jié)點(diǎn).我可以在那里看到它們,正確地歸因于葉節(jié)點(diǎn)等.
I have verified that the nodes are being created by checking the DB used by my openfire server. I can see them in there, properly attributed as leaf nodes, etc.
有什么建議嗎?還有其他人在用 XMPP 和 ColdFusion 做任何事情嗎?我在使用 CF 發(fā)送和接收消息方面取得了巨大成功,而 Smack 還沒(méi)有讓 pubsub 工作:)
Any advice? Anyone else out there doing anything with XMPP and ColdFusion? I have had great success sending and receiving messages with CF and Smack just haven't had the pubsub working yet :)
謝謝!
推薦答案
已回答:
PubSubManager 類還有第二個(gè)方法,它接受兩個(gè)參數(shù),一個(gè)連接和一個(gè) to 參數(shù).顯然 Openfire 需要這個(gè) to 參數(shù),經(jīng)過(guò)一些實(shí)驗(yàn),我發(fā)現(xiàn)它可以使用 pubsub.your.xmpp.address
There is a second method on the PubSubManager class that accepts two arguments, a connection and a to parameter. Apparently Openfire requires this to parameter and after some experimenting i discovered that it works using pubsub.your.xmpp.address
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection,"pubsub.127.0.0.1");
這篇關(guān)于嘗試使用 Smackx pubsub 獲取節(jié)點(diǎn)時(shí)未找到項(xiàng)目(404)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!