Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Last active December 15, 2016 21:44
Show Gist options
  • Select an option

  • Save theY4Kman/94e1bae90dfe8cdd5cf71c483f17578f to your computer and use it in GitHub Desktop.

Select an option

Save theY4Kman/94e1bae90dfe8cdd5cf71c483f17578f to your computer and use it in GitHub Desktop.
var util = require('util');
var xmlrpc = require('xmlrpc');
var Serializer = require('xmlrpc/lib/serializer');
function DoubleType(raw) {
xmlrpc.CustomType.call(this, raw);
}
util.inherits(DoubleType, xmlrpc.CustomType);
DoubleType.prototype.tagName = 'double';
var amount = 189.0;
console.log(Serializer.serializeMethodCall('test', [amount]));
// <?xml version="1.0"?><methodCall><methodName>test</methodName><params><param><value><int>189</int></value></param></params></methodCall>
console.log(Serializer.serializeMethodCall('test', [new DoubleType(amount)]));
// <?xml version="1.0"?><methodCall><methodName>test</methodName><params><param><value><double>189</double></value></param></params></methodCall>
// Used like:
var client = new Meteor.XmlRpcClient('https://{url_here}');
client.methodCall('payMeNow', [new DoubleType(189.00)], (error, value) => console.log(error, value));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment