Sdílet prostřednictvím


SoapUnknownHeader Třída

Definice

Představuje data přijatá z hlavičky SOAP, která nebyla srozumitelná webovou službou XML příjemce nebo klientem webové služby XML. Tuto třídu nelze zdědit.

public ref class SoapUnknownHeader sealed : System::Web::Services::Protocols::SoapHeader
public sealed class SoapUnknownHeader : System.Web.Services.Protocols.SoapHeader
type SoapUnknownHeader = class
    inherit SoapHeader
Public NotInheritable Class SoapUnknownHeader
Inherits SoapHeader
Dědičnost
SoapUnknownHeader

Příklady

MyWebService Webová služba XML přijímá a zpracovává hlavičku MyHeader SOAP odeslanou všemi voláními MyWebMethod metody webové služby XML. Kromě toho MyWebMethod obdrží všechny hlavičky SOAP jiné než hlavičky MyHeader SOAP.

<%@ WebService Language="C#" Class="MyWebService"%>
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System;

// Define a SOAP header by deriving from the SoapHeader base class.

public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {

    public MyHeader myHeader;
    // Receive all SOAP headers besides the MyHeader SOAP header.
    public SoapUnknownHeader[] unknownHeaders;
 
    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

    //Receive any SOAP headers other than MyHeader.
    [SoapHeader("unknownHeaders")]

    public string MyWebMethod() {

    string unknownHeaderAttributes = String.Empty;

        // Set myHeader.MyValue to some value.
         
       foreach (SoapUnknownHeader header in unknownHeaders) {
           // Perform some processing on the header.
           foreach (XmlAttribute attribute in header.Element.Attributes) {
              unknownHeaderAttributes = unknownHeaderAttributes + attribute.Name + ":" + attribute.Value + ";";            
           }
           // For those headers that cannot be 
           // processed, set the DidUnderstand property to false.
           header.DidUnderstand = false;
       }
       return unknownHeaderAttributes;
    }
}
<%@ WebService Language="VB" Class="MyWebService"%>
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System

' Define a SOAP header by deriving from the SoapHeader base class.
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    
    Public myHeader As MyHeader
    
    ' Receive all SOAP headers besides the MyHeader SOAP header.
    Public unknownHeaders() As SoapUnknownHeader    

    'Receive any SOAP headers other than MyHeader.
    <WebMethod, _
    SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut), _
    SoapHeader("unknownHeaders")> _
    Public Function MyWebMethod() As String
        Dim unknownHeaderAttributes As String = String.Empty
        
        ' Set myHeader.MyValue to some value.
        Dim header As SoapUnknownHeader
        For Each header In  unknownHeaders
            ' Perform some processing on the header.
            Dim attribute As XmlAttribute
            For Each attribute In header.Element.Attributes
                unknownHeaderAttributes &= attribute.Name & ":" & _
                    attribute.Value & ";"
            Next attribute
            ' For those headers that cannot be 
            ' processed, set the DidUnderstand property to false.
            header.DidUnderstand = False
        Next header
        
        Return unknownHeaderAttributes
        
    End Function
End Class

Poznámky

Klient SOAP může vyvolat webovou službu XML s dalšími daty nad rámec požadovaných parametrů ve formě hlavičky SOAP. Webová služba XML vytvořená pomocí ASP.NET nebo klienta webové služby XML může zobrazit jakékoli hlavičky SOAP, o kterých nevěděl v době, kdy byla webová služba XML napsána použitím SoapHeaderAttribute vlastnosti MemberNameSoapHeaderpole nebo SoapHeaderSoapUnknownHeader pole SoapUnknownHeader metody webové služby XML. Určení , TypeSoapUnknownHeaderumožňuje webové službě XML zobrazit obsah hlavičky SOAP ve formě XmlElement.

Konstruktory

Name Description
SoapUnknownHeader()

Inicializuje novou instanci SoapUnknownHeader třídy.

Vlastnosti

Name Description
Actor

Získá nebo nastaví příjemce hlavičky SOAP.

(Zděděno od SoapHeader)
DidUnderstand

Získá nebo nastaví hodnotu určující, zda metoda webové služby XML správně zpracovala hlavičku SOAP.

(Zděděno od SoapHeader)
Element

Získá nebo nastaví XML Header element pro požadavek nebo odpověď SOAP.

EncodedMustUnderstand

Získá nebo nastaví hodnotu mustUnderstand xml atributu pro hlavičku SOAP při komunikaci s protokolem SOAP verze 1.1.

(Zděděno od SoapHeader)
EncodedMustUnderstand12

Získá nebo nastaví hodnotu mustUnderstand xml atributu pro hlavičku SOAP při komunikaci s protokolem SOAP verze 1.2.

(Zděděno od SoapHeader)
EncodedRelay

Získá nebo nastaví relé atribut hlavičky SOAP 1.2.

(Zděděno od SoapHeader)
MustUnderstand

Získá nebo nastaví hodnotu označující, zda SoapHeader musí být srozumitelný.

(Zděděno od SoapHeader)
Relay

Získá nebo nastaví hodnotu, která označuje, zda je hlavička SOAP předána do dalšího uzlu SOAP, pokud aktuální uzel nerozumí hlavičce.

(Zděděno od SoapHeader)
Role

Získá nebo nastaví příjemce hlavičky SOAP.

(Zděděno od SoapHeader)

Metody

Name Description
Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také