SoapBodyBinding 类

定义

表示添加到 InputBindingOutputBinding 的扩展性元素。

public ref class SoapBodyBinding : System::Web::Services::Description::ServiceDescriptionFormatExtension
[System.Web.Services.Configuration.XmlFormatExtension("body", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.InputBinding), typeof(System.Web.Services.Description.OutputBinding), typeof(System.Web.Services.Description.MimePart))]
public class SoapBodyBinding : System.Web.Services.Description.ServiceDescriptionFormatExtension
[<System.Web.Services.Configuration.XmlFormatExtension("body", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.InputBinding), typeof(System.Web.Services.Description.OutputBinding), typeof(System.Web.Services.Description.MimePart))>]
type SoapBodyBinding = class
    inherit ServiceDescriptionFormatExtension
Public Class SoapBodyBinding
Inherits ServiceDescriptionFormatExtension
继承
派生
属性

示例

#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;
int main()
{
   ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbersInput_cs.wsdl" );

   // Create a 'Binding' object for the 'SOAP' protocol.
   Binding^ myBinding = gcnew Binding;
   myBinding->Name = "Service1Soap";
   XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" );
   myBinding->Type = qualifiedName;

   SoapBinding^ mySoapBinding = gcnew SoapBinding;
   mySoapBinding->Transport = SoapBinding::HttpTransport;
   mySoapBinding->Style = SoapBindingStyle::Document;

   // Add the 'SoapBinding' object to the 'Binding' object.
   myBinding->Extensions->Add( mySoapBinding );

   // Create the 'OperationBinding' object for the 'SOAP' protocol.
   OperationBinding^ myOperationBinding = gcnew OperationBinding;
   myOperationBinding->Name = "AddNumbers";

   // Create the 'SoapOperationBinding' object for the 'SOAP' protocol.
   SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding;
   mySoapOperationBinding->SoapAction = "http://tempuri.org/AddNumbers";
   mySoapOperationBinding->Style = SoapBindingStyle::Document;

   // Add the 'SoapOperationBinding' object to 'OperationBinding' object.
   myOperationBinding->Extensions->Add( mySoapOperationBinding );

   // Create the 'InputBinding' object for the 'SOAP' protocol.
   InputBinding^ myInput = gcnew InputBinding;
   SoapBodyBinding^ mySoapBinding1 = gcnew SoapBodyBinding;
   mySoapBinding1->Use = SoapBindingUse::Literal;
   myInput->Extensions->Add( mySoapBinding1 );

   // Assign the 'InputBinding' to 'OperationBinding'.
   myOperationBinding->Input = myInput;

   // Create the 'OutputBinding' object' for the 'SOAP' protocol..
   OutputBinding^ myOutput = gcnew OutputBinding;
   myOutput->Extensions->Add( mySoapBinding1 );

   // Assign the 'OutPutBinding' to 'OperationBinding'.
   myOperationBinding->Output = myOutput;

   // Add the 'OperationBinding' to 'Binding'.
   myBinding->Operations->Add( myOperationBinding );

   // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
   myDescription->Bindings->Add( myBinding );
   Port^ soapPort = gcnew Port;
   soapPort->Name = "Service1Soap";
   soapPort->Binding = gcnew XmlQualifiedName( "s0:Service1Soap" );

   // Create a 'SoapAddressBinding' object for the 'SOAP' protocol.
   SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding;
   mySoapAddressBinding->Location = "http://localhost/AddNumbers.cs.asmx";

   // Add the 'SoapAddressBinding' to the 'Port'.
   soapPort->Extensions->Add( mySoapAddressBinding );

   // Add the 'Port' to 'PortCollection' of 'ServiceDescription'.
   myDescription->Services[ 0 ]->Ports->Add( soapPort );

   // Write the 'ServiceDescription' as a WSDL file.
   myDescription->Write( "AddNumbersOut_cs.wsdl" );
   Console::WriteLine( " 'AddNumbersOut_cs.Wsdl' file was generated" );
}

using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

   class MySoapClass
   {
      public static void Main()
      {
         ServiceDescription myDescription =
                     ServiceDescription.Read("AddNumbersInput_cs.wsdl");
         // Create a 'Binding' object for the 'SOAP' protocol.
         Binding myBinding = new Binding();
         myBinding.Name = "Service1Soap";
         XmlQualifiedName qualifiedName =
                     new XmlQualifiedName("s0:Service1Soap");
         myBinding.Type = qualifiedName;

         SoapBinding mySoapBinding = new SoapBinding();
         mySoapBinding.Transport = SoapBinding.HttpTransport;
         mySoapBinding.Style = SoapBindingStyle.Document;
         // Add the 'SoapBinding' object to the 'Binding' object.
         myBinding.Extensions.Add(mySoapBinding);

         // Create the 'OperationBinding' object for the 'SOAP' protocol.
         OperationBinding myOperationBinding = new OperationBinding();
         myOperationBinding.Name = "AddNumbers";

         // Create the 'SoapOperationBinding' object for the 'SOAP' protocol.
         SoapOperationBinding mySoapOperationBinding =
                                          new SoapOperationBinding();
         mySoapOperationBinding.SoapAction  = "http://tempuri.org/AddNumbers";
         mySoapOperationBinding.Style = SoapBindingStyle.Document;
         // Add the 'SoapOperationBinding' object to 'OperationBinding' object.
         myOperationBinding.Extensions.Add(mySoapOperationBinding);

         // Create the 'InputBinding' object for the 'SOAP' protocol.
         InputBinding myInput = new InputBinding();
         SoapBodyBinding mySoapBinding1 = new SoapBodyBinding();
         mySoapBinding1.Use= SoapBindingUse.Literal;
         myInput.Extensions.Add(mySoapBinding1);
         // Assign the 'InputBinding' to 'OperationBinding'.
         myOperationBinding.Input = myInput;
         // Create the 'OutputBinding' object' for the 'SOAP' protocol..
         OutputBinding myOutput = new OutputBinding();
         myOutput.Extensions.Add(mySoapBinding1);
          // Assign the 'OutPutBinding' to 'OperationBinding'.
         myOperationBinding.Output = myOutput;

         // Add the 'OperationBinding' to 'Binding'.
         myBinding.Operations.Add(myOperationBinding);

          // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
         myDescription.Bindings.Add(myBinding);

         Port soapPort = new Port();
         soapPort.Name = "Service1Soap";
         soapPort.Binding = new XmlQualifiedName("s0:Service1Soap");

         // Create a 'SoapAddressBinding' object for the 'SOAP' protocol.
         SoapAddressBinding mySoapAddressBinding =
                                       new SoapAddressBinding();
         mySoapAddressBinding.Location = "http://localhost/AddNumbers.cs.asmx";

         // Add the 'SoapAddressBinding' to the 'Port'.
         soapPort.Extensions.Add(mySoapAddressBinding);

         // Add the 'Port' to 'PortCollection' of 'ServiceDescription'.
         myDescription.Services[0].Ports.Add(soapPort);

         // Write the 'ServiceDescription' as a WSDL file.
         myDescription.Write("AddNumbersOut_cs.wsdl");
         Console.WriteLine(" 'AddNumbersOut_cs.Wsdl' file was generated");
    }
}
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MySoapClass
   Public Shared Sub Main()
      Dim myDescription As ServiceDescription = _
                     ServiceDescription.Read("AddNumbersInput_vb.wsdl")
      ' Create a 'Binding' object for the 'SOAP' protocol.
      Dim myBinding As New Binding()
      myBinding.Name = "Service1Soap"
      Dim qualifiedName As New XmlQualifiedName("s0:Service1Soap")
      myBinding.Type = qualifiedName

      Dim mySoapBinding As New SoapBinding()
      mySoapBinding.Transport = SoapBinding.HttpTransport
      mySoapBinding.Style = SoapBindingStyle.Document

      ' Add the 'SoapBinding' object to the 'Binding' object.
      myBinding.Extensions.Add(mySoapBinding)

      ' Create the 'OperationBinding' object for the 'SOAP' protocol.
      Dim myOperationBinding As New OperationBinding()
      myOperationBinding.Name = "AddNumbers"

      ' Create the 'SoapOperationBinding' object for the 'SOAP' protocol.
      Dim mySoapOperationBinding As New SoapOperationBinding()
      mySoapOperationBinding.SoapAction = "http://tempuri.org/AddNumbers"
      mySoapOperationBinding.Style = SoapBindingStyle.Document
      ' Add the 'SoapOperationBinding' object to 'OperationBinding' object.
      myOperationBinding.Extensions.Add(mySoapOperationBinding)

      ' Create the 'InputBinding' object for the 'SOAP' protocol.
      Dim myInput As New InputBinding()
      Dim mySoapBinding1 As New SoapBodyBinding()
      mySoapBinding1.Use = SoapBindingUse.Literal
      myInput.Extensions.Add(mySoapBinding1)
      ' Assign the 'InputBinding' to 'OperationBinding'.
      myOperationBinding.Input = myInput
      ' Create the 'OutputBinding' object' for the 'SOAP' protocol.
      Dim myOutput As New OutputBinding()
      myOutput.Extensions.Add(mySoapBinding1)
      ' Assign the 'OutPutBinding' to 'OperationBinding'.
      myOperationBinding.Output = myOutput

      ' Add the 'OperationBinding' to 'Binding'.
      myBinding.Operations.Add(myOperationBinding)

      ' Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
      myDescription.Bindings.Add(myBinding)

      Dim soapPort As New Port()
      soapPort.Name = "Service1Soap"
      soapPort.Binding = New XmlQualifiedName("s0:Service1Soap")

      ' Create a 'SoapAddressBinding' object for the 'SOAP' protocol.
      Dim mySoapAddressBinding As New SoapAddressBinding()
      mySoapAddressBinding.Location = "http://localhost/AddNumbers.vb.asmx"

      ' Add the 'SoapAddressBinding' to the 'Port'.
      soapPort.Extensions.Add(mySoapAddressBinding)

      ' Add the 'Port' to 'PortCollection' of 'ServiceDescription'.
      myDescription.Services(0).Ports.Add(soapPort)

      ' Write the 'ServiceDescription' as a WSDL file.
      myDescription.Write("AddNumbersOut_vb.wsdl")
      Console.WriteLine(" 'AddNumbersOut_vb.Wsdl' file was generated")
   End Sub
End Class

注解

此类指定消息(抽象类型定义或具体架构定义)如何出现在传输的 SOAP 正文元素中。

有关为 XML Web 服务指定协议的详细信息,请参阅使用 ASP.NET 的 XML Web 服务。 有关 Web 服务描述语言 (WSDL) 的详细信息,请参阅 WSDL 规范。

构造函数

SoapBodyBinding()

初始化 SoapBodyBinding 类的新实例。

属性

Encoding

获取或设置一个字符串,该字符串包含由空格分隔的 URI 的列表。 这些 URI 表示用来对 SOAP 体中的消息进行编码的编码样式。

Handled

获取或设置一个值,该值指示当导入扩展性元素时,导入进程是否使用 ServiceDescriptionFormatExtension

(继承自 ServiceDescriptionFormatExtension)
Namespace

获取或设置一个 URI,该 URI 表示 Encoding 属性未具体定义的内容编码规范的位置。

Parent

获取 ServiceDescriptionFormatExtension 的父级。

(继承自 ServiceDescriptionFormatExtension)
Parts

获取或设置一个值,该值指示传输的消息的哪些部分出现在该传输的 SOAP 体部分。

PartsString

获取或设置一个值,该值指示传输的消息的哪些部分出现在该传输的 SOAP 体部分。

Required

获取或设置一个值,该值指示 ServiceDescriptionFormatExtension 是否是它所引用的操作所必需的。

(继承自 ServiceDescriptionFormatExtension)
Use

指示消息部分是使用指定的编码规则进行编码还是定义消息的具体架构。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于