SoapRpcMethodAttribute.Action プロパティ
SOAP 要求の SOAPAction HTTP ヘッダー フィールドを取得または設定します。
Public Property Action As String
[C#]
public string Action {get; set;}
[C++]
public: __property String* get_Action();public: __property void set_Action(String*);
[JScript]
public function get Action() : String;public function set Action(String);
プロパティ値
SOAP 要求の SOAPAction HTTP ヘッダー フィールド。既定値は http://tempuri.org/MethodName です。MethodName は XML Web サービス メソッドの名前です。
解説
通常、 Action プロパティは、SOAP 要求の意図を示す URI です。ただし、SOAP 仕様では、URI の書式や、URI が既存のドキュメントを参照するかどうかについての制限は規定されていません Action プロパティの存在と内容は、ファイアウォールなどの Web サーバーによって、HTTP 上の SOAP 要求メッセージを適切にフィルタ処理するために使用できます。
既定で .NET Framework Version 1.1 は、XML Web サービス用に生成された WSDL ドキュメント内のサポートされている SOAP バインディングごとに、 Action プロパティを soap:operation 要素の soapAction 属性に発行します。サポートされる SOAP バインディングは SOAP 1.1 です。SOAP 仕様の詳細については、W3C Web サイト (http://www.w3.org/TR/SOAP) を参照してください。
使用例
[Visual Basic, C#] Action プロパティに https://www.contoso.com/Sample
を設定するコード例を次に示します。
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Public Class MyUser
Inherits WebService
<SoapRpcMethod(Action := "https://www.contoso.com/Sample", _
RequestNamespace := "https://www.contoso.com/Request", _
RequestElementName := "GetUserNameRequest", _
ResponseNamespace := "https://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
' Deterime 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
[C#]
<%@ WebService Language="C#" class="MyUser" %>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
public class MyUser : WebService {
[ SoapRpcMethod(Action="https://www.contoso.com/Sample",
RequestNamespace="https://www.contoso.com/Request",
RequestElementName="GetUserNameRequest",
ResponseNamespace="https://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;
// Deterime 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;
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
SoapRpcMethodAttribute クラス | SoapRpcMethodAttribute メンバ | System.Web.Services.Protocols 名前空間