The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

xmlexer - exercises XML-RPC and SOAP servers interactively

SYNOPSIS

  xmlexer "http://www.oreillynet.com:80/meerkat/xml-rpc/server.php"
  xmlexer> meerkat.getCategoriesBySubstring('Data')
  $result = [ {
          'id' => '80',
          'title' => 'Data'
    }, ...

Completion works: in the example above, you just need to typ m(tab)Ca(tab)B(tab) to enter "meerkat.getCategoriesBySubstring".

DESCRIPTION

xmlexer provides an easy-to-use environment to exercise XML-RPC and SOAP applications. It offers extensive command-line completion, history, and even an expression parser and symbol table.

OPTIONS

xmlexer doesn't take any command-line options. It opens all URLs named on the command line.

COMMANDS

xmlexer supplies a number of commands to open a connection to a remote host and navigate its API. Usually hitting ^C will terminate the currently-running command and return you to the xmlexer prompt.

autoload

Toggles the autoload flag (defaults to on). If autoload is true, when a connection is opened, xmlexer attempts to load the entire API. However, on a bad server this can be time consuming and error-prone. Turning autoload off prevents the API from being loaded. You can still exercise the server using 'call'. Use the 'load' command to load the API after the connection has been opened.

See also: open, load

call URL FUNC [ARGS...]

Calls a connection manually. This is necessary if the remote server doesn't publish its API (i.e. provide working system.listMethods, system.methodSignature, and system.introspection calls).

  $ xmlexer
  xmlexer> open "http://time.xmlrpc.com/RPC2"
  Loaded 0 functions from http://time.xmlrpc.com/RPC2
  xmlexer> call "http://time.xmlrpc.com/RPC2" currentTime.getCurrentTime
  $result = '20040128T01:07:27';

See also: load, autoload

clear URL [METHODS...]

Clears all knowledge of the API for the connection specified. You can also pass the names of the specific methods that you would like to clear. If you don't specify any methods to clear, the entire API for this connection will be cleared.

Calling clear with no arguments and then load forces a connection's API to be entirely refreshed.

See also: list, load

close URL

Closes a connection. Pass it the URL of the connection you want to close. Use "open" to open a connection.

See also: open, connections

connections

Lists open connections. These aren't actually open sockets; it's just a data structure that stores API information for a particular remote host.

See also: open, close

delete VAR...

Removes one or more variables from the symbol table. To add variables, use the assignment operator. For instance,

  xmlexer> abc=2^8  
  $abc = 256;
  xmlexer> delete abc
  xmlexer> abc
  abc
  ^ unknown command or variable!

See also: vars, show

echo ARGS...

Simply echoes its command-line arguments. This is a good way of discovering if your input strings are accidentally being tokenized (i.e. you forgot to put quotes around a URL).

exit

Exits xmlexer immediately.

help [CMD]

Lists the commands and functions that you have at your disposal. If you supply the name of a command or function, it will print more detailed help on that command or function.

  xmlexer> help list
  list: List the methods in a connection
history [-c] [-d] NUM...

Lists the command history (similar to Bash). It also accepts some arguments:

-c

Clears all history.

-d NUM...

Deletes a specific item from history. You can pass more than one number to -d.

You can pass an integer specifying the maximum number of history items you to view. If you don't specify any arguments on the command line, every history item will be printed.

xmlexer performs history substitution just like bash: !! repeats the last command, !$ specifies the last argument, !!:s/SEARCH/REPLACE/ runs a substitution on the last command, ^search^repl performs a quick substitution, etc.

  xmlexer> !12
  open 'http://localhost:9000'

If you type a bang and then hit tab, you can even complete on the strings in history. Try it and you'll see what I mean. Unfortunately, due to a ReadLine bug, if you start completing a line from history, when completing on command history, you must finish the entire command -- you can't just hit return when the string is unique.

list CONN

If you pass it the URL of an open connection, the methods that the connection supplies will be listed.

See also: load, clear

load CONN [methods...]

Loads the API for the specified connection. You will need this call if either the API didn't load completely the first time (keep calling load until you get everything), or you called the clear command, or autoload is turned off.

You can specify the names of the methods that you would like to be loaded. If you don't specify any methods, load will use system.listMethods to determine what methods to load. If the server is set up correctly, this will load all methods from the server's API.

See also: open, list, clear, autoload

open URL

Opens a new connection. "Open" is a bit of a misnomer -- this call does not actually open any sort of persistent socket. Rather, it connects to the remote server and reads as much information as it can about the API (unless autoload is off). It uses this information to assist in command-line completion and expression writing. To cause xmlexer to forget about a connection, call "close".

You need to surround the argument to open in quotes. Otherwise, xmlexer will think that you're doing a lot of syntactically invalid division (http://ab/c...).

See also: close, load

show VAR...

Shows the value of one or more variables. Because variables return their result when they're named on the command line, there's no real need for the show command anymore.

  xmlexer> abc=123
  $abc = '123';
  xmlexer> show abc
  $abc = '123';
  xmlexer> abc
  $result = '123';

See also: vars, delete

vars

Lists all the variables defined in the symbol table.

See also: show, delete

verbose NUM

Raises or lowers the amount of text printed by xmlexer. Set it to -1 to get xmlexer to print virtually nothing. Set it to 10 to see the nitty gritty details of everything xmlexer is doing. The default verbosity is 1.

  xmlexer> verbose 4

Primarily affects: load, open, call

debug_complete NUM

This turns on command-line completion debugging. If you set this to 3 or higher, you will see a lot of information about the completion process printed every time you stomp on tab.

EXPRESSIONS

xmlexer actually has two parsers in it: the shell-like one provided by Term::GDBUI and its own internal expression parser. Use shell-like expressions when working with xmlexer, and expressions when working with remote servers.

  xmlexer> verbose -1            # shell-like, command with args
  xmlexer> system.identity()
  $result = 'RPC::XML::Server/1.37';

Because the two types of expressions are totally distinct, you cannot mix them. The following doesn't work, for instance, because it is mixing commands and expressions into the same statement.

  xmlexer> verbose 1+3         # WRONG

To call a function, just follow its name with a set of parentheses containing optional arguments. The function will not be called if you forget to specify the parens.

If you do not supply a variable to store the result of an expression, xmlexer will store the result in the variable named "result".

  xmlexer> 9
  $result = '9';
  xmlexer> x=6
  $x = '6';
  xmlexer> show result
  $result = '9';

Operators

xmlexer can perform some rudimentary arithmetic operations. Here is the precedence table of the arithmetic operators, from highest to lowest.

  ^         exponentiation    (tightest binding)
  * /       multiplication, divison
  + -       addition, subtraction
  =         assignment        (weakest binding)

You can mix arithmetic and method calls interchangably in the same expression.

  xmlexer> 3^3-Test.add(2^3,4)
  $result = 15;

EXAMPLES

The synopsis at the start of this document exercises the Meerkat API at http://www.oreillynet.com/pub/a/rss/2000/11/14/meerkat_xmlrpc.html.

Remember that as long as xmlexer can load the method signatures it will autocomplete for you. Just bounce on tab -- usually you'll be pleased by the results.

Sometimes a server won't publish its method signatures. In this case, you need to use xmlexer's call routine manually (see its documentation in COMMANDS for an example).

TROUBLESHOOTING

If anything goes wrong, the first thing you should do is bump up the verbosity and try again. Usually this will give you a good idea of just what's going on.

If you get parse errors, hit the up arrow to see how xmlexer is tokenizing your expression. It spaces the tokens its own way so you can see, for instance, what happens if you forget to put quotes around a URL.

BUGS

You can't concatenate strings. This is just pure laziness until someone asks for it. I suppose I'd overload the + operator as I really, really don't want to turn '.' into a tokenchar.

expressions and commands don't get along (see more under EXPRESSIONS). This is because Term::ExprUI is incomplete. The best solution to this problem is probably just to ditch commands entirely and turn everything into an expression.

^C interrupts are a little odd. At the command line, they don't fire until you hit return. This appears to be a bug with Term::ReadLine::Gnu. The signals just pile up until the readline call returns. I haven't found any way of fixing it. Also, it appears that some libraries disable SIG{INT} while they're doing network operations. If you just hold down ^C, eventually they'll notice and return early.

AUTHOR

Scott Bronson <bronson@rinspin.com>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 716:

You forgot a '=back' before '=head1'