共用方式為


Binding.Operations 屬性

定義

取得在 XML Web Service 所支援的動作中使用的資料格式和訊息通訊協定的規格集合。

public:
 property System::Web::Services::Description::OperationBindingCollection ^ Operations { System::Web::Services::Description::OperationBindingCollection ^ get(); };
public System.Web.Services.Description.OperationBindingCollection Operations { get; }
member this.Operations : System.Web.Services.Description.OperationBindingCollection
Public ReadOnly Property Operations As OperationBindingCollection

屬性值

OperationBindingCollection

OperationBindingCollection 物件,包含在 XML Web 服務所支援的動作中使用的資料格式和訊息通訊協定的規格集合。

範例

下列範例示範 屬性的 Operations 一般用法。

// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( addOperationBinding );
OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( subtractOperationBinding );
OperationBinding^ multiplyOperationBinding = CreateOperationBinding( "Multiply", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( multiplyOperationBinding );
OperationBinding^ divideOperationBinding = CreateOperationBinding( "Divide", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( divideOperationBinding );
// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding addOperationBinding = CreateOperationBinding("Add",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(addOperationBinding);
OperationBinding subtractOperationBinding = CreateOperationBinding("Subtract",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(subtractOperationBinding);
OperationBinding multiplyOperationBinding = CreateOperationBinding("Multiply",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(multiplyOperationBinding);
OperationBinding divideOperationBinding = CreateOperationBinding("Divide",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(divideOperationBinding);
' Create OperationBindings for each of the operations defined in asmx file.
Dim addOperationBinding As OperationBinding = CreateOperationBinding("Add", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(addOperationBinding)
Dim subtractOperationBinding As OperationBinding = CreateOperationBinding("Subtract", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(subtractOperationBinding)
Dim multiplyOperationBinding As OperationBinding = CreateOperationBinding("Multiply", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(multiplyOperationBinding)
Dim divideOperationBinding As OperationBinding = CreateOperationBinding("Divide", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(divideOperationBinding)
   // Used to create OperationBinding instances within 'Binding'.
public:
   static OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace )
   {
      // Create OperationBinding instance for operation.
      OperationBinding^ myOperationBinding = gcnew OperationBinding;
      myOperationBinding->Name = operation;
      // Create InputBinding for operation.
      InputBinding^ myInputBinding = gcnew InputBinding;
      SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding;
      mySoapBodyBinding->Use = SoapBindingUse::Literal;
      myInputBinding->Extensions->Add( mySoapBodyBinding );
      // Create OutputBinding for operation.
      OutputBinding^ myOutputBinding = gcnew OutputBinding;
      myOutputBinding->Extensions->Add( mySoapBodyBinding );
      // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
      myOperationBinding->Input = myInputBinding;
      myOperationBinding->Output = myOutputBinding;
      // Create extensibility element for 'SoapOperationBinding'.
      SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding;
      mySoapOperationBinding->Style = SoapBindingStyle::Document;
      mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, operation );
      // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'.
      myOperationBinding->Extensions->Add( mySoapOperationBinding );
      return myOperationBinding;
   }
// Used to create OperationBinding instances within 'Binding'.
public static OperationBinding CreateOperationBinding(string operation,string targetNamespace)
{
   // Create OperationBinding instance for operation.
   OperationBinding myOperationBinding = new OperationBinding();
   myOperationBinding.Name = operation;
   // Create InputBinding for operation.
   InputBinding myInputBinding = new InputBinding();
   SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
   mySoapBodyBinding.Use = SoapBindingUse.Literal;
   myInputBinding.Extensions.Add(mySoapBodyBinding);
   // Create OutputBinding for operation.
   OutputBinding myOutputBinding = new OutputBinding();
   myOutputBinding.Extensions.Add(mySoapBodyBinding);
   // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
   myOperationBinding.Input = myInputBinding;
   myOperationBinding.Output = myOutputBinding;
   // Create extensibility element for 'SoapOperationBinding'.
   SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();
   mySoapOperationBinding.Style = SoapBindingStyle.Document;
   mySoapOperationBinding.SoapAction = targetNamespace + operation;
   // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'.
   myOperationBinding.Extensions.Add(mySoapOperationBinding);
   return myOperationBinding;
}
' Used to create OperationBinding instances within 'Binding'.
Public Shared Function CreateOperationBinding(operation As String, targetNamespace As String) As OperationBinding
   ' Create OperationBinding instance for operation.
   Dim myOperationBinding As New OperationBinding()
   myOperationBinding.Name = operation
   ' Create InputBinding for operation.
   Dim myInputBinding As New InputBinding()
   Dim mySoapBodyBinding As New SoapBodyBinding()
   mySoapBodyBinding.Use = SoapBindingUse.Literal
   myInputBinding.Extensions.Add(mySoapBodyBinding)
   ' Create OutputBinding for operation.
   Dim myOutputBinding As New OutputBinding()
   myOutputBinding.Extensions.Add(mySoapBodyBinding)
   ' Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. 
   myOperationBinding.Input = myInputBinding
   myOperationBinding.Output = myOutputBinding
   ' Create extensibility element for 'SoapOperationBinding'.
   Dim mySoapOperationBinding As New SoapOperationBinding()
   mySoapOperationBinding.Style = SoapBindingStyle.Document
   mySoapOperationBinding.SoapAction = targetNamespace + operation
   ' Add extensibility element 'SoapOperationBinding' to 'OperationBinding'.
   myOperationBinding.Extensions.Add(mySoapOperationBinding)
   Return myOperationBinding
End Function 'CreateOperationBinding

適用於