다음을 통해 공유


SoapRpcMethodAttribute.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

속성 값

SOAPAction SOAP 요청의 HTTP 헤더 필드입니다. 기본값은 http://tempuri.org/MethodName MethodName이 XML 웹 서비스 메서드의 이름입니다.

예제

다음 코드 예제에서는 속성을 .로 http://www.contoso.com/Sample설정합니다Action.

<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class MyUser : WebService {
 
       [ SoapRpcMethod(Action="http://www.contoso.com/Sample", 
           RequestNamespace="http://www.contoso.com/Request",
           RequestElementName="GetUserNameRequest",
           ResponseNamespace="http://www.contoso.com/Response",
           ResponseElementName="GetUserNameResponse")]
      [ WebMethod(Description="Obtains the User Name") ]
      public UserName GetUserName() {
           string temp;
           int pos;
           UserName NewUser = new UserName();
           
           // Get the full user name, including the domain name if applicable.
           temp = User.Identity.Name;
 
           // Determine whether the user is part of a domain by searching for a backslash.
           pos = temp.IndexOf("\\");
           
           // Parse the domain name out of the string, if one exists.
           if (pos <= 0)
                 NewUser.Name = User.Identity.Name;
           else {
               NewUser.Name = temp.Remove(0,pos+1);
                 NewUser.Domain = temp.Remove(pos,temp.Length-pos);
           } 
       return NewUser;
      }
 
 }   
 
 public class UserName {
 
     public string Name;
     public string Domain;
 }
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MyUser
    Inherits WebService    
    
    <SoapRpcMethod(Action := "http://www.contoso.com/Sample", _
    RequestNamespace := "http://www.contoso.com/Request", _
    RequestElementName := "GetUserNameRequest", _
    ResponseNamespace := "http://www.contoso.com/Response", _
    ResponseElementName := "GetUserNameResponse"), _
    WebMethod(Description := "Obtains the User Name")> _
    Public Function _
        GetUserName() As UserName
        
        Dim temp As String
        Dim pos As Integer
        Dim NewUser As New UserName()
        
        ' Get the full user name, including the domain name if applicable.
        temp = User.Identity.Name
        
        ' Determine whether the user is part of a domain by searching for a backslash.
        pos = temp.IndexOf("\")
        
        ' Parse the domain name out of the string, if one exists.
        If pos <= 0 Then
            NewUser.Name = User.Identity.Name
        Else
            NewUser.Name = temp.Remove(0, pos + 1)
            NewUser.Domain = temp.Remove(pos, temp.Length - pos)
        End If
        Return NewUser
    End Function
End Class 

Public Class UserName
    
    Public Name As String
    Public Domain As String
End Class

설명

일반적으로 Action 이 속성은 SOAP 요청의 의도를 나타내는 URI입니다. 그러나 SOAP 사양은 형식 및 URI가 기존 문서를 참조하는지 여부에 제한을 두지 않습니다. 속성의 현재 상태 및 콘텐츠는 HTTP에서 Action SOAP 요청 메시지를 적절하게 필터링하기 위해 방화벽과 같은 웹 서버에서 사용할 수 있습니다.

기본적으로 .NET Framework 버전 1.1은 XML 웹 서비스에 대해 생성된 WSDL 문서에서 지원되는 각 SOAP 바인딩에 대한 요소의 특성 soap:operation 에 속성을 soapAction 게시 Action 합니다. 지원되는 SOAP 바인딩은 SOAP 1.1입니다.

자세한 내용은 W3C 웹 사이트의 SOAP 사양을 참조하세요.

적용 대상