SoapHeaderAttribute(String) Konstruktor

Definicja

Inicjuje SoapHeaderAttribute nowe wystąpienie klasy, ustawiając składową klasy usługi sieci Web XML reprezentującą zawartość nagłówka PROTOKOŁU SOAP.

public:
 SoapHeaderAttribute(System::String ^ memberName);
public SoapHeaderAttribute (string memberName);
new System.Web.Services.Protocols.SoapHeaderAttribute : string -> System.Web.Services.Protocols.SoapHeaderAttribute
Public Sub New (memberName As String)

Parametry

memberName
String

Element członkowski klasy usługi sieci Web XML reprezentujący zawartość nagłówka PROTOKOŁU SOAP. Właściwość MemberName zostanie ustawiona na wartość tego parametru.

Przykłady

Następująca MyWebService usługa sieci Web XML definiuje jeden z SoapHeader typów MyHeader. Hello Metoda usługi sieci Web XML określa myHeader element członkowski jako MemberName właściwość do odbierania zawartości MyHeader nagłówków SOAP przekazanych do metody usługi sieci Web XML.

#using <System.EnterpriseServices.dll>
#using <System.Web.Services.dll>

using namespace System;
using namespace System::Web::Services;
using namespace System::Web::Services::Protocols;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public ref class MyHeader: public SoapHeader
{
public:
   String^ MyValue;
};

public ref class MyWebService
{
public:

   // Member variable to receive the contents of the MyHeader SOAP header.
   MyHeader^ myHeader;

   [WebMethod]
   [SoapHeader("myHeader",Direction=SoapHeaderDirection::InOut)]
   void Hello(){}

};
using System;
using System.Web.Services;
using System.Web.Services.Protocols;

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {
    // Member variable to receive the contents of the MyHeader SOAP header.
    public MyHeader myHeader;

    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]
    public void Hello() {
    }
}
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader base class.
' The header contains just one string value.
Public Class MyHeader
   Inherits SoapHeader
   Public MyValue As String
End Class


Public Class MyWebService
   ' Member variable to receive the contents of the MyHeader SOAP header.
   Public myHeader As MyHeader

   
   <WebMethod, _ 
    SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut)> _
   Public Sub Hello()

   End Sub
End Class

Uwagi

Klient usługi sieci Web XML lub usługa sieci Web XML może określić nagłówki SOAP, które chce przetworzyć dla określonych metod usługi sieci Web XML, stosując metodę SoapHeaderAttribute usługi sieci Web XML w klasie usługi sieci Web XML lub odpowiednią metodę w klasie serwera proxy. Aby metoda usługi sieci Web XML odbierała zawartość nagłówka PROTOKOŁU SOAP, element członkowski jest dodawany do klasy usługi sieci Web XML pochodzącej Type z SoapHeaderklasy . Podobnie klient usługi sieci Web XML dodaje element członkowski do klasy serwera proxy pochodzącej z SoapHeaderklasy . To Type wyprowadzenie z SoapHeader reprezentuje zawartość nagłówka SOAP i jest tworzone przez dewelopera usługi sieci Web XML lub klienta usługi sieci Web XML, który chce odbierać nagłówek SOAP. Po utworzeniu SoapHeaderAttribute klasy można zastosować metodę usługi sieci Web XML lub odpowiednią metodę w klasie serwera proxy klienta usługi sieci Web XML określającą element członkowski do odbierania zawartości nagłówka SOAP z memberName parametrem do tego konstruktora lub MemberName właściwości.

Metoda usługi sieci Web XML może odbierać wiele nagłówków PROTOKOŁU SOAP, dodając wiele elementów członkowskich do klasy usługi sieci Web XML lub klasy serwera proxy usługi sieci Web XML, a następnie stosując wiele SoapHeaderAttribute atrybutów do metody usługi sieci Web XML.

Aby odbierać i przetwarzać nieznane nagłówki protokołu SOAP w momencie zapisywania usługi sieci Web XML, określ Type element członkowski, który ma być SoapUnknownHeaderalbo tablicą SoapHeader obu klas.

Dotyczy