Chapter 76 method Keyword - SoapAction

Posted by TreColl on Mon, 03 Jan 2022 18:28:54 +0100

Chapter 76 method Keyword - SoapAction

Specifies the SOAP operation to use in the HTTP header when this method is called as a web method over HTTP. Applies only to classes defined as web services or web clients.

usage

To specify the SOAP operation to use in the HTTP header when using this method as a web method, use the following syntax:

Method name(formal_spec) As returnclass [ WebMethod, SoapAction = soapaction ] 
{    //implementation }

soapaction is one of the following:

  • "[default] - the default value of SOAP operation, that is, namespace / package Class. Method
  • "customValue" - use customValue as the SOAP operation.
    The value should be a URI that identifies the intent of the SOAP request.

If a custom value is specified, it must be unique in each web method of the web service, or you must specify the SoapRequestMessage keyword for each web method (and use a unique value for the keyword).

  • "" "- use null value as SOAP operation.". This is rare.

details

Soap actions of web methods are usually used to route request SOAP messages.
For example, a firewall can use it to properly filter SOAP request messages.
The InterSystems IRIS web service uses SOAP operations (combined with the message itself) to determine how to process the request message.

This keyword allows you to specify the HTTP SOAP action to use when calling this method as a web method.
For SOAP 1.1, SOAP actions are included in the soap action HTTP header.
For SOAP 1.2, it is included in the content type HTTP header.

default

If the SoapAction keyword is ignored, the form of SOAP action is as follows:

NAMESPACE/Package.Class.Method

Where NAMESPACE is the value of the NAMESPACE parameter of the web service, package Class is the name of the web service class and Method is the name of the web Method.

WSDL relationships

The SoapAction keyword affects the < binding > part of the WSDL of a web service.
For example, the following web methods:

Method Add(a as %Numeric,b as %Numeric) As %Numeric [ SoapAction = MySoapAction,WebMethod ]
{
    Quit a + b
}

For this web service, the < binding > part of WSDL is as follows:

<binding name="MyServiceNameSoap" type="s0:MyServiceNameSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="Add">
        <soap:operation soapAction="MySoapAction" style="document"/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output>
            <soap:body use="literal"/>
        </output>
    </operation>
</binding>

By default, if the method does not specify the SoapAction keyword, the < soap: Operation > element may look like the following:

<soap:operation soapAction="http://www.mynamespace.org/ROBJDemo.BasicWS.Add" style="document"/>

If you use the SOAP wizard to generate a web service or client from a WSDL, set this keyword to a keyword appropriate for the WSDL.

Impact on messages

For the web method shown earlier, the web service expects to receive a request message in the following form (for SOAP 1.1):

POST /csp/gsop/ROBJDemo.BasicWS.cls HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; InterSystems IRIS;)
Host: localhost:8080
Connection: Close
Accept-Encoding: gzip
SOAPAction: MySoapAction
Content-Length: 379
Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope >...

By default, if the method does not specify the SoapAction keyword, the SoapAction line may look like the following:

SOAPAction: http://www.mynamespace.org/ROBJDemo.BasicWS.Add

Note that for SOAP 1.2, the details are slightly different.
In this case, the web service expects to receive a request message in the following form:

POST /csp/gsop/ROBJDemo.BasicWS.cls HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; InterSystems IRIS;)
Host: localhost:8080
Connection: Close
Accept-Encoding: gzip
Content-Length: 377
Content-Type: application/soap+xml; charset=UTF-8; action="MySoapAction"

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope >...

Topics: Cache iris