I tried to use the guide on http://cookbook.soaplite.com/#changing%20method%20name%20in%20response , but it doesn't seem to work, I guess it's not applicable on what I'm doing.
The code you posted doesn't show any code from the guide, or a client.
It works for me, goes from
<product_info_requestResponse xmlns="http://127.0.0.1/MyModule" xsi:ni
+l="true"/>
to
<product_info_request xmlns="http://127.0.0.1/MyModule">
#!/usr/bin/perl --
#~ 2011-08-24-07:25:06PDT by Anonymous Monk
#~ perltidy -csc -otr -opr -ce -nibc -i=4
use strict;
use warnings;
use Proc::Background;
Main( @ARGV );
exit( 0 );
sub Main {
my( $cos ) = @_;
if( $cos ){
GoServer() if $cos == 1;
GoClient() if $cos == 2;
} else {
GoGo();
}
}
sub GoGo {
my $serv = Proc::Background->new( $^X, __FILE__, 1 => 'GoServer' )
+;
sleep 1;
my $cli = Proc::Background->new( $^X, __FILE__, 2 => qw'Go Client'
+ );
sleep 1;
$cli->die;
$serv->die;
}
sub GoServer {
require MyModule;
require SOAP::Lite;
require SOAP::Transport::HTTP;
my $daemon = SOAP::Transport::HTTP::Daemon->new(
LocalAddr => '127.0.0.1',
LocalPort => 1203,
Reuse => 1
)
#~ ->serializer( MySerializer->new ) # WORKS
->dispatch_to('MyModule');
print "SOAP server started at ", $daemon->url, "\n";
$daemon->handle;
}
sub GoClient {
require SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://127.0.0.1/MyModule')
-> proxy('http://127.0.0.1:1203');
$soap->transport->add_handler("request_send", \&pp_dump );
$soap->transport->add_handler("response_done", \&pp_dump );
$soap->product_info_request("one","two","three");
}
sub pp {
use XML::Twig;
open my($fh), '>', \my $str;
no warnings 'newline';
XML::Twig->new(qw! pretty_print record !)->xparse(@_)->print( $fh
+);
return $str;
}
sub pp_dump {
my $content = $_[0]->content('');
$_[0]->content( pp($content) );
print $_[0]->as_string,"\n";
return;
}
BEGIN {
package MyModule;
use strict;
sub product_info_request
{
my ($self,@args) = @_;
return (SOAP::Header->name(prod_no => $args[1])->type('string'
+));
}
BEGIN { $INC{'MyModule.pm'} = __FILE__; }
1;
}
BEGIN {
package MySerializer;
@MySerializer::ISA = 'SOAP::Serializer';
sub envelope {
$_[2] =~ s/Response$// if $_[1] =~ /^(?:method|response)$/;
shift->SUPER::envelope(@_);
}
BEGIN { $INC{'MySerializer.pm'} = __FILE__; }
1;
}
__END__
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.