第七十六章 方法关键字 - SoapAction
指定当通过HTTP将此方法作为web方法
调用时,要在HTTP
头中使用的SOAP
操作。仅适用于定义为web服务
或web客户端
的类。
用法
要指定将此方法用作web方法
时在HTTP头中使用的SOAP
操作,请使用以下语法:
Method name(formal_spec) As returnclass [ WebMethod, SoapAction = soapaction ]
{ //implementation }
其中soapaction
是下列之一:
“[default]”—SOAP
操作的默认值,即NAMESPACE/Package.Class.Method
"customValue"
-使用customValue
作为SOAP
操作。
该值应该是标识SOAP
请求意图的URI
。
如果指定了一个自定义的值,它必须在web服务
的每个web方法
中是唯一的,或者你必须为每个web方法
指定SoapRequestMessage
关键字(并且为该关键字使用唯一的值)。
- “” -使用空值作为
SOAP
操作。这种情况很少见。
详情
web方法
的SOAP
动作通常用于路由请求SOAP消息
。
例如,防火墙可以使用它来适当地过滤SOAP请求消息
。
InterSystems IRIS web服务
使用SOAP操作
(与消息本身结合)来确定如何处理请求消息。
该关键字允许指定在作为web方法
调用此方法时使用的HTTP SOAP
动作。
对于SOAP 1.1
, SOAP
动作包含在SOAPAction HTTP
报头中。
对于SOAP 1.2
,它包含在Content-Type
HTTP报头中。
默认
如果忽略SoapAction
关键字,SOAP
动作的形式如下:
NAMESPACE/Package.Class.Method
其中NAMESPACE
是web服务
的NAMESPACE
参数的值,Package.Class
是web服务
类的名称,Method
是web方法
的名称。
WSDL的关系
SoapAction
关键字影响web服务
的WSDL
中的<binding>
部分。
例如,以下web方法:
Method Add(a as %Numeric,b as %Numeric) As %Numeric [ SoapAction = MySoapAction,WebMethod ]
{
Quit a + b
}
对于这个web服务
,WSDL
的<binding>
部分如下所示:
<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>
默认情况下,如果方法没有指定SoapAction
关键字,<soap:operation>
元素可能会像下面这样:
<soap:operation soapAction="http://www.mynamespace.org/ROBJDemo.BasicWS.Add" style="document"/>
如果使用SOAP
向导从WSDL
生成 web服务
服务或客户端,将此关键字设置为适合于该WSDL
的关键字。
对消息的影响
对于前面显示的web方法
,web服务
期望收到以下形式的请求消息(对于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 >...
默认情况下,如果方法没有指定SoapAction
关键字,SoapAction
行可能会像下面这样:
SOAPAction: http://www.mynamespace.org/ROBJDemo.BasicWS.Add
注意,对于SOAP 1.2
,细节略有不同。
在这种情况下,web服务
期望收到如下形式的请求消息:
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 >...