SoapDocumentMethodAttribute.Action 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 SOAPAction SOAP 请求的 HTTP 标头字段。
public:
property System::String ^ Action { System::String ^ get(); void set(System::String ^ value); };
public string Action { get; set; }
member this.Action : string with get, set
Public Property Action As String
属性值
SOAPAction SOAP 请求的 HTTP 标头字段。 默认值为 http://tempuri.org/MethodNameMethodName 是 XML Web 服务方法的名称。
示例
下面的代码示例将 Action 属性设置为 http://www.contoso.com/GetUserName.
<%@ WebService Language="C#" class="MyUser" %>
using System.Web.Services;
using System.Web.Services.Protocols;
public class MyUser : WebService {
[ SoapDocumentMethod(Action="http://www.contoso.com/GetUserName")]
public string GetUserName() {
return User.Identity.Name;
}
}
<%@ WebService Language="VB" class="MyUser" %>
Imports System.Web.Services
Imports System.Web.Services.Protocols
Public Class MyUser
Inherits WebService
<SoapDocumentMethod(Action := "http://www.contoso.com/GetUserName")> _
Public Function _
GetUserName() As String
Return User.Identity.Name
End Function
End Class
注解
通常,该 Action 属性是一个 URI,指示请求的意图。 但是,SOAP 规范对 URI 格式没有限制,也不对 URI 是否可解析的任何规则进行限制。 Web 服务器(如防火墙)可以使用属性的存在和内容 Action 来适当地筛选 HTTP 中的 SOAP 请求消息。
默认情况下,.NET Framework 版本 1.1 会在为 XML Web 服务生成的 WSDL 文档中每个受支持的 SOAP 绑定的soap:operation元素属性中发布Action该属性soapAction。 有关详细信息,请参阅 W3C 网站上的 SOAP 规范。