This documentation is archived and is not being maintained.

SoapHeaderBinding Class

Represents an extensibility element added to an InputBinding or an OutputBinding within an XML Web service.

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

'Declaration
<XmlFormatExtensionAttribute("header", "http://schemas.xmlsoap.org/wsdl/soap/",  _
	GetType(InputBinding), GetType(OutputBinding))> _
Public Class SoapHeaderBinding _
	Inherits ServiceDescriptionFormatExtension
'Usage
Dim instance As SoapHeaderBinding

For more information about specifying protocols for XML Web services, see [<topic://cpconbuildingaspnetwebservices>]. For more information about Web Services Description Language (WSDL), see the specification at http://www.w3.org/TR/wsdl/.

Imports System
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Public Class MySampleClass
   Public Shared Sub Main()
      Dim myServiceDescription As ServiceDescription = _
                        ServiceDescription.Read("SoapHeaderBindingInput_vb.wsdl")
      Dim myBinding As New Binding()
      myBinding.Name = "MyWebServiceSoap"
      myBinding.Type = New XmlQualifiedName("s0:MyWebServiceSoap")

      Dim mySoapBinding As New SoapBinding()
      mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"
      mySoapBinding.Style = SoapBindingStyle.Document
      myBinding.Extensions.Add(mySoapBinding)

      Dim myOperationBinding As New OperationBinding()
      myOperationBinding.Name = "Hello" 

      Dim mySoapOperationBinding As New SoapOperationBinding()
      mySoapOperationBinding.SoapAction = "http://tempuri.org/Hello"
      mySoapOperationBinding.Style = SoapBindingStyle.Document
      myOperationBinding.Extensions.Add(mySoapOperationBinding)

      ' Create InputBinding for operation for the 'SOAP' protocol. 
      Dim myInputBinding As New InputBinding()
      Dim mySoapBodyBinding As New SoapBodyBinding()
      mySoapBodyBinding.Use = SoapBindingUse.Literal
      myInputBinding.Extensions.Add(mySoapBodyBinding)
      Dim mySoapHeaderBinding As New SoapHeaderBinding()
      mySoapHeaderBinding.Message = New XmlQualifiedName("s0:HelloMyHeader")
      mySoapHeaderBinding.Part = "MyHeader"
      mySoapHeaderBinding.Use = SoapBindingUse.Literal
      ' Add mySoapHeaderBinding to 'myInputBinding' object.
      myInputBinding.Extensions.Add(mySoapHeaderBinding)
      ' Create OutputBinding for operation for the 'SOAP' protocol. 
      Dim myOutputBinding As New OutputBinding()
      myOutputBinding.Extensions.Add(mySoapBodyBinding)

      ' Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
      myOperationBinding.Input = myInputBinding
      myOperationBinding.Output = myOutputBinding
      myBinding.Operations.Add(myOperationBinding)

      myServiceDescription.Bindings.Add(myBinding)
      myServiceDescription.Write("SoapHeaderBindingOut_vb.wsdl")
      Console.WriteLine("'SoapHeaderBindingOut_vb.wsdl' file is generated.")
      Console.WriteLine("Proxy could be created using " + _
                        "'wsdl /language:VB SoapHeaderBindingOut_vb.wsdl'.")
   End Sub 'Main
End Class 'MySampleClass
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;

int main() 
{
   ServiceDescription* myServiceDescription =
      ServiceDescription::Read(S"SoapHeaderBindingInput_cpp.wsdl");
   Binding* myBinding = new Binding();
   myBinding->Name = S"MyWebServiceSoap";
   myBinding->Type = new XmlQualifiedName(S"s0:MyWebServiceSoap");

   SoapBinding* mySoapBinding = new SoapBinding();
   mySoapBinding->Transport=S"http://schemas.xmlsoap.org/soap/http";
   mySoapBinding->Style=SoapBindingStyle::Document;
   myBinding->Extensions->Add(mySoapBinding);

   OperationBinding* myOperationBinding = new OperationBinding();
   myOperationBinding->Name = S"Hello";

   SoapOperationBinding* mySoapOperationBinding = new SoapOperationBinding();
   mySoapOperationBinding->SoapAction = S"http://tempuri.org/Hello";
   mySoapOperationBinding->Style=SoapBindingStyle::Document;
   myOperationBinding->Extensions->Add(mySoapOperationBinding);

   // Create InputBinding for operation for the 'SOAP' protocol.
   InputBinding* myInputBinding = new InputBinding();
   SoapBodyBinding* mySoapBodyBinding = new SoapBodyBinding();
   mySoapBodyBinding->Use = SoapBindingUse::Literal;
   myInputBinding->Extensions->Add(mySoapBodyBinding);
   SoapHeaderBinding* mySoapHeaderBinding = new SoapHeaderBinding();
   mySoapHeaderBinding->Message = new XmlQualifiedName(S"s0:HelloMyHeader");
   mySoapHeaderBinding->Part=S"MyHeader";
   mySoapHeaderBinding->Use=SoapBindingUse::Literal;
   // Add mySoapHeaderBinding to 'myInputBinding' object.
   myInputBinding->Extensions->Add(mySoapHeaderBinding);
   // Create OutputBinding for operation for the 'SOAP' protocol.
   OutputBinding* myOutputBinding = new OutputBinding();
   myOutputBinding->Extensions->Add(mySoapBodyBinding);

   // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
   myOperationBinding->Input = myInputBinding;
   myOperationBinding->Output = myOutputBinding;
   myBinding->Operations->Add(myOperationBinding);

   myServiceDescription->Bindings->Add(myBinding);
   myServiceDescription->Write(S"SoapHeaderBindingOut_cpp.wsdl");
   Console::WriteLine(S"'SoapHeaderBindingOut_cpp.wsdl' file is generated.");
   Console::WriteLine(S"Proxy could be created using 'wsdl SoapHeaderBindingOut_cpp.wsdl'.");
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: