SoapRpcMethodAttribute Classe

Definizione

Specifica che i messaggi SOAP inviati da e verso il metodo utilizzano la formattazione RPC.

public ref class SoapRpcMethodAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class SoapRpcMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public sealed class SoapRpcMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type SoapRpcMethodAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type SoapRpcMethodAttribute = class
    inherit Attribute
Public NotInheritable Class SoapRpcMethodAttribute
Inherits Attribute
Ereditarietà
SoapRpcMethodAttribute
Attributi

Esempio

Nell'esempio di codice seguente viene impostato lo stile Rpc del messaggio su per il metodo del GetUserName servizio Web XML.

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

Commenti

Web Services Description Language (WSDL) definisce due stili per il modo in cui un metodo o un'operazione del servizio Web XML può essere formattato in un messaggio SOAP: RPC e Document. RPC la formattazione fa riferimento alla formattazione dell'operazione in base alla specifica SOAP per l'uso di SOAP per RPC; nota come sezione 7 della specifica SOAP. RPC la formattazione indica che tutti i parametri vengono incapsulati all'interno di un singolo elemento XML denominato dopo il metodo del servizio Web XML e che ogni elemento XML all'interno di tale elemento XML rappresenta un parametro denominato dopo il parametro che rappresenta.

I messaggi SOAP formattati in entrambi gli RPC stili e Document possono essere utilizzati per comunicare con un servizio Web XML in modalità RPC (Remote Procedure Call). Tuttavia, lo Document stile può essere usato facilmente per comunicare in modo libero. Pertanto, Document è consigliabile applicare lo stile ai servizi Web XML. Per altri dettagli, vedere l'argomento Customizing SOAP Messages .

Per altre informazioni, vedere Personalizzazione della formattazione dei messaggi SOAP.

Questo attributo può essere applicato a un metodo di servizio Web XML nel server e a una classe proxy nel client. I metodi del servizio Web XML con la OneWay proprietà impostata su true non hanno accesso al relativo HttpContext. Di conseguenza, l'accesso a una delle proprietà della WebService classe restituisce null.

Costruttori

SoapRpcMethodAttribute()

Inizializza una nuova istanza della classe SoapRpcMethodAttribute, impostando tutte le proprietà sui relativi valori predefiniti.

SoapRpcMethodAttribute(String)

Inizializza una nuova istanza della classe SoapRpcMethodAttribute, impostando la proprietà Action sul valore del parametro action.

Proprietà

Action

Ottiene o imposta il campo di intestazione HTTP SOAPAction della richiesta SOAP.

Binding

Ottiene o imposta l'associazione per cui un metodo di servizio Web XML implementa un'operazione.

OneWay

Ottiene o imposta l'eventuale attesa da parte del client di un servizio Web XML per il completamento dell'elaborazione di un metodo di servizio Web XML da parte di un server Web.

RequestElementName

Ottiene o imposta l'elemento XML associato alla richiesta SOAP per un metodo di servizio Web XML.

RequestNamespace

Ottiene o imposta lo spazio dei nomi XML associato alla richiesta SOAP per un metodo di servizio Web XML.

ResponseElementName

Ottiene o imposta l'elemento XML associato alla risposta SOAP per un metodo di servizio Web XML.

ResponseNamespace

Ottiene o imposta lo spazio dei nomi XML associato alla risposta SOAP per un metodo di servizio Web XML.

TypeId

Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.

(Ereditato da Attribute)
Use

Ottiene o imposta l'associazione utilizzata durante la chiamata del metodo.

Metodi

Equals(Object)

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

(Ereditato da Attribute)
GetHashCode()

Restituisce il codice hash per l'istanza.

(Ereditato da Attribute)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

In caso di override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.

(Ereditato da Attribute)
Match(Object)

Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da Attribute)

Si applica a

Vedi anche