Hello
I need to do gateway registration to Openfire+smack.
i am getting
Error registering user: remote-server-not-found(404)
**can you plz post the code **
MyCODE
package registration;
import java.util.HashMap;
import java.util.Map;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Registration;
public class RegistrationManager {
public static void register(XMPPConnection conn, String gateway, String username, String password, String nickname) throws XMPPException
{
if(username == null || username.length() == 0 ||
password == null || password.length() == 0 ||
nickname == null || nickname.length() == 0 ||
gateway == null || gateway.length() == 0)
throw new XMPPException(“Incorrect paramaters”);
Registration registration = new Registration();
registration.setType(IQ.Type.SET);
registration.setTo(gateway);
registration.addExtension(new GatewayRegisterExtension());
Map attributes = new HashMap();
if (username != null) attributes.put(“username”, username);
if (password != null) attributes.put(“password”, password);
if (username != null) attributes.put(“email”, username);
// if (nickname != null) attributes.put(“nick”, nickname);
registration.setAttributes(attributes);
PacketCollector collector = conn.createPacketCollector(new PacketIDFilter(registration.getPacketID()));
conn.sendPacket(registration);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
collector.cancel();
if(response == null){
System.out.println(response.getXmlns());
System.out.println(response.getChildElementXML());
throw new XMPPException(“Server timed out”);}
if(response.getType() == IQ.Type.ERROR)
{
System.out.println(response.getXmlns());
System.out.println(response.getChildElementXML());
throw new XMPPException(“Error registering user”, response.getError());
}
if(!conn.getRoster().contains(gateway))
conn.getRoster().createEntry(gateway, gateway, null);
Presence subscribe = new Presence(Presence.Type.subscribe);
subscribe.setTo(gateway);
subscribe.setFrom(conn.getUser());
conn.sendPacket(subscribe);
}
}
package registration;
import org.jivesoftware.smack.packet.PacketExtension;
class GatewayRegisterExtension implements PacketExtension
{
public String getElementName()
{
return “x”;
}
public String getNamespace()
{
return “jabber:iq:register”;
}
public String toXML()
{
StringBuilder builder = new StringBuilder();
builder.append("<").append(getElementName()).append(" xmlns="").append(getNamespace()).append(""/>");
System.out.println(“builder”+builder);
return builder.toString();
}
}
XML request
idhasoftemailtest@gmail.comidhasoftemailtest@gmail.comidhas0ftemailtest
XML response