SoapUnknownHeader 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示从接收方 XML Web services 或 XML Web services 客户端未能理解的 SOAP 标头中接收的数据。 此类不能被继承。
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
- 继承
示例
MyWebService
XML Web 服务接受并处理MyHeader
随对 XML Web 服务方法的任何调用一起发送的 MyWebMethod
SOAP 标头。 此外, MyWebMethod
接收 SOAP 标头以外的 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
注解
SOAP 客户端可以调用 XML Web 服务,其附加数据超出了 SOAP 标头形式的必需参数。 使用 ASP.NET 或 XML Web 服务客户端创建的 XML Web 服务可以查看 XML Web 服务在编写 XML Web 服务时不知道的任何 SOAP 标头,方法是应用SoapHeaderAttribute具有MemberName数组或 XML Web 服务方法的SoapUnknownHeader数组SoapHeaderSoapHeaderSoapUnknownHeader的属性。 Specifying a Type of SoapUnknownHeader, allows the XML Web service to view the contents of the SOAP header in the form of an XmlElement.
构造函数
SoapUnknownHeader() |
初始化 SoapUnknownHeader 类的新实例。 |
属性
Actor |
获取或设置 SOAP 标头的接收者。 (继承自 SoapHeader) |
DidUnderstand |
获取或设置一个值,该值指示 XML Web services 方法是否已正确处理 SOAP 标头。 (继承自 SoapHeader) |
Element |
获取或设置 SOAP 请求或响应的 XML 标头元素。 |
EncodedMustUnderstand |
当与 SOAP 协议 1.1 版通信时,获取或设置 SOAP 标头的 |
EncodedMustUnderstand12 |
与 SOAP 协议 1.2 版通信时,获取或设置 SOAP 标头的 |
EncodedRelay |
获取或设置 SOAP 1.2 标头的中转特性。 (继承自 SoapHeader) |
MustUnderstand |
获取或设置一个值,该值指示是否必须理解 SoapHeader。 (继承自 SoapHeader) |
Relay |
获取或设置一个值,该值指示当前节点不理解 SOAP 标头时是否将该标头中转到下一个 SOAP 节点。 (继承自 SoapHeader) |
Role |
获取或设置 SOAP 标头的接收者。 (继承自 SoapHeader) |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |