Condividi tramite


SoapRpcMethodAttribute Classe

Definizione

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

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

Esempio

Nell'esempio di codice seguente viene impostato lo stile del messaggio su Rpc 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 si riferisce 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 usati per comunicare con un servizio Web XML in modo RPC (Remote Procedure Call). Tuttavia, lo Document stile può essere usato facilmente per comunicare in modo associato in modo libero. Pertanto, Document è consigliabile usare i servizi Web XML in stile. Per altri dettagli, vedere l'argomento Customizing SOAP Messages .

Per altri dettagli, 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 HttpContextoggetto . Di conseguenza, l'accesso a una delle proprietà della WebService classe restituisce null.

Costruttori

Nome Descrizione
SoapRpcMethodAttribute()

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

SoapRpcMethodAttribute(String)

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

Proprietà

Nome Descrizione
Action

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

Binding

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

OneWay

Ottiene o imposta un valore che indica se un client del servizio Web XML attende che il server Web termini l'elaborazione di un metodo di servizio Web XML.

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 del servizio Web XML.

TypeId

Se implementato in una classe derivata, ottiene un identificatore univoco per questo Attribute.

(Ereditato da Attribute)
Use

Ottiene o imposta l'associazione utilizzata per richiamare il metodo .

Metodi

Nome Descrizione
Equals(Object)

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

(Ereditato da Attribute)
GetHashCode()

Restituisce il codice hash per questa istanza.

(Ereditato da Attribute)
GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

Quando sottoposto a 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 è uguale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

Nome Descrizione
_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 per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per 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 alle proprietà e ai metodi esposti da un oggetto .

(Ereditato da Attribute)

Si applica a

Vedi anche