当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET OperationBindingCollection类代码示例

本文整理汇总了VB.NET中System.Web.Services.Description.OperationBindingCollection的典型用法代码示例。如果您正苦于以下问题:VB.NET OperationBindingCollection类的具体用法?VB.NET OperationBindingCollection怎么用?VB.NET OperationBindingCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OperationBindingCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: MyOperationBindingCollectionSample

' 导入命名空间
Imports System.Web.Services.Description

Class MyOperationBindingCollectionSample

   Shared Sub Main()
      Try
         Dim myServiceDescription As ServiceDescription = _
            ServiceDescription.Read("MathService_input_vb.wsdl")

         ' Add the OperationBinding for the Add operation.
         Dim addOperationBinding As New OperationBinding()
         Dim addOperation As String = "Add"
         Dim myTargetNamespace As String = myServiceDescription.TargetNamespace
         addOperationBinding.Name = addOperation

         ' Add the InputBinding for the operation.
         Dim myInputBinding As New InputBinding()
         Dim mySoapBodyBinding As New SoapBodyBinding()
         mySoapBodyBinding.Use = SoapBindingUse.Literal
         myInputBinding.Extensions.Add(mySoapBodyBinding)
         addOperationBinding.Input = myInputBinding

         ' Add the OutputBinding for the operation.
         Dim myOutputBinding As New OutputBinding()
         myOutputBinding.Extensions.Add(mySoapBodyBinding)
         addOperationBinding.Output = myOutputBinding

         ' Add the extensibility element for the SoapOperationBinding.
         Dim mySoapOperationBinding As New SoapOperationBinding()
         mySoapOperationBinding.Style = SoapBindingStyle.Document
         mySoapOperationBinding.SoapAction = myTargetNamespace & addOperation
         addOperationBinding.Extensions.Add(mySoapOperationBinding)

         ' 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

         ' Check for the Add OperationBinding in the collection.
         Dim contains As Boolean = _
            myOperationBindingCollection.Contains(addOperationBinding)
         Console.WriteLine(ControlChars.NewLine & _
            "Whether the collection contains the Add " & _
            "OperationBinding : " & contains.ToString())

         ' Add the Add OperationBinding to the collection.
         myOperationBindingCollection.Add(addOperationBinding)
         Console.WriteLine(ControlChars.NewLine & _
            "Added the OperationBinding of the Add " & _
            "operation to the collection.")

         ' Get the OperationBinding of the Add operation from the collection.
         Dim myOperationBinding As OperationBinding = _
            myOperationBindingCollection(3)

         ' Remove the OperationBinding of the 'Add' operation from
         ' the collection.
         myOperationBindingCollection.Remove(myOperationBinding)
         Console.WriteLine(ControlChars.NewLine & _
            "Removed the OperationBinding of the " & _
            "Add operation from the collection.")
         ' Insert the OperationBinding of the Add operation at index 0.
         myOperationBindingCollection.Insert(0, addOperationBinding)
         Console.WriteLine(ControlChars.NewLine & _
            "Inserted the OperationBinding of the " & _
            "Add operation in the collection.")

         ' Get the index of the OperationBinding of the Add
         ' operation from the collection.
         Dim index As Integer = myOperationBindingCollection.IndexOf( _
            addOperationBinding)
         Console.WriteLine(ControlChars.NewLine & _
            "The index of the OperationBinding of the " & _
            "Add operation : " & index.ToString())
         Console.WriteLine("")

         Dim operationBindingArray(myOperationBindingCollection.Count -1  ) _
            As OperationBinding

         ' Copy this collection to the OperationBinding array.
         myOperationBindingCollection.CopyTo(operationBindingArray, 0)
         Console.WriteLine("The operations supported by this service " & _
            "are :")
         Dim myOperationBinding1 As OperationBinding
         For Each myOperationBinding1 In  operationBindingArray
            Dim myBinding As Binding = myOperationBinding1.Binding
            Console.WriteLine(" Binding : " & myBinding.Name & " Name of " & _
               "operation : " & myOperationBinding1.Name)
         Next myOperationBinding1

         ' Save the ServiceDescription 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
开发者ID:VB.NET开发者,项目名称:System.Web.Services.Description,代码行数:104,代码来源:OperationBindingCollection


注:本文中的System.Web.Services.Description.OperationBindingCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。