MessageBinding-Klasse
Beschreibt, wie abstrakter Inhalt einem konkreten Format zugeordnet wird.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Syntax
'Declaration
Public MustInherit Class MessageBinding
Inherits NamedItem
'Usage
Dim instance As MessageBinding
public abstract class MessageBinding : NamedItem
public ref class MessageBinding abstract : public NamedItem
public abstract class MessageBinding extends NamedItem
public abstract class MessageBinding extends NamedItem
Hinweise
Diese abstrakte Klasse bildet die Basisklasse für folgende Klassen:
Beispiel
Das folgende Beispiel veranschaulicht eine typische Verwendung der MessageBinding-Klasse.
Imports System
Imports System.Web.Services.Description
Class MyClass1
Public Shared Sub Main()
Dim addOperationBinding As OperationBinding = _
CreateOperationBinding("Add", "http://tempuri.org/")
End Sub 'Main
Public Shared Function CreateInputOutputBinding(myBindName As String, _
isInputBinding As Boolean) As MessageBinding
' Value isInputBinding = true ---> return type = InputBinding.
' Value isInputBinding = false --> return type = OutputBinding.
Dim myMessageBinding As MessageBinding = Nothing
Select Case isInputBinding
Case True
myMessageBinding = New InputBinding()
Console.WriteLine("Added an InputBinding")
Case False
myMessageBinding = New OutputBinding()
Console.WriteLine("Added an OutputBinding")
End Select
myMessageBinding.Name = myBindName
Dim mySoapBodyBinding As New SoapBodyBinding()
mySoapBodyBinding.Use = SoapBindingUse.Literal
myMessageBinding.Extensions.Add(mySoapBodyBinding)
Console.WriteLine("Added extensibility element of type: " & _
mySoapBodyBinding.GetType().ToString())
Return myMessageBinding
End Function 'CreateInputOutputBinding
' Used to create OperationBinding instances within Binding.
Public Shared Function CreateOperationBinding(myOperation As String, _
targetNamespace As String) As OperationBinding
' Create OperationBinding for operation.
Dim myOperationBinding As New OperationBinding()
myOperationBinding.Name = myOperation
' Create InputBinding for operation.
Dim myInputBinding As InputBinding = _
CType(CreateInputOutputBinding(Nothing, True), InputBinding)
' Create OutputBinding for operation.
Dim myOutputBinding As OutputBinding = _
CType(CreateInputOutputBinding(Nothing, False), OutputBinding)
' Add InputBinding and OutputBinding to OperationBinding.
myOperationBinding.Input = myInputBinding
myOperationBinding.Output = myOutputBinding
' Create an extensibility element for SoapOperationBinding.
Dim mySoapOperationBinding As New SoapOperationBinding()
mySoapOperationBinding.Style = SoapBindingStyle.Document
mySoapOperationBinding.SoapAction = targetNamespace + myOperation
' Add the extensibility element SoapOperationBinding to OperationBinding.
myOperationBinding.Extensions.Add(mySoapOperationBinding)
Return myOperationBinding
End Function 'CreateOperationBinding
End Class 'MyClass1
using System;
using System.Web.Services.Description;
class MyClass
{
public static void Main()
{
OperationBinding addOperationBinding =
CreateOperationBinding("Add","http://tempuri.org/");
}
public static MessageBinding CreateInputOutputBinding(string myBindName,
bool isInputBinding)
{
// Value isInputBinding = true ---> return type = InputBinding.
// Value isInputBinding = false --> return type = OutputBinding.
MessageBinding myMessageBinding = null;
switch(isInputBinding)
{
case true:
myMessageBinding = new InputBinding();
Console.WriteLine("Added an InputBinding");
break;
case false:
myMessageBinding = new OutputBinding();
Console.WriteLine("Added an OutputBinding");
break;
}
myMessageBinding.Name = myBindName;
SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
mySoapBodyBinding.Use = SoapBindingUse.Literal;
myMessageBinding.Extensions.Add(mySoapBodyBinding);
Console.WriteLine("Added extensibility element of type : " +
mySoapBodyBinding.GetType());
return myMessageBinding;
}
// Used to create OperationBinding instances within Binding.
public static OperationBinding CreateOperationBinding(
string myOperation,string targetNamespace)
{
// Create OperationBinding for Operation.
OperationBinding myOperationBinding = new OperationBinding();
myOperationBinding.Name = myOperation;
// Create InputBinding for operation.
InputBinding myInputBinding =
(InputBinding)CreateInputOutputBinding(null,true);
// Create OutputBinding for operation.
OutputBinding myOutputBinding =
(OutputBinding)CreateInputOutputBinding(null,false);
// Add InputBinding and OutputBinding to OperationBinding.
myOperationBinding.Input = myInputBinding;
myOperationBinding.Output = myOutputBinding;
// Create an extensibility element for SoapOperationBinding.
SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();
mySoapOperationBinding.Style = SoapBindingStyle.Document;
mySoapOperationBinding.SoapAction = targetNamespace + myOperation;
// Add the extensibility element SoapOperationBinding to OperationBinding.
myOperationBinding.Extensions.Add(mySoapOperationBinding);
return myOperationBinding;
}
}
#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Web::Services::Description;
MessageBinding^ CreateInputOutputBinding( String^ myBindName, bool isInputBinding )
{
// Value isInputBinding = true ---> return type = InputBinding.
// Value isInputBinding = false --> return type = OutputBinding.
MessageBinding^ myMessageBinding = nullptr;
switch ( isInputBinding )
{
case true:
myMessageBinding = gcnew InputBinding;
Console::WriteLine( "Added an InputBinding" );
break;
case false:
myMessageBinding = gcnew OutputBinding;
Console::WriteLine( "Added an OutputBinding" );
break;
}
myMessageBinding->Name = myBindName;
SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding;
mySoapBodyBinding->Use = SoapBindingUse::Literal;
myMessageBinding->Extensions->Add( mySoapBodyBinding );
Console::WriteLine( "Added extensibility element of type : {0}", mySoapBodyBinding->GetType() );
return myMessageBinding;
}
// Used to create OperationBinding instances within Binding.
OperationBinding^ CreateOperationBinding( String^ myOperation, String^ targetNamespace )
{
// Create OperationBinding for Operation.
OperationBinding^ myOperationBinding = gcnew OperationBinding;
myOperationBinding->Name = myOperation;
// Create InputBinding for operation.
InputBinding^ myInputBinding = dynamic_cast<InputBinding^>(CreateInputOutputBinding( nullptr, true ));
// Create OutputBinding for operation.
OutputBinding^ myOutputBinding = dynamic_cast<OutputBinding^>(CreateInputOutputBinding( nullptr, false ));
// Add InputBinding and OutputBinding to OperationBinding.
myOperationBinding->Input = myInputBinding;
myOperationBinding->Output = myOutputBinding;
// Create an extensibility element for SoapOperationBinding.
SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding;
mySoapOperationBinding->Style = SoapBindingStyle::Document;
mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, myOperation );
// Add the extensibility element SoapOperationBinding to OperationBinding.
myOperationBinding->Extensions->Add( mySoapOperationBinding );
return myOperationBinding;
}
int main()
{
/* OperationBinding* addOperationBinding = */
CreateOperationBinding( "Add", "http://tempuri.org/" );
}
import System.*;
import System.Web.Services.Description.*;
class MyClass
{
public static void main(String[] args) {
OperationBinding addOperationBinding =
CreateOperationBinding("Add", "http://tempuri.org/");
} //main
public static MessageBinding CreateInputOutputBinding(String myBindName,
boolean isInputBinding)
{
// Value isInputBinding = true ---> return type = InputBinding.
// Value isInputBinding = false --> return type = OutputBinding.
MessageBinding myMessageBinding = null;
if (isInputBinding) {
myMessageBinding = new InputBinding();
Console.WriteLine("Added an InputBinding");
}
else {
myMessageBinding = new OutputBinding();
Console.WriteLine("Added an OutputBinding");
}
myMessageBinding.set_Name(myBindName);
SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
mySoapBodyBinding.set_Use(SoapBindingUse.Literal);
myMessageBinding.get_Extensions().Add(mySoapBodyBinding);
Console.WriteLine("Added extensibility element of type : "
+ mySoapBodyBinding.GetType());
return myMessageBinding;
} //CreateInputOutputBinding
// Used to create OperationBinding instances within Binding.
public static OperationBinding CreateOperationBinding(String myOperation,
String targetNamespace)
{
// Create OperationBinding for Operation.
OperationBinding myOperationBinding = new OperationBinding();
myOperationBinding.set_Name(myOperation);
// Create InputBinding for operation.
InputBinding myInputBinding =
(InputBinding)CreateInputOutputBinding(null, true);
// Create OutputBinding for operation.
OutputBinding myOutputBinding =
(OutputBinding)CreateInputOutputBinding(null, false);
// Add InputBinding and OutputBinding to OperationBinding.
myOperationBinding.set_Input(myInputBinding);
myOperationBinding.set_Output(myOutputBinding);
// Create an extensibility element for SoapOperationBinding.
SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();
mySoapOperationBinding.set_Style(SoapBindingStyle.Document);
mySoapOperationBinding.set_SoapAction(targetNamespace + myOperation);
// Add the extensibility element SoapOperationBinding to
// OperationBinding.
myOperationBinding.get_Extensions().Add(mySoapOperationBinding);
return myOperationBinding;
} //CreateOperationBinding
} //MyClass
Vererbungshierarchie
System.Object
System.Web.Services.Description.DocumentableItem
System.Web.Services.Description.NamedItem
System.Web.Services.Description.MessageBinding
System.Web.Services.Description.FaultBinding
System.Web.Services.Description.InputBinding
System.Web.Services.Description.OutputBinding
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
MessageBinding-Member
System.Web.Services.Description-Namespace