Freigeben über


SoapRpcMethodAttribute.Action-Eigenschaft

Ruft das SOAPAction-HTTP-Headerfeld der SOAP-Anforderung ab oder legt dieses fest.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Property Action As String
'Usage
Dim instance As SoapRpcMethodAttribute
Dim value As String

value = instance.Action

instance.Action = value
public string Action { get; set; }
public:
property String^ Action {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_Action ()

/** @property */
public void set_Action (String value)
public function get Action () : String

public function set Action (value : String)

Eigenschaftenwert

Das SOAPAction-HTTP-Headerfeld der SOAP-Anforderung. Die Standardeinstellung ist http://tempuri.org/Methodenname, wobei Methodenname der Name der XML-Webdienstmethode ist.

Hinweise

In der Regel ist die Action-Eigenschaft ein URI, der den Zweck der SOAP-Anforderung angibt. Durch die SOAP-Spezifikation wird jedoch weder das Format eingeschränkt, noch werden Beschränkungen bezüglich dessen auferlegt, ob der URI auf ein vorhandenes Dokument verweist. Das Vorhandensein und der Inhalt der Action-Eigenschaft können von Webservern, z. B. Firewalls, verwendet werden, um SOAP-Anforderungsnachrichten in HTTP entsprechend zu filtern.

.NET Framework, Version 1.1, veröffentlicht die Action-Eigenschaft im soapAction-Attribut des soap:operation-Elements für jede unterstützte SOAP-Bindung in für einen XML-Webdienst generierten WSDL-Dokumenten. SOAP 1.1 ist die unterstützte SOAP-Bindung.

Weitere Informationen über die SOAP-Spezifikation finden Sie auf der W3C-Website unter http://www.w3.org/TR/SOAP (nur auf Englisch verfügbar).

Beispiel

Im folgenden Codebeispiel wird die Action-Eigenschaft auf https://www.contoso.com/Sample festgelegt.

<%@ 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
<%@ 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;
 }

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

SoapRpcMethodAttribute-Klasse
SoapRpcMethodAttribute-Member
System.Web.Services.Protocols-Namespace