Skip to content

Commit

Permalink
[Whitespace] Set soapversion before calling API
Browse files Browse the repository at this point in the history
SOAP::Lite has some global constants which determine the version of SOAP
to use, if these are set to the wrong version it can cause 400 Bad
Request errors when calling the Whitespace API.
  • Loading branch information
chrismytton committed May 14, 2024
1 parent 3bd3565 commit 6728eee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions perllib/Integrations/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,27 @@ has backend_type => ( is => 'ro', default => 'whitespace' );
sub call {
my ($self, $method, @params) = @_;

# SOAP::Lite uses some global constants to set e.g. the request's
# Content-Type header and various envelope XML attributes. On new() it sets
# up those XML attributes, and even if you call soapversion on the object's
# serializer after, it does nothing if the global version matches the
# object's current version (which it will!), and then uses those same
# constants anyway. So we have to set the version globally before creating
# the object (during the call to self->endpoint), and also during the
# call() (because it uses the constants at that point to set the
# Content-Type header), and then set it back after so it doesn't break
# other users of SOAP::Lite.
SOAP::Lite->soapversion(1.1);

require SOAP::Lite;
@params = make_soap_structure(@params);
my $som = $self->endpoint->call(
$method => @params,
$self->security
);

SOAP::Lite->soapversion(1.2);

# TODO: Better error handling
die $som->faultstring if ($som->fault);

Expand Down

0 comments on commit 6728eee

Please sign in to comment.