This section provides a tutorial example showing the Unsupported Media Type 'application/soap' error, when using SOAP::Lite with soapversion('1.2').
Based on the result of my last tutorial, I think I am ready to try my SOAP 1.2 client
application with the real server at xmlme.com:
#- GetSpeech_SOAP_1_2_Test.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')
->default_ns('http://xmlme.com/WebServices')
->on_action( sub {join '/', @_} )
->readable(true)
->proxy('http://www.xmlme.com/WSShakespeare.asmx');
my $som = $client->call('GetSpeech',
SOAP::Data->name("Request")
->value("To be, or not to be")
);
Result of GetSpeech_SOAP_1_2_Test.pl:
POST http://www.xmlme.com/WSShakespeare.asmx HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 606
Content-Type: application/soap; charset=utf-8
SOAPAction: http://xmlme.com/WebServices/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 xmlns="http://xmlme.com/WebServices">
<Request xsi:type="xsd:string">To be, or not to be</Request>
</GetSpeech>
</soap12:Body>
</soap12:Envelope>
...
HTTP/1.1 415 Unsupported Media Type
Cache-Control: private
Connection: close
...
The result is disappointing, but somewhat expected.
I kind of ignored the issue at the Content-Type header line.
SOAP 1.2 requires to use the "application/soap+xml" media type,
not "application/soap".