SoapHeaderDirection SoapHeaderDirection SoapHeaderDirection SoapHeaderDirection Enum

定义

指定 SoapHeader 的接收者是 XML Web services、XML Web services 客户端还是两者都是。Specifies whether the recipient of the SoapHeader is the XML Web service, the XML Web service client, or both.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class SoapHeaderDirection
[System.Flags]
public enum SoapHeaderDirection
type SoapHeaderDirection = 
Public Enum SoapHeaderDirection
继承
SoapHeaderDirectionSoapHeaderDirectionSoapHeaderDirectionSoapHeaderDirection
属性

字段

Fault Fault Fault Fault 4

指定 XML Web services 方法引发错误时,将 SoapHeader 发送到 XML Web services 客户端。Specifies the SoapHeader is sent to the XML Web service client when an exception is thrown by the XML Web service method.

In In In In 1

指定将 SoapHeader 发送到 XML Web services。Specifies the SoapHeader is sent to the XML Web service.

InOut InOut InOut InOut 3

指定将 SoapHeader 发送到 XML Web services 和 XML Web services 客户端。Specifies the SoapHeader is sent to both the XML Web service and the XML Web service client.

Out Out Out Out 2

指定将 SoapHeader 发送到 XML Web services 客户端。Specifies the SoapHeader is sent to the XML Web service client.

示例

下面的 XML Web 服务方法指定myHeaderFault从 XML Web 服务客户端发送到 XML Web 服务,然后返回到 XML Web 服务客户端,而不考虑 XML Web 执行期间引发的异常服务方法。The following XML Web service method specifies that the myHeaderFault is sent from the XML Web service client to the XML Web service and then back to the XML Web service client, regardless of an exception thrown during execution of the XML Web service method.

public ref class MyHeader: public SoapHeader
{
public:
   String^ MyValue;
};

public ref class MyWebService
{
public:
   MyHeader^ myHeader;

   [WebMethod]
   [SoapHeader("myHeader",
   Direction=SoapHeaderDirection::InOut|SoapHeaderDirection::Fault)]
   void MySoapHeaderReceivingMethod()
   {
      
      // Set myHeader->MyValue to some value.
   }

};

public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {

    public MyHeader myHeader;

    [WebMethod]
    [SoapHeader("myHeader", 
                Direction=SoapHeaderDirection.InOut | SoapHeaderDirection.Fault)]
    public void MySoapHeaderReceivingMethod() {

        // Set myHeader.MyValue to some value.

    }
}
   
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    
    Public myHeader As MyHeader    
    
    <WebMethod, _
    SoapHeader("myHeader", _
                Direction := SoapHeaderDirection.InOut Or SoapHeaderDirection.Fault)> _
    Public Sub MySoapHeaderReceivingMethod()

        ' Set myHeader.MyValue to some value.
        
    End Sub
    
End Class

注解

一个SoapHeaderAttribute可以应用于 XML Web 服务方法或 XML Web 服务的代理类的方法。A SoapHeaderAttribute can be applied to either an XML Web service method or a method of a proxy class to an XML Web service. 在任一情况下,指定收件人Direction属性的SoapHeaderAttributeIn either case, the recipient(s) are specified by the Direction property of SoapHeaderAttribute. 若要指定 XML Web 服务方法返回的 SOAP 标头,其执行期间引发异常时,将应用SoapHeaderAttribute方法,设置到Direction到错误的属性。To specify that an XML Web service method returns a SOAP header when an exception is thrown during its execution, apply an SoapHeaderAttribute to the method and set the Direction property to Fault.

.NET Framework 1.0 版不支持错误值。Version 1.0 of the .NET Framework does not support the Fault value.

适用于

另请参阅