次の方法で共有


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

プロパティ値

SOAP 要求の SOAPAction HTTP ヘッダー フィールド。 既定値は http://tempuri.org/MethodName です。MethodName は XML Web サービス メソッドの名前です。

次のコード例では、 Action プロパティを http://www.contoso.com/Sample に設定します。

<%@ 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 が既存のドキュメントを参照しているかどうかに制限はありません。 Action プロパティの存在とコンテンツは、ファイアウォールなどの Web サーバーが HTTP で SOAP 要求メッセージを適切にフィルター処理するために使用できます。

既定では、.NET Framework バージョン 1.1 は、XML Web サービス用に生成された WSDL ドキュメントでサポートされている各 SOAP バインドについて、soap:operation要素のsoapAction属性のAction プロパティを発行します。 サポートされている SOAP バインディングは SOAP 1.1 です。

詳細については、W3C Web サイトの SOAP 仕様を参照してください。

適用対象