SoapDocumentMethodAttribute Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
L'applicazione del SoapDocumentMethodAttribute a un metodo specifica che i messaggi SOAP da e verso il metodo utilizzano Document formattazione.
public ref class SoapDocumentMethodAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class SoapDocumentMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type SoapDocumentMethodAttribute = class
inherit Attribute
Public NotInheritable Class SoapDocumentMethodAttribute
Inherits Attribute
- Ereditarietà
- Attributi
Esempio
Nell'esempio di codice seguente viene impostato lo stile del messaggio su Document per il metodo del GetUserName servizio Web XML. Inoltre, l'elemento XML con l'elemento per la richiesta SOAP e la Body risposta SOAP vengono impostati rispettivamente su GetUserNameRequest e GetUserNameResponse.
<%@ WebService Language="C#" class="MyUser" %>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
public class MyUser : WebService {
[ SoapDocumentMethod(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 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;
}
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Public Class MyUser
Inherits WebService
<SoapDocumentMethod(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 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
Commenti
Web Services Description Language (WSDL) definisce due stili per il modo in cui un metodo di servizio Web XML, che chiama un'operazione, può essere formattato in un messaggio SOAP: RPC e Document.
Document fa riferimento alla formattazione del metodo del servizio Web XML in base a uno schema XSD. Lo Document stile fa riferimento alla formattazione dell'elemento Body come una serie di una o più parti del messaggio che seguono l'elemento Body . Esattamente come le singole parti del messaggio sono determinate dalle Use proprietà e ParameterStyle . La Use proprietà determina se i parametri sono formattati Encoded o Literal. Determina ParameterStyle se i parametri vengono incapsulati all'interno di una singola parte del messaggio dopo l'elemento Body o se ogni parametro è una singola parte del messaggio.
Per altri dettagli, vedere Personalizzazione della formattazione dei messaggi SOAP.
Questo attributo può essere applicato sia a un metodo di servizio Web XML nel server che a un metodo della classe proxy nel client.
Costruttori
| Nome | Descrizione |
|---|---|
| SoapDocumentMethodAttribute() |
Inizializza una nuova istanza della classe SoapDocumentMethodAttribute. |
| SoapDocumentMethodAttribute(String) |
Inizializza una nuova istanza della SoapDocumentMethodAttribute classe impostando la Action proprietà sul valore del |
Proprietà
| Nome | Descrizione |
|---|---|
| Action |
Ottiene o imposta il |
| 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. |
| ParameterStyle |
Ottiene o imposta un valore che indica se i parametri vengono incapsulati all'interno di un singolo elemento XML sotto l'elemento |
| RequestElementName |
Ottiene o imposta l'elemento XML associato alla richiesta SOAP per un metodo di servizio Web XML, definito in una descrizione del servizio come operazione. |
| RequestNamespace |
Ottiene o imposta lo spazio dei nomi 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 la formattazione dei parametri per un metodo di servizio Web XML all'interno della parte XML di un messaggio SOAP. |
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) |