Export (0) Print
Expand All

SoapHeaderAttribute.MemberName Property

Gets or sets the member of the XML Web service class representing the SOAP header contents.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

public string MemberName { get; set; }
/** @property */
public String get_MemberName ()

/** @property */
public void set_MemberName (String value)

public function get MemberName () : String

public function set MemberName (value : String)

Not applicable.

Property Value

The member of the XML Web service class representing the SOAP header contents. There is no default.

An XML Web service or XML Web service client can specify the SOAP headers it wants to process by applying a SoapHeaderAttribute to the XML Web service method in the XML Web service class or the corresponding method in the proxy class. In order for the XML Web service method to receive the contents of the SOAP header, a member is added to the XML Web service class of a type derived from SoapHeader. Likewise, an XML Web service client adds a member to the proxy class deriving from SoapHeader. The Type deriving from SoapHeader represents the contents of the SOAP header and is created by the developer of the XML Web service or XML Web service client that wants to receive the SOAP header. Once the class is created, a SoapHeaderAttribute can be applied to the XML Web service method or corresponding method in the XML Web service client proxy class specifying the member to receive the SOAP header contents with the MemberName property.

An XML Web service method can receive multiple SOAP headers by adding multiple members to the XML Web service class or the XML Web service proxy class and in turn applying multiple SoapHeaderAttribute attributes to the XML Web service method.

To receive and process unknown SOAP headers at the time the XML Web service is written, specify the type of the member to be either SoapUnknownHeader, SoapHeader or an array of either class.

The following MyWebService XML Web service defines one SoapHeader of type MyHeader. The Hello XML Web service method specifies the myHeader member as the MemberName property to receive the contents of MyHeader SOAP headers passed into the XML Web service method.

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() {
    
    }
}

import System.*;
import System.Web.Services.*;
import 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 extends SoapHeader
{
    public String myValue;
} //MyHeader

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

    /** @attribute WebMethod()
     */
    /** @attribute SoapHeader("myHeader", Direction = SoapHeaderDirection.InOut)
     */

    public void Hello()
    {
    } //Hello
} //MyWebService

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft