I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-04-29 10:35:16-07 by noah in response to 7786
Re: SOAP::WSDL noob question about namespace prefixing

As I understand it, you need to write your own serializer to do this; I wound up doing this:

MySerializer.pm:

package MySerializer; use strict; use warnings; use SOAP::WSDL::Serializer::XSD; use base 'SOAP::WSDL::Serializer::XSD'; sub serialize { my ($self, $args_of_ref) = @_; my $xml = $self->SUPER::serialize($args_of_ref); # # insert the xmlns:ns2 namespace definition $xml =~ s#>#xmlns:ns2=\"http://services.example.com/\">#; return $xml; } sub serialize_body { my ($self, $name, $data, $opt) = @_; # # set the namespace prefix $data->__set_name("ns2:$name"); # # ensure that the namespace isn't set as part of the API call no warnings 'redefine'; *MyElements::getElementId::get_xmlns = sub { '' }; return $self->SUPER::serialize_body($name, $data, $opt); } 1;

get_element_id.pl:

#!/usr/bin/perl use strict; use warnings; use MyInterfaces::MyService::MyServicePort; use MySerializer; my $svc = MyInterfaces::MyService::MyServicePort->new(); $svc->set_serializer('MySerializer'); my $res = $svc->getElementId(); die $res->get_faultstring unless $res; print $res;
This may or may not be the Right Way(tm) to do this, but it works for me. Hope this helps.
Direct Responses: 7797 | Write a response