SoapDocumentMethodAttribute Klasa

Definicja

SoapDocumentMethodAttribute Zastosowanie metody do metody określa, że komunikaty SOAP do i z metody używają Document formatowania.

public ref class SoapDocumentMethodAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class SoapDocumentMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public sealed class SoapDocumentMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type SoapDocumentMethodAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type SoapDocumentMethodAttribute = class
    inherit Attribute
Public NotInheritable Class SoapDocumentMethodAttribute
Inherits Attribute
Dziedziczenie
SoapDocumentMethodAttribute
Atrybuty

Przykłady

Poniższy przykład kodu ustawia styl komunikatu dla Document GetUserName metody usługi sieci Web XML. Ponadto element XML z elementem Body żądania SOAP i odpowiedzi soap są ustawione odpowiednio na GetUserNameRequest i 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

Uwagi

Język opisu usług sieci Web (WSDL) definiuje dwa style sposobu, w jaki metoda usługi sieci Web XML, którą wywołuje operację, można sformatować w komunikacie SOAP: RPC i Document. Document odwołuje się do formatowania metody usługi sieci Web XML zgodnie ze schematem XSD. Styl Document odnosi się do formatowania Body elementu jako serii co najmniej jednej części komunikatu po elemecie Body . Dokładnie sposób określania poszczególnych części komunikatów Use przez właściwości i ParameterStyle . Właściwość Use określa, czy parametry są sformatowane Encoded , czy Literal. Określa ParameterStyle , czy parametry są hermetyzowane w ramach jednej części komunikatu po Body elemecie, czy każdy parametr jest pojedynczą częścią komunikatu.

Aby uzyskać więcej informacji, zobacz Dostosowywanie formatowania komunikatów PROTOKOŁU SOAP.

Ten atrybut można zastosować zarówno do metody usługi sieci Web XML na serwerze, jak i metody klasy serwera proxy na kliencie.

Konstruktory

SoapDocumentMethodAttribute()

Inicjuje nowe wystąpienie klasy SoapDocumentMethodAttribute.

SoapDocumentMethodAttribute(String)

Inicjuje SoapDocumentMethodAttribute nowe wystąpienie klasy, ustawiając Action właściwość na wartość parametru action .

Właściwości

Action

Pobiera lub ustawia SOAPAction pole nagłówka HTTP żądania SOAP.

Binding

Pobiera lub ustawia powiązanie metody usługi sieci Web XML implementuje operację .

OneWay

Pobiera lub ustawia, czy klient usługi sieci Web XML czeka na zakończenie przetwarzania metody usługi sieci Web XML.

ParameterStyle

Pobiera lub ustawia, czy parametry są hermetyzowane w ramach pojedynczego elementu XML poniżej Body elementu w części XML komunikatu SOAP.

RequestElementName

Pobiera lub ustawia element XML skojarzony z żądaniem SOAP dla metody usługi sieci Web XML zdefiniowanej w opisie usługi jako operacji.

RequestNamespace

Pobiera lub ustawia przestrzeń nazw skojarzona z żądaniem SOAP dla metody usługi sieci Web XML.

ResponseElementName

Pobiera lub ustawia element XML skojarzony z odpowiedzią PROTOKOŁU SOAP dla metody usługi sieci Web XML.

ResponseNamespace

Pobiera lub ustawia przestrzeń nazw XML skojarzona z odpowiedzią PROTOKOŁU SOAP dla metody usługi sieci Web XML.

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego Attributeelementu .

(Odziedziczone po Attribute)
Use

Pobiera lub ustawia formatowanie parametrów dla metody usługi sieci Web XML w części XML komunikatu SOAP.

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

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

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też