| CODENOTIFIER | HelpYou are not signed inSign in |
Project: ejabberd-modules
Revision: 709
Author: badlop
Date: 31 Aug 2008 14:17:18
Changes:* README.txt: Added Java example client (thanks to Calder)
Files:| ... | ...@@ -215,7 +215,6 @@ | |
| 215 | 215 | ------- |
| 216 | 216 | |
| 217 | 217 | |
| 218 | ||
| 219 | 218 | EXAMPLE IN PHP |
| 220 | 219 | -------------- |
| 221 | 220 | |
| ... | ...@@ -247,3 +246,47 @@ | |
| 247 | 246 | |
| 248 | 247 | ?> |
| 249 | 248 | ------- |
| 249 | ||
| 250 | ||
| 251 | EXAMPLE IN JAVA | |
| 252 | --------------- | |
| 253 | ||
| 254 | This is an XML-RPC client in Java, thanks to Calder. | |
| 255 | It requires Apache XML-RPC available at http://ws.apache.org/xmlrpc/ | |
| 256 | ||
| 257 | ------- | |
| 258 | import java.net.URL; | |
| 259 | import java.util.HashMap; | |
| 260 | import java.util.Map; | |
| 261 | ||
| 262 | import org.apache.xmlrpc.client.XmlRpcClient; | |
| 263 | import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; | |
| 264 | ||
| 265 | public class Test { | |
| 266 | ||
| 267 | public static void main(String[] args) { | |
| 268 | try { | |
| 269 | XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); | |
| 270 | config.setServerURL(new URL("http://127.0.0.1:4560/RPC2")); | |
| 271 | XmlRpcClient client = new XmlRpcClient(); | |
| 272 | client.setConfig(config); | |
| 273 | ||
| 274 | /* Command string */ | |
| 275 | String command = "check_password"; | |
| 276 | ||
| 277 | /* Parameters as struct */ | |
| 278 | Map struct = new HashMap(); | |
| 279 | struct.put("user", "test1"); | |
| 280 | struct.put("host", "localhost"); | |
| 281 | struct.put("password", "test"); | |
| 282 | ||
| 283 | Object[] params = new Object[]{struct}; | |
| 284 | Integer result = (Integer) client.execute(command, params); | |
| 285 | System.out.println(result); | |
| 286 | } catch (Exception e) { | |
| 287 | System.out.println(e); | |
| 288 | } | |
| 289 | } | |
| 290 | ||
| 291 | } | |
| 292 | ------- |
| ... | ...@@ -1,6 +1,7 @@ | |
| 1 | 1 | 2008-08-31 Badlop <badlop@process-one.net> |
| 2 | 2 | |
| 3 | * README.txt: Fixed the PHP example (thanks to Calder) | |
| 3 | * README.txt: Added Java example client and fixed the PHP | |
| 4 | example (thanks to Calder) | |
| 4 | 5 | |
| 5 | 6 | 2008-07-24 Badlop <badlop@process-one.net> |
| 6 | 7 |