7.2. Using Headers on the Service

After defining your header classes, you need to specify which Web methods will use these headers. First, you declare public member variables of the types of headers you want to use. For example, Listing 7.2 shows a Web service with two member variables: one of type HeaderClass1 and one of type HeaderClass2. Note that the member variables must be public.

Listing 7.2. A Web service with two member variables representing two SOAP headers (VBWSBook\Chapter7\DataService.asmx.vb)
Public Class DataService
    Inherits System.Web.Services.WebService

    'header fields must be public
    Public inputHeader As HeaderClass1
    Public outputHeader As HeaderClass2
End Class

You add a SoapHeaderAttribute attribute to each Web method that ...

Get Real World XML Web Services: For VB and VB .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.