ffrost has asked for the wisdom of the Perl Monks concerning the following question:

I have code where I've supplied a snippet of the relevant parts below:

$soap = SOAP::Lite ->proxy($proxy) ->uri($uri) ->autotype(0) ->ns('http://www.w3.org/2003/05/soap-envelope','soap') ->ns('http://mil.dod.af.A1.personnel.dataservices.filter','mil') ->ns('http://mil.dod.af.A1.personnel.dataservices.training/v2.4','v2') ->readable(1);

This creates the following output:

<soap:Envelope soap:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/ xmlns:mil=http://mil.dod.af.A1.personnel.dataservices.filter xmlns:soap=http://www.w3.org/2003/05/soap-envelope xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:v2=http://mil.dod.af.A1.personnel.dataservices.training/v2.4 xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>

But I need it to look like this, without the magically included namespaces:

<soap:Envelope xmlns:mil=http://mil.dod.af.A1.personnel.dataservices.filter xmlns:v2=http://mil.dod.af.A1.personnel.dataservices.training/v2.4 xmlns:soap=http://www.w3.org/2003/05/soap-envelope>

How do I get rid of the soap:encodingStyle, xmlns:soapenc, xmlns:xsd and xmlns:xsi namespaces? If I use these extra namespaces in the web service call then it fails their validation check.

Replies are listed 'Best First'.
Re: SOAP::Lite - how to remove namespaces
by ForgotPasswordAgain (Vicar) on Dec 06, 2023 at 17:59 UTC

    (I haven't used SOAP::Lite for a long time, so just guessing.)

    Looking at lib/SOAP/Lite.pm, it seems that stuff is probably done by new using register_ns. Offhand I don't see a clean way to "unregister" a namespace, but the way register_ns is implemented -- if you just want to get on with life and don't mind dirty hacks -- it looks like you could do something like (untested) delete $soap->{_namespaces}{soapenc} for example to remove soapenc.