From 621c8a52124838ccaa78ecf80172b87f81366f43 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Tue, 14 May 2024 18:09:00 +0100 Subject: [PATCH] [Whitespace] Set soapversion before calling API 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. --- perllib/Integrations/Whitespace.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/perllib/Integrations/Whitespace.pm b/perllib/Integrations/Whitespace.pm index 59d92fad63c..430947ed1f0 100644 --- a/perllib/Integrations/Whitespace.pm +++ b/perllib/Integrations/Whitespace.pm @@ -63,12 +63,27 @@ sub call { my ($self, $method, @params) = @_; require SOAP::Lite; + + # 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); + @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);