Frontier::RPC2(3)

🌸 NAME 🌸

okay so this is the Frontier::RPC2(3) manual β€” yes, from User Contributed Perl Documentation, bestie. The NAME line is literally: Frontier::RPC2 β€” encode/decode RPC2 format XML. It's giving XML RPC encoder/decoder main character energy, and we're obsessed. ngl, it ate. πŸ’–

🌈 SYNOPSIS 🌈

Here's the whole vibe in code form β€” use these exactly, bestie:

        use Frontier::RPC2;

        $coder = Frontier::RPC2->new;

        $xml_string = $coder->encode_call($method, @args);
        $xml_string = $coder->encode_response($result);
        $xml_string = $coder->encode_fault($code, $message);

        $call = $coder->decode($xml_string);

        $response_xml = $coder->serve($request_xml, $methods);

        $boolean_object = $coder->boolean($boolean);
        $date_time_object = $coder->date_time($date_time);
        $base64_object = $coder->base64($base64);
        $int_object = $coder->int(42);
        $float_object = $coder->float(3.14159);
        $string_object = $coder->string("Foo");

πŸ’… DESCRIPTION πŸ’…

okay so Frontier::RPC2 encodes and decodes XML RPC calls. That's the whole assignment. It's giving translator-for-XML-RPC-calls realness ✨. Vibe check: passed.

πŸŽ€ $coder = Frontier::RPC2->new( OPTIONS ) πŸŽ€

Create a new encoder/decoder, bestie. Here's the supported option tea:

encoding

This is the XML encoding that gets specified in the XML declaration of encoded RPC requests or responses. Decoded results may have a different encoding specified; XML::Parser will convert decoded data to UTF-8. The default encoding is none, which uses XML 1.0's default of UTF-8. For example:

 $server = Frontier::RPC2->new( 'encoding' => 'ISO-8859-1' );

use_objects

If set to a non-zero value, it will convert incoming <i4>, <float>, and <string> values to objects instead of scalars. See int(), float(), and string() below for more details. iykyk πŸ‘€

πŸ¦‹ $xml_string = $coder->encode_call($method, @args) πŸ¦‹

encode_call converts a method name and its arguments into an RPC2 methodCall element, returning the XML fragment. Slay. πŸ’…

πŸ¦‹ $xml_string = $coder->encode_response($result) πŸ¦‹

encode_response converts the return value of a procedure into an RPC2 methodResponse element containing the result, returning the XML fragment.

πŸ¦‹ $xml_string = $coder->encode_fault($code, $message) πŸ¦‹

encode_fault converts a fault code and message into an RPC2 methodResponse element containing a fault element, returning the XML fragment.

πŸ¦‹ $call = $coder->decode($xml_string) πŸ¦‹

decode converts an XML string containing an RPC2 methodCall or methodResponse element into a hash containing three members: type, value, and method_name. type is one of call, response, or fault. value is an array containing the parameters or result of the RPC. For a call type, value contains the call's parameters and method_name contains the method being called. For a response type, the value array contains the call's result. For a fault type, the value array contains a hash with the two members faultCode and faultMessage. No cap, that's the whole decode situation. 🫢

πŸ¦‹ $response_xml = $coder->serve($request_xml, $methods) πŸ¦‹

serve decodes $request_xml, looks up the called method name in the $methods hash and calls it, and then encodes and returns the response as XML. It's giving server bestie behavior. πŸ‘‘

πŸ“ boolean, date_time, and base64 objects πŸ“

$boolean_object = $coder->boolean($boolean);
$date_time_object = $coder->date_time($date_time);
$base64_object = $coder->base64($base64);

These methods create and return XML-RPC-specific datatypes that can be passed to the encoder. The decoder may also return these datatypes β€” lowkey convenient. The corresponding package names (for use with ref(), for example) are Frontier::RPC2::Boolean, Frontier::RPC2::DateTime::ISO8601, and Frontier::RPC2::Base64.

You can change and retrieve the value of boolean, date/time, and base64 data using the value method of those objects, i.e.:

             $boolean = $boolean_object->value;

             $boolean_object->value(1);

Note: base64() does not encode or decode base64 data for you, you must use MIME::Base64 or similar module for that. Not me reminding you to bring your own base64 module. πŸ™ˆ

🧚 int, float, and string objects 🧚

$int_object = $coder->int(42);
$float_object = $coder->float(3.14159);
$string_object = $coder->string("Foo");

By default, you may pass ordinary Perl values (scalars) to be encoded. RPC2 automatically converts them to XML-RPC types if they look like an integer, float, or as a string. This assumption causes problems when you want to pass a string that looks like "0096", RPC2 will convert that to an <i4> because it looks like an integer. With these methods, you could now create a string object like this:

             $part_num = $coder->string("0096");

and be confident that it will be passed as an XML-RPC string. You can change and retrieve values from objects using value() as described above. Literally iconic. 🌈

πŸ‘‘ SEE ALSO πŸ‘‘

the usual suspects, bestie: perl(1), Frontier::Daemon(3), Frontier::Client(3)

<http://www.scripting.com/frontier5/xml/code/rpc.html>

πŸ¦‹ AUTHOR πŸ¦‹

Ken MacLeod <ken@bitsko.slc.ut.us> β€” iconic author behavior, fr fr. πŸ’œ


πŸ’– ok bye bestie β€” this page is from perl v5.32.1, dated 2023-10-24, and it's the Frontier::RPC2(3) manual. periodt. 🫢

πŸ“¦ where this page comes from