npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

davexmlrpc

v0.4.26

Published

XML-RPC client and server in JavaScript.

Downloads

841

Readme

What is XML-RPC?

It's a spec and a set of implementations that allow software running on disparate operating systems, running in different environments to make procedure calls over the Internet.

It's remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned.

JavaScript implementation

Starting in 2019, there's a new implementation of XML-RPC in JavaScript.

  • Client and server for Node.js.

  • Client for the browser.

  • Pure JavaScript.

  • Supports XML and JSON encoding.

  • New debugger and validation suite.

  • Example code.

  • Written by one of the designers of the protocol.

Example client

Here's code that makes a simple XML-RPC call in a Node.js app.

It sends a call to the demo server, betty.userland.com.

The procedure it calls is "examples.getStateName," with a single parameter, the number 5.

The call will be made in XML (it could also use JSON if we know the server supports it).

When the server returns, the callback receives the standard Node error object in the first param, and if there was no error, the data returned through XML-RPC in the second parameter.

Example server

Here's the code for a simple XML-RPC server.

Here's pseudo-code that calls this service. It returns THIS IS A TEST.

Simple XML-RPC debugger

I've put up a simple app that lets you try calling an XML-RPC procedure from an HTML form, where you supply the URL of the endpoint, the verb you want to call, and its parameters as a JavaScript expression.

It then displays the result in JSON in a box below.

If there's an error message it's displayed in red.

You can try calling these routines on betty.scripting.com (it's the default endpoint):

  1. examples.getStateName, params = 31

  2. examples.getStateNames, params = [12, 22, 32, 42]

  3. examples.getStateList, params = [[12, 22, 32, 42]]

  4. examples.getStateStruct, params = [{state1: 3, state2: 42}]

  5. examples.getStateName, params = 900 (error)

  6. noSuchName (error)

If you open the JavaScript console, you'll see the actual XML-RPC cals, in XML, as they go over the wire. Screen shot.

How params work in the xmlRpcClient

The third param to the xmlRpcClient function is either a value or a list of values.

If it's a value, the XML-RPC procedure is called with a single parameter.

If it's a list with N elements, the procedure is called with N params.

If you want to call a procedure with a single param that's a list, send a list with a single element that's the list. It's the one weird case for this calling convention, and is illustrated with the third call, above.

Using JSON in place of XML

The XML-RPC standard specifies using XML, of course, but in this implementation, as an experiment, you can also use JSON.

When processing a request, we look at the first non-whitespace character. If it's a left curly brace, we treat it as JSON, not XML.

I haven't written a spec for the JSONified version, but I have created a cribsheet with examples that I used to guide the implementation.

Two types, <base64> and <dateTime.iso8601> are represented as strings. There is no way for the toolkit to know they are binary data or dates. This means that the XML and JSON versions are not exactly the same. Not sure what the implications of this will be. I wrote up the issue on Scripting News.

Please help test for interop

If you're running XML-RPC in your world, could you try testing against the server

I have running at betty.scripting.com. The server is accessible through port 80. The calls it handles are exactly the ones handled by the userland version of the test server. Demo code that calls the actual server is provided, in JavaScript.

The goal is to replace betty.userland.com with the one running here. But only after enough testing to be confident that it makes a good reference server.

If you have success, or find problems, please post a note in the issues section here. Thanks!

How to participate

I started a page at reboot.xmlrpc.com with links to new stuff related to this work.

Read Eric Kidd's fantastic XML-RPC HowTo.

Test your implementation on the XML-RPC Validator page.

The original site

The original site, dating back to 1998, is preserved.

Lest anyone forget

The first implementation of XML-RPC was in Frontier, in April 1998.

Questions, comments?

Post an issue here.