baalexander / node-xmlrpc

A pure JavaScript XML-RPC client and server for Node.js.
MIT License
298 stars 149 forks source link

Specifying number as long int when calling method #136

Open iggi- opened 8 years ago

iggi- commented 8 years ago

When connecting to our java xmlRPC server, we're noting an issue where our javascript numbers are being converted to type int and then the xmlRPC looks up the method, it does not find a method that matches since it is expecting a long.

I see support for i8 tags have been added, but I'm not seeing a way in the code to use them when making a call, only on the return.

How can we make calls with variables sent as a Long?

iggi- commented 8 years ago

Was able to add this functionality in a fairly hacked up way.

After line 24 in Serialize.js add: .att("xmlns:ex", "http://ws.apache.org/xmlrpc/namespaces/extensions")

After Line 180 in Serialize.js replace with:

    if(/<ex:i8>(.*?)<\/ex:i8>/g.exec(value)){
      value = value.replace(/(<([^>]+)>)/ig,"");
      xml.ele('ex:i8').raw(value)
    } else {
      xml.ele('string').d(value)
    }

then just use the<ex:i8></ex:i8>tag in a string (yuck) to cast it as a long.

Again, this is a hack to get this to work with a tomcat xmlrpc servlet, but I wanted to note this for anyone else having the problem and maybe this can be implemented upstream sometime.