OperationBinding Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Fournit des spécifications pour des protocoles et des formats de données de message utilisés dans l'action prise en charge par le service Web XML. Cette classe ne peut pas être héritée.
public ref class OperationBinding sealed : System::Web::Services::Description::DocumentableItem
public ref class OperationBinding sealed : System::Web::Services::Description::NamedItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class OperationBinding : System.Web.Services.Description.DocumentableItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class OperationBinding : System.Web.Services.Description.NamedItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type OperationBinding = class
inherit DocumentableItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type OperationBinding = class
inherit NamedItem
Public NotInheritable Class OperationBinding
Inherits DocumentableItem
Public NotInheritable Class OperationBinding
Inherits NamedItem
- Héritage
- Héritage
- Attributs
Exemples
L’exemple suivant illustre l’utilisation des propriétés et des méthodes exposées par la OperationBinding
classe. Il prend une prise en charge existante ServiceDescription et ajoute la prise en charge du protocole SOAP.
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
int main()
{
try
{
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" );
String^ myTargetNamespace = myServiceDescription->TargetNamespace;
// Create an OperationBinding for the Add operation.
OperationBinding^ addOperationBinding = gcnew OperationBinding;
String^ addOperation = "Add";
addOperationBinding->Name = addOperation;
// Create an InputBinding for the Add operation.
InputBinding^ myInputBinding = gcnew InputBinding;
SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding;
mySoapBodyBinding->Use = SoapBindingUse::Literal;
myInputBinding->Extensions->Add( mySoapBodyBinding );
// Add the InputBinding to the OperationBinding.
addOperationBinding->Input = myInputBinding;
// Create an OutputBinding for the Add operation.
OutputBinding^ myOutputBinding = gcnew OutputBinding;
myOutputBinding->Extensions->Add( mySoapBodyBinding );
// Add the OutputBinding to the OperationBinding.
addOperationBinding->Output = myOutputBinding;
// Create an extensibility element for a SoapOperationBinding.
SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding;
mySoapOperationBinding->Style = SoapBindingStyle::Document;
mySoapOperationBinding->SoapAction = String::Concat( myTargetNamespace, addOperation );
// Add the extensibility element SoapOperationBinding to
// the OperationBinding.
addOperationBinding->Extensions->Add( mySoapOperationBinding );
ServiceDescriptionFormatExtensionCollection^ myExtensions;
// Get the FaultBindingCollection from the OperationBinding.
FaultBindingCollection^ myFaultBindingCollection = addOperationBinding->Faults;
FaultBinding^ myFaultBinding = gcnew FaultBinding;
myFaultBinding->Name = "ErrorFloat";
// Associate SOAP fault binding to the fault binding of the operation.
myExtensions = myFaultBinding->Extensions;
SoapFaultBinding^ mySoapFaultBinding = gcnew SoapFaultBinding;
mySoapFaultBinding->Use = SoapBindingUse::Literal;
mySoapFaultBinding->Namespace = myTargetNamespace;
myExtensions->Add( mySoapFaultBinding );
myFaultBindingCollection->Add( myFaultBinding );
// Get the BindingCollection from the ServiceDescription.
BindingCollection^ myBindingCollection = myServiceDescription->Bindings;
// Get the OperationBindingCollection of SOAP binding
// from the BindingCollection.
OperationBindingCollection^ myOperationBindingCollection = myBindingCollection[ 0 ]->Operations;
myOperationBindingCollection->Add( addOperationBinding );
Console::WriteLine( "The operations supported by this service are:" );
System::Collections::IEnumerator^ myEnum = myOperationBindingCollection->GetEnumerator();
while ( myEnum->MoveNext() )
{
OperationBinding^ myOperationBinding = safe_cast<OperationBinding^>(myEnum->Current);
Binding^ myBinding = myOperationBinding->Binding;
Console::WriteLine( " Binding : {0} :: Name of operation : {1}", myBinding->Name, myOperationBinding->Name );
FaultBindingCollection^ myFaultBindingCollection1 = myOperationBinding->Faults;
System::Collections::IEnumerator^ myEnum1 = myFaultBindingCollection1->GetEnumerator();
while ( myEnum1->MoveNext() )
{
FaultBinding^ myFaultBinding1 = safe_cast<FaultBinding^>(myEnum1->Current);
Console::WriteLine( " Fault : {0}", myFaultBinding1->Name );
}
}
myServiceDescription->Write( "MathService_new_cs.wsdl" );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception caught!!!" );
Console::WriteLine( "Source : {0}", e->Source );
Console::WriteLine( "Message : {0}", e->Message );
}
}
using System;
using System.Web.Services.Description;
class MyOperationBindingSample
{
static void Main()
{
try
{
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathService_input_cs.wsdl");
string myTargetNamespace = myServiceDescription.TargetNamespace;
// Create an OperationBinding for the Add operation.
OperationBinding addOperationBinding = new OperationBinding();
string addOperation = "Add";
addOperationBinding.Name = addOperation;
// Create an InputBinding for the Add operation.
InputBinding myInputBinding = new InputBinding();
SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
mySoapBodyBinding.Use = SoapBindingUse.Literal;
myInputBinding.Extensions.Add(mySoapBodyBinding);
// Add the InputBinding to the OperationBinding.
addOperationBinding.Input = myInputBinding;
// Create an OutputBinding for the Add operation.
OutputBinding myOutputBinding = new OutputBinding();
myOutputBinding.Extensions.Add(mySoapBodyBinding);
// Add the OutputBinding to the OperationBinding.
addOperationBinding.Output = myOutputBinding;
// Create an extensibility element for a SoapOperationBinding.
SoapOperationBinding mySoapOperationBinding =
new SoapOperationBinding();
mySoapOperationBinding.Style = SoapBindingStyle.Document;
mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation;
// Add the extensibility element SoapOperationBinding to
// the OperationBinding.
addOperationBinding.Extensions.Add(mySoapOperationBinding);
ServiceDescriptionFormatExtensionCollection myExtensions;
// Get the FaultBindingCollection from the OperationBinding.
FaultBindingCollection myFaultBindingCollection =
addOperationBinding.Faults;
FaultBinding myFaultBinding = new FaultBinding();
myFaultBinding.Name = "ErrorFloat";
// Associate SOAP fault binding to the fault binding of the operation.
myExtensions = myFaultBinding.Extensions;
SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding();
mySoapFaultBinding.Use = SoapBindingUse.Literal;
mySoapFaultBinding.Namespace = myTargetNamespace;
myExtensions.Add(mySoapFaultBinding);
myFaultBindingCollection.Add(myFaultBinding);
// Get the BindingCollection from the ServiceDescription.
BindingCollection myBindingCollection =
myServiceDescription.Bindings;
// Get the OperationBindingCollection of SOAP binding
// from the BindingCollection.
OperationBindingCollection myOperationBindingCollection =
myBindingCollection[0].Operations;
myOperationBindingCollection.Add(addOperationBinding);
Console.WriteLine(
"The operations supported by this service are:");
foreach(OperationBinding myOperationBinding in
myOperationBindingCollection)
{
Binding myBinding = myOperationBinding.Binding;
Console.WriteLine(" Binding : " + myBinding.Name +
" :: Name of operation : " + myOperationBinding.Name);
FaultBindingCollection myFaultBindingCollection1 =
myOperationBinding.Faults;
foreach(FaultBinding myFaultBinding1 in
myFaultBindingCollection1)
{
Console.WriteLine(" Fault : " + myFaultBinding1.Name);
}
}
// Save the ServiceDescription to an external file.
myServiceDescription.Write("MathService_new_cs.wsdl");
}
catch(Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
}
}
Imports System.Web.Services.Description
Class MyOperationBindingSample
Shared Sub Main()
Try
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("MathService_input_vb.wsdl")
Dim myTargetNamespace As String = _
myServiceDescription.TargetNamespace
' Create an OperationBinding for the Add operation.
Dim addOperationBinding As New OperationBinding()
Dim addOperation As String = "Add"
addOperationBinding.Name = addOperation
' Create an InputBinding for the Add operation.
Dim myInputBinding As New InputBinding()
Dim mySoapBodyBinding As New SoapBodyBinding()
mySoapBodyBinding.Use = SoapBindingUse.Literal
myInputBinding.Extensions.Add(mySoapBodyBinding)
' Add the InputBinding to the OperationBinding.
addOperationBinding.Input = myInputBinding
' Create an OutputBinding for the Add operation.
Dim myOutputBinding As New OutputBinding()
myOutputBinding.Extensions.Add(mySoapBodyBinding)
' Add the OutputBinding to the OperationBinding.
addOperationBinding.Output = myOutputBinding
' Create an extensibility element for a SoapOperationBinding.
Dim mySoapOperationBinding As New SoapOperationBinding()
mySoapOperationBinding.Style = SoapBindingStyle.Document
mySoapOperationBinding.SoapAction = myTargetNamespace & addOperation
' Add the extensibility element SoapOperationBinding to
' the OperationBinding.
addOperationBinding.Extensions.Add(mySoapOperationBinding)
Dim myExtensions As ServiceDescriptionFormatExtensionCollection
' Get the FaultBindingCollection from the OperationBinding.
Dim myFaultBindingCollection As FaultBindingCollection = _
addOperationBinding.Faults
Dim myFaultBinding As New FaultBinding()
myFaultBinding.Name = "ErrorFloat"
' Associate SOAP fault binding to the fault binding of the operation.
myExtensions = myFaultBinding.Extensions
Dim mySoapFaultBinding As New SoapFaultBinding()
mySoapFaultBinding.Use = SoapBindingUse.Literal
mySoapFaultBinding.Namespace = myTargetNamespace
myExtensions.Add(mySoapFaultBinding)
myFaultBindingCollection.Add(myFaultBinding)
' Get the BindingCollection from the ServiceDescription.
Dim myBindingCollection As BindingCollection = _
myServiceDescription.Bindings
' Get the OperationBindingCollection of SOAP binding
' from the BindingCollection.
Dim myOperationBindingCollection As OperationBindingCollection = _
myBindingCollection(0).Operations
myOperationBindingCollection.Add(addOperationBinding)
Console.WriteLine( _
"The operations supported by this service are:")
Dim myOperationBinding As OperationBinding
For Each myOperationBinding In myOperationBindingCollection
Dim myBinding As Binding = myOperationBinding.Binding
Console.WriteLine(" Binding : " & myBinding.Name & _
" :: Name of operation : " & myOperationBinding.Name)
Dim myFaultBindingCollection1 As FaultBindingCollection = _
myOperationBinding.Faults
Dim myFaultBinding1 As FaultBinding
For Each myFaultBinding1 In myFaultBindingCollection1
Console.WriteLine(" Fault : " & myFaultBinding1.Name)
Next myFaultBinding1
Next myOperationBinding
' Save the ServiceDescripition to an external file.
myServiceDescription.Write("MathService_new_vb.wsdl")
Catch e As Exception
Console.WriteLine("Exception caught!!!")
Console.WriteLine("Source : " & e.Source.ToString())
Console.WriteLine("Message : " & e.Message.ToString())
End Try
End Sub
End Class
Remarques
La OperationBinding
classe correspond à l’élément WSDL (Web Services Description Language) <operation>
placé entre l’élément <binding>
, qui correspond à son tour à la Binding classe. Pour plus d’informations sur WSDL, consultez la spécification WSDL.
Constructeurs
OperationBinding() |
Initialise une nouvelle instance de la classe OperationBinding. |
Propriétés
Binding |
Obtient Binding dont OperationBinding en cours est membre. |
Documentation |
Obtient ou définit la documentation pour l'instance de DocumentableItem. (Hérité de DocumentableItem) |
DocumentationElement |
Obtient ou définit l'élément documentation pour DocumentableItem. (Hérité de DocumentableItem) |
ExtensibleAttributes |
Obtient ou définit un tableau de type XmlAttribute qui représente des extensions d'attribut de WSDL pour se conformer au Basic Profile 1.1 du WS-I (Web Services Interoperability). (Hérité de DocumentableItem) |
Extensions |
Obtient la collection d'éléments d'extensibilité spécifique au OperationBinding en cours. |
Faults |
Obtient FaultBindingCollection associé à l'instance de OperationBinding. |
Input |
Obtient ou définit le InputBinding associé à OperationBinding. |
Name |
Obtient ou définit le nom de l'objet OperationBinding. |
Name |
Obtient ou définit le nom de l'élément. (Hérité de NamedItem) |
Namespaces |
Obtient ou définit le dictionnaire de préfixes d'espace de noms et d'espaces de noms utilisé pour conserver des préfixes d'espace de noms et des espaces de noms lorsqu'un objet ServiceDescription est construit. (Hérité de DocumentableItem) |
Output |
Obtient ou définit le OutputBinding associé à OperationBinding. |
Méthodes
Equals(Object) |
Détermine si l'objet spécifié est égal à l'objet actuel. (Hérité de Object) |
GetHashCode() |
Fait office de fonction de hachage par défaut. (Hérité de Object) |
GetType() |
Obtient le Type de l'instance actuelle. (Hérité de Object) |
MemberwiseClone() |
Crée une copie superficielle du Object actuel. (Hérité de Object) |
ToString() |
Retourne une chaîne qui représente l'objet actuel. (Hérité de Object) |