mx-moth / jquery-xmlrpc Goto Github PK
View Code? Open in Web Editor NEWA jQuery library for talking to XML-RPC services from JavaScript
License: The Unlicense
A jQuery library for talking to XML-RPC services from JavaScript
License: The Unlicense
I'm successfully calling a RPC server with a jquery-xmlrpc client (source below), but the response parameter is corrupt despite being of the correct size. The server takes a base64 encoded Ogg and responds with a base64 encoded Ogg. I have a pure Python RPC client that's working fine, and the jquery-xmlrpc is sending the input correctlywith the exact same server, so is the base64 to ArrayBuffer conversion wonky?
<!DOCTYPE html>
<html>
<head>
<script src="jquery-3.0.0.min.js"></script>
<script src="jquery.xmlrpc.min.js"></script>
<script src="FileSaver.min.js"></script>
</head>
<body>
<input id="filePicker" type="file" accept=".ogg" />
<script>
var handleFileSelect = function(e) {
var files = e.target.files;
var file = files[0];
if (files && file) {
var reader = new FileReader();
reader.onload = function(e) {
$.xmlrpc({
url: '/RPC2',
methodName: 'process_audio',
params: {'audio': e.target.result},
success: function(response, status, jqXHR) {
saveAs(new Blob([response[0]], {type: 'audio/ogg'}), 'audio.ogg');
},
error: function(jqXHR, status, error) { console.error(jqXHR); }
});
};
reader.readAsArrayBuffer(file)
}
};
</script>
</body>
</html>
I am doing the following xml-rpc call.
$.xmlrpc({
url: '/api/rpc/v1/com.xxx.yyy',
methodName: 'getParameter',
params: ['Name'],
dataFilter: function(data, type) {
console.log(type);
console.log(data); // xml-rpc response is logged(Shown in scrnshot) - Works perfectly fine
},
success: function(respone, status, jqXHR) {
console.log(respone); // Here I get an empty object
});
});
I ran all the tests and it passed. I believe that the error occurs when the xml-rpc node is converted to the Javascript equivalent.
}
Hi there can I know whether I can supply an array of methods to the methodnames?
jquery-3.2.1.js:3860 jQuery.Deferred exception: True is not defined ReferenceError: True is not defined
at Object. (file:///C:/Users/user/Downloads/odoo-js/funciones.js:38:84)
at mightThrow (file:///C:/Users/user/Downloads/odoo-js/jquery-3.2.1.js:3583:29)
at process (file:///C:/Users/user/Downloads/odoo-js/jquery-3.2.1.js:3651:12) undefined
So, I have been working on figuring our why xmlrpc call sometimes returns the variables to the success callback correctly and at other times they are inside an array ie. when I expect this: [22, ....] I get [[22], ...]
Here is the method response:
<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
<params>
<param>
<value>
<int>24</int>
</value>
</param>
</params>
</methodResponse>
Don't know if it makes any difference but when I see the odd decoding, I use it like this:
$.when(rpc1(), rpc2()).then(function(r1, r2) { ... });
But things work as expected with just one rpc call in same setup.
This became a problem when I wanted to do some client side caching of a scalar value, because there can sometimes be nested arrays it is impossible to create a deferred object that would work with the callback in all cases.
The XML-RPC spec states that dateTimes must be encoded in ISO8601 format. Producing ISO dates in JavaScript is easy enough, with Date.prototype.toISOString()
into a native JavaScript date. Parsing ISO dates is also easy, new Date(string)
. However, both of these have problems.
The spec says that dateTimes should not have a timezone set. Working out timezones is not part of the spec. However, the default Date.prototype.toISOString()
implementation has a timezone of 'Z' (Zulu, same as UTC). This is against spec.
Additionally, the default new Date(string)
can not parse ISO8601 shorthand dates, as mentioned in the spec, and clarified in this document.
This means that this library does not yet conform to the XML-RPC spec. However, everything that I have seen that uses XML-RPC does not have any issues with these restrictions. If any one comes across a server where this is an issue, leave a comment here and I will look in to fixing it.
Hello,
If I try to use this library, I always obtain CORS error 'Access-Control-Allow-Origin'
How can I enable CORS in jquery-xml library? Any example?
Thanks
jquery-xmlrpc unable to send post to another domain, it said "No 'Access-Control-Allow-Origin' header is present on the requested resource"
Is there possible to get this one for next echantment ?
Please add package.json
for npm support as well
First of all: I'm new to js and also new to xmlrpc, so maybe this is me just derping. Sorry if that's the case.
TypeError: elems is undefined (jQuery.js:775) shows up in the console when using jquery 1.10.2 and jquery-xmlrpc 0.4.0 (last releases of both).
That jQuery line is part of the
// arg is for internal usage only
map: function( elems, callback, arg ) {
var value,
i = 0,
length = elems.length,
isArray = isArraylike( elems ),
ret = [];
The line that's failing is:
length = elems.length,
And im not able to backtrack the error to one of the mac calls your code does.
I don't know if it's a jQuery problem or this plugin problem, or just me, but i'm leaving this here just in case.
Repro
$.xmlrpc.parseDocument(d($('docxml').val()))
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>isCreator</name>
<value>
<boolean>1</boolean>
</value>
</member>
<member>
<name>originalStationId</name>
<value></value>
</member>
</struct>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
Expected Result
A valid JSON result
Actual Result
The parseDocument function aborts with the following error:
Uncaught TypeError: Cannot read property 'nodeName' of undefined
The following block of code assumes the 'value' element will always contain child elements and thus breaks in this scenario :
var value = xmlrpc.parseNode($el.find('> value > *').get(0));
I'm not sure if these empty value elements are valid but they occur in the wild or at least in some Pandora responses.
The xmlrpc.parseDocument converter seems to have some problems parsing structs in chrome.
The source of this, as far as I can tell, appears to be patchy reduce support in chrome as used by the struct decode function:
return $(node)
.find('> member')
.toArray()
.reduce(function(struct, el) {
var $el = $(el);
var key = $el.find('> name').text();
var value = xmlrpc.parseValue($el.find('> value'));
struct[key] = value;
return struct;
}, {});
This works fine in Firefox.
With a quick modification to avoid using reduce, everything worked fine e.g.
var struct = {};
$(node).find('> member').each(
function(index, el) {
var $el = $(el);
var key = $el.find('> name').text();
var value = xmlrpc.parseValue($el.find('> value'));
struct[key] = value;
});
return struct;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.