SoapRpcMethodAttribute クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)

<AttributeUsageAttribute(AttributeTargets.Method)> _ Public NotInheritable Class SoapRpcMethodAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method)] public sealed class SoapRpcMethodAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method)] public ref class SoapRpcMethodAttribute sealed : public Attribute

Web サービス記述言語 (WSDL: Web Services Description Language) では、XML Web サービス メソッドまたは操作の SOAP メッセージ内における書式として、RPC と Document の 2 つのスタイルを定義しています。RPC スタイルは、SOAP 仕様の RPC としての SOAP の使用に関する規定 (SOAP 仕様のセクション 7) に従って操作の書式を指定することを示します。RPC スタイルは、XML Web サービス メソッドの名前が付いている単一の XML 要素内にすべてのパラメータをカプセル化し、その XML 要素内の各 XML 要素が各パラメータを表し、各要素にはそれぞれが表すパラメータの名前が付けられることを指定します。
RPC (Remote Procedure Call) で XML Web サービスと通信する場合は、RPC スタイルおよび Document スタイルで書式設定された SOAP メッセージを使用できます。Document スタイルは、疎結合で通信する場合にも簡単に使用できます。したがって、Document スタイルの XML Web サービスを推奨します。詳細については、Customizing SOAP Messages のトピックを参照してください。
詳細については、SOAP メッセージ形式のカスタマイズ のトピックを参照してください。
この属性は、サーバー上の XML Web サービス メソッドと、クライアント上のプロキシ クラスに適用できます。OneWay プロパティが true に設定されている XML Web サービス メソッドは、その HttpContext にはアクセスできません。このため、WebService クラスのプロパティのいずれかにアクセスすると、null 参照 (Visual Basic では Nothing) が返されます。

GetUserName XML Web サービス メソッドに対して、メッセージ スタイルを Rpc に設定するコード例を次に示します。
<%@ 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 out the domain name from 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
<%@ 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 out the domain name from 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; }

System.Attribute
System.Web.Services.Protocols.SoapRpcMethodAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapRpcMethodAttribute クラスのページへのリンク