Share via


SoapDocumentMethodAttribute.Action 屬性

定義

取得或設定 SOAP 要求的 SOAPAction 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

屬性值

String

SOAP 要求的 SOAPAction HTTP 標頭欄位。 預設值為 http://tempuri.org/MethodName ,其中 MethodName 是 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 規格。

適用於