As I understand it, you need to write your own serializer to do this; I wound up doing this:
MySerializer.pm:
CPAN::Forum
SOAP-WSDL - Re: SOAP::WSDL noob question about namespace prefixing
| Posted on Tue Apr 29 13:35:16 2008 by noah in response to 7786 (See the whole thread of 3) |
| 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 |
(0)
]