If I send a XMPP example message with the type='result' to the application everything is fine. But if I change the the type to 'set' or 'get' the application replies with an error message "feature-not-implemented". This is a weird because I follow a tutorial from the producer side.
I tried from this page http://www.igniterealtime.org/builds/smack/docs/latest/documentation/providers.html the example Custom IQProvider example.
I use Gradle 2.9 with the following dependencies:
dependencies {
//xjc 'com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.1'
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile "org.igniterealtime.smack:smack-java7:4.1.0"
// Optional for XMPPTCPConnection
compile "org.igniterealtime.smack:smack-tcp:4.1.0"
// Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …)
compile "org.igniterealtime.smack:smack-im:4.1.0"
// Optional for XMPP extensions support
compile "org.igniterealtime.smack:smack-extensions:4.1.0"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I implemented the classes MyIQProvider and MyIQ according to the description and register the provider with:
ProviderManager.addIQProvider("myiq", "example:iq:foo", new MyIQProvider());
If I send the following message (type='set') to the Smack Java application:
<iq type='set' from='apfel_vie@jabber.de/colibriVtn' to='birne_vie@jabber.de/colibriVen'>
<myiq xmlns='example:iq:foo' token='secret'>
<user age='42'>John Doe</user>
<location>New York</location>
</myiq>
</iq>
Then the application replies with:
<iq id='time_1' type='error' to='apfel_vie@jabber.de/colibriVtn' from='birne_vie@jabber.de/colibriVen'>
<error type='cancel'>
<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
The type='get' results in the same behavior.
But if I only change the type to 'result':
<iq type='result' from='apfel_vie@jabber.de/colibriVtn' to='birne_vie@jabber.de/colibriVen' id='time_1'>
<myiq xmlns='example:iq:foo' token='secret'>
<user age='42'>John Doe</user>
<location>New York</location>
</myiq>
</iq>
The Java Smack application does not reply such an error message.
What do I have to add/change that the application does not reply this error message in the case where the type is equal to set?
You need o register an IQ request handler: https://www.igniterealtime.org/builds/smack/docs/4.1.7/javadoc/org/jivesoftware/smack/XMPPConnection.html#registerIQRequestHandler-org.jivesoftware.smack.iqrequest.IQRequestHandler