This documentation is archived and is not being maintained.

SoapHeaderAttribute.Direction Property

Gets or sets whether the SOAP header is intended for the XML Web service or the XML Web service client or both.

[Visual Basic]
Public Property Direction As SoapHeaderDirection
[C#]
public SoapHeaderDirection Direction {get; set;}
[C++]
public: __property SoapHeaderDirection get_Direction();
public: __property void set_Direction(SoapHeaderDirection);
[JScript]
public function get Direction() : SoapHeaderDirection;
public function set Direction(SoapHeaderDirection);

Property Value

The intended recipient of the SOAP header. The default is In, which means the intended recipient is just the XML Web service.

Example

[Visual Basic, C#, C++] The following MyWebService XML Web service defines one SoapHeader of type MyHeader. The Hello XML Web service method specifies that MyHeader must be sent to the XML Web service method and the client to invocate the XML Web service method.

[Visual Basic] 
Imports System
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 'MyHeader


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 'Hello
End Class 'MyWebService


[C#] 
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() {
    
    }
}

[C++] 
#using <mscorlib.dll>
#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 __gc class MyHeader : public SoapHeader {
public:
    String* MyValue;
};

public __gc class MyWebService {
    // Member variable to receive the contents of the MyHeader SOAP header.
public:
    MyHeader* myHeader;
 
    [WebMethod]
    [SoapHeader(S"myHeader", Direction=SoapHeaderDirection::InOut)]
    void Hello() {
    
    }
};

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SoapHeaderAttribute Class | SoapHeaderAttribute Members | System.Web.Services.Protocols Namespace

Show: