TheNode has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm new to SOAP::Lite.

I have to write SOAP client for third party software. It seems pretty straightforward, but there's one obstacle. There is a hyphen in method name I want to invoke.

I've copied wsdl to local filesystem and modified method name there - of course it returns an error - but the syntax is ok. Output works when sending it through SoapUI when I change the method name back.

Method name: bpi-request

When trying to run my script I got an error:
Bad stub: Bareword "bpi" not allowed while "strict subs" in use at (ev +al 92) line 6. at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 2921.
It seems that SOAP:Lite have problem with hyphens in wsdl files. Is there a way to modify xml before sending? Then I could change 'bpi-request' in wsdl to 'bpirequest' and then before sending change all 'bpirequest' to 'bpi-request'.

Regards,

TheNode

Replies are listed 'Best First'.
Re: SOAP::Lite - a hyphen in method name
by Corion (Patriarch) on Aug 27, 2015 at 13:13 UTC

    Maybe you can show us the actual code you're using? Most likely, you can fake the "hyphen-in-a-method name" by using something like:

    my $method_name = 'bpi-request'; $soap->$method_name( 'foo', 'bar', 'baz' );

    Also worth investigating would be $session->call( $method_name, ...), which also allows you to call functions that Perl would consider having illegal names in SOAP::Lite.

      I've already tried that. The hyphen exists in wsdl file what makes problem for Lite.pm module. If I remove hyphen from wsdl and perl script then request is sent. But to get proper response I have to have that hypen in XML request.

        The problematic code is in ->generate_stub (metacpan link). I would print out what ->generate_stub creates and then patch the code in ->generate_stub appropriately to generate a sane/sanitized code. Most likely you can fake things by munging the parameter generate_stub gets.