Subject: | Compatibility to M$ web services retrieved by wsdl |
Date: | Fri, 06 Sep 2013 00:09:48 +0200 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Herwig Burgert <herwig.burgert [...] hhjb.it> |
Hallo SOAP::Lite developers,
to satisfy the M$ web service recommendation (you described this in conjunction
with the default_ns directive),
an adequate method is needed when service definition is retrieved via wsdl.
I've done following changes to satisfy M$ but this should be done maybe by
parameter-passing to the service directive
or by setting a flag to do so:
...
package SOAP::Schema;
...
sub _call {
my ($self, $method) = (shift, shift);
my $name = UNIVERSAL::isa($method => 'SOAP::Data') ? $method->name : $method;
my %method = %{$methods{$name}};
$self->proxy($method{endpoint} || Carp::croak "No server address (proxy)
specified")
unless $self->proxy;
my @templates = @{$method{parameters}};
my @parameters = ();
foreach my $param (@_) {
if (@templates) {
my $template = shift @templates;
my ($prefix,$typename) = SOAP::Utils::splitqname($template->type);
my $method = 'as_'.$typename;
# TODO - if can('as_'.$typename) {...}
my $result = $self->serializer->$method($param, $template->name,
$template->type, $template->attr);
push(@parameters, $template->value($result->[2]));
}
else {
push(@parameters, $param);
}
}
### BEGIN HHJB ###
# $self->endpoint($method{endpoint})
# ->ns($method{namespace})
# ->on_action(sub{qq!"$method{soapaction}"!});
$self->endpoint($method{endpoint})
->default_ns($method{namespace})
->on_action(sub{qq!"$method{soapaction}"!});
#### END HHJB ####
EOP
### BEGIN HHJB ###
# my $namespaces = $self->deserializer->ids->[1];
# foreach my $key (keys %{$namespaces}) {
# my ($ns,$prefix) = SOAP::Utils::splitqname($key);
# $self->{'_stub'} .= '
$self->serializer->register_ns("'.$namespaces->{$key}.'","'.$prefix.'");'."\n"
# if ($ns eq "xmlns");
# }
#### END HHJB ####
$self->{'_stub'} .= <<'EOP';
my $som = $self->SUPER::call($method => @parameters);
if ($self->want_som) {
return $som;
}
UNIVERSAL::isa($som => 'SOAP::SOM') ? wantarray ? $som->paramsall :
$som->result : $som;
}
These changes have been necessary to produce working SOAP like this:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Read xmlns="urn:microsoft-dynamics-schemas/page/customer">
<No xsi:type="xsd:string">700200</No>
</Read>
</soap:Body>
</soap:Envelope>
instead of this not working with M$:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:microsoft-dynamics-schemas/page/customer"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<tns:Read>
<No xsi:type="xsd:string">700200</No>
</tns:Read>
</soap:Body>
</soap:Envelope>
Kind regards
Herwig Burgert