This section provides a tutorial example on how to set the Envelope element under a named namespace of 'http://www.w3.org/2003/05/soap-envelope' - Using soapversion('1.2') and envprefix('soap12') together!
The first issue is to set the Envelope element under a named namespace of "http://www.w3.org/2003/05/soap-envelope".
I did 3 tests before finding the solution:
1. Using soapversion('1.1') only.
#- GetSpeech_localhost_v11.pl
#- Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
#- All rights reserved
#
use SOAP::Lite +trace;
my $client = SOAP::Lite->new()
->soapversion('1.1')
->readable(true)
->proxy('http://localhost/WSShakespeare.asmx');
my $som = $client->call('GetSpeech', "To be, or not to be");
Result of GetSpeech_localhost_v11.pl:
POST http://localhost/WSShakespeare.asmx HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 505
Content-Type: text/xml; charset=utf-8
SOAPAction: "#GetSpeech"
<?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>
<GetSpeech>
<c-gensym3 xsi:type="xsd:string">To be, or not to be</c-gensym3>
</GetSpeech>
</soap:Body>
</soap:Envelope>
2. Using soapversion('1.2') only.
#- GetSpeech_localhost_v12.pl
#- Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
#- All rights reserved
#
use SOAP::Lite +trace;
my $client = SOAP::Lite->new()
->soapversion('1.2')
->readable(true)
->proxy('http://localhost/WSShakespeare.asmx');
my $som = $client->call('GetSpeech', "To be, or not to be");
Result of GetSpeech_localhost_v12.pl:
POST http://localhost/WSShakespeare.asmx HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 485
Content-Type: application/soap; charset=utf-8
SOAPAction: "#GetSpeech"
<?xml version="1.0" encoding="UTF-8"?>
<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/">
<Body>
<GetSpeech>
<c-gensym3 xsi:type="xsd:string">To be, or not to be</c-gensym3>
</GetSpeech>
</Body>
</Envelope>
3. Using soapversion('1.2') and envprefix('soap12').
#- GetSpeech_localhost_v12_envprevix.pl
#- Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
#- All rights reserved
#
use SOAP::Lite +trace;
my $client = SOAP::Lite->new()
->soapversion('1.2')
->envprefix('soap12')
->readable(true)
->proxy('http://localhost/WSShakespeare.asmx');
my $som = $client->call('GetSpeech', "To be, or not to be");
Result of GetSpeech_localhost_v12_envprevix.pl:
POST http://localhost/WSShakespeare.asmx HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 573
Content-Type: application/soap; charset=utf-8
SOAPAction: "#GetSpeech"
<?xml version="1.0" encoding="UTF-8"?>
<soap12:Envelope
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap12:Body>
<GetSpeech>
<c-gensym3 xsi:type="xsd:string">To be, or not to be</c-gensym3>
</GetSpeech>
</soap12:Body>
</soap12:Envelope>
What your conclusion based on these tests? Here is what I think:
If you use soapversion('1.1') only, SOAP::Lite generates Envelope under the named namespace of
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/". This is correct for a SOAP 1.1 request.
If you use soapversion('1.2') only, SOAP::Lite generates Envelope under no namespace at all.
This is incorrect for SOAP 1.2.
If you use soapversion('1.2') and envprefix('soap12') together, SOAP::Lite generates Envelope under
the named namespace of xmlns:soap12="http://www.w3.org/2003/05/soap-envelope".
This is correct for SOAP 1.2.
So if you want to do SOAP 1.2, remember to use soapversion('1.2') and envprefix('soap12') together!