SOAP::...esolver(3pm)

πŸ’– SOAP::WSDL::Generator::PrefixResolver πŸ’–

okay bestie, welcome to SOAP::...esolver β€” the perl-manpage vibe check you didn't know you needed. It's the User Contributed Perl Documentation entry for the class that hands out prefixes for different classes. sit down, grab a boba, let's get into it πŸ§‹βœ¨


✨ NAME ✨

SOAP::WSDL::Generator::PrefixResolver β€” prefixes for different classes. that's the whole name, she's serving exactly what it says on the tin πŸ’…


🌸 SYNOPSIS 🌸

so if you wanna make your own custom prefix resolver, like a lil bespoke one, you go:

package MyPrefixResolver;
use strict; use warnings;
use base qw(SOAP::WSDL::Generator::PrefixResolver);

sub resolve_prefix {
    my ($self, $type, $namespace, $node) = @_;
    # return something special
    return $self->SUPER::resolve_prefix($type, $namespace, $node);
}

and then when you're actually generating code, it's giving:

use MyPrefixResolver;
use SOAP::WSDL::Generator::XSD;
my $generator = SOAP::WSDL::Generator::Template::XSD->new({
   prefix_resolver_class => 'MyPrefixResolver',
});

see how the prefix_resolver_class is set to 'MyPrefixResolver'? that's you plugging your own girlboss logic into the machine. iconic ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

This is the prefix resolver class for SOAP::WSDL's code generator. You're absolutely allowed to subclass it so you can apply your own custom prefix resolving logic. do your thing, main character 🫢

Subclasses must implement the following methods (no skipping, bestie):

  • resolve_prefix
sub resolve_prefix {
   my ($self, $namespace, $node) = @_;
   # ...
}

resolve_prefix is expected to return a (perl class) prefix. It gets called with the following parameters:

  • type β€” one of (server|interface|typemap|type|element|attribute)
  • namespace β€” the targetNamespace of the node to generate a prefix for.
  • node β€” the node to generate a prefix for

lowkey, you usually just need type and namespace for prefix resolving. node is there for those rather funky setups where you have to pick different prefixes based on type names or whatever. nb, not judging, funky setups are valid πŸ’œ

node may be of any of the following classes:

  • SOAP::WSDL::Service
  • SOAP::WSDL::XSD::Attribute
  • SOAP::WSDL::XSD::Element
  • SOAP::WSDL::XSD::Type
⚠️ heads up bestie: both namespace and node may be undef β€” so please test for definedness before you do anything fancy with them. undefined behavior is not the vibe. 😭

If you want your prefixes to represent perl class hierarchies, they should end with '::'. periodt.

Example: ✨

Imagine you're generating interfaces for the Acme Pet Shop. Acme Corp. has set up their datatypes to be global across all interfaces (and products), while elements are local to the product (the Pet Shop in the example). All elements are in the urn:Acme namespace.

In addition, there are types in the namespace urn:Acme:Goods, which should go into the same namespace as types, but be prefixed with 'Goods_'.

You may want prefixes (roughly) like this:

Interfaces:        Acme::Client::PetShop::
Server:            Acme::Server::PetShop::
Types:             Acme::Types::
Types (Goods):     Acme::Types::Goods_
Elements:          Acme::Elements::PetShop::
Typemaps:          Acme::Typemaps::PetShop::

slay. that's the whole dream πŸŽ€


πŸ’€ BUGS AND LIMITATIONS πŸ’€

You cannot suffix your types by some rule yet... 😭 that's it, that's the limitation. we're waiting on it fr fr.


Copyright 2008 Martin Kutter.

This file is part of SOAP-WSDL. You may distribute/modify it under the same terms as perl itself. (perl itself said it's fine, so it's fine 🫢)


🌈 AUTHOR 🌈

Martin Kutter <martin.kutter fen-net.de> β€” shoutout to the author, king behavior fr 🫑


πŸ“ REPOSITORY INFORMATION πŸ“

$Rev: 583 $
$LastChangedBy: kutterma $
$Id: $
$HeadURL: $

and that's the whole page, bestie πŸ’– this was perl v5.36.0, dated 2022-10-14, and it's the SOAP::...esolver page from the User Contributed Perl Documentation collection. go forth and resolve those prefixes β€” no cap, you're gonna ate this up πŸŒŸπŸ’…

πŸ“¦ where this page comes from