This section describes why the SOAPAction header line is not needed in SOAP 1.2 - SOAPAction is replaced by the 'action' parameter of the application/soap-xml media type in SOAP 1.2.
According to RFC 3902 - 'The "application/soap+xml" media type',
the SOAPAction HTTP header field in SOAP 1.1 has been replaced by
the "action" parameter of the media type:
MIME media type name: application
MIME subtype name: soap+xml
Required parameters: none
Optional parameters:
"charset": This parameter has identical semantics to the charset
parameter of the "application/xml" media type as specified in
RFC 3023 [RFC3023].
"action": This optional parameter can be used to specify the URI
that identifies the intent of the message. In SOAP 1.2, it
serves a similar purpose as the SOAPAction HTTP header field
did in SOAP 1.1. Namely, its value identifies the intent of
the message.
...
So how to remove SOAPAction HTTP header with using SOAP::Lite?
I did some research on the Internet, and found no suggestions.
So I decided to leave it there. But it needs to be modified
to make the .NET Web services server happy. Because they require
a format of "$uri/$method", not "$uri#$method".
The solution is easy as we learned from previous SOAP 1.1 tutorials.
The on_action() function can be used to provide a call back function
to control the value of SOAPAction:
#- GetSpeech_localhost_SOAPAction.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://localhost/WSShakespeare.asmx');
my $som = $client->call('GetSpeech',
SOAP::Data->name("Request")
->value("To be, or not to be")
);
Result of GetSpeech_localhost_SOAPAction.pl:
POST http://localhost/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>
I think my entire GetSpeech SOAP 1.2 request is ready now. What do you think?