SoapBinding Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Предоставляет расширение, добавляемое в Binding веб-службы XML. Этот класс не наследуется.
public ref class SoapBinding : System::Web::Services::Description::ServiceDescriptionFormatExtension
[System.Web.Services.Configuration.XmlFormatExtension("binding", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.Binding))]
[System.Web.Services.Configuration.XmlFormatExtensionPrefix("soap", "http://schemas.xmlsoap.org/wsdl/soap/")]
[System.Web.Services.Configuration.XmlFormatExtensionPrefix("soapenc", "http://schemas.xmlsoap.org/soap/encoding/")]
public class SoapBinding : System.Web.Services.Description.ServiceDescriptionFormatExtension
[<System.Web.Services.Configuration.XmlFormatExtension("binding", "http://schemas.xmlsoap.org/wsdl/soap/", typeof(System.Web.Services.Description.Binding))>]
[<System.Web.Services.Configuration.XmlFormatExtensionPrefix("soap", "http://schemas.xmlsoap.org/wsdl/soap/")>]
[<System.Web.Services.Configuration.XmlFormatExtensionPrefix("soapenc", "http://schemas.xmlsoap.org/soap/encoding/")>]
type SoapBinding = class
inherit ServiceDescriptionFormatExtension
Public Class SoapBinding
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 версии 1.1.
Дополнительные сведения об указании протоколов для веб-служб XML см. в разделе Xml Web Services Using ASP.NET. Дополнительные сведения о языке описания веб-служб (WSDL) см. в спецификации WSDL .
Конструкторы
SoapBinding() |
Инициализирует экземпляр класса SoapBinding. |
Поля
HttpTransport |
Получает URI для стандартного протокола, задающего передачу HTTP данных SOAP. Это поле является константой. |
Namespace |
Получает URI для пространства имен XML класса SoapBinding . Это поле является константой. |
Свойства
Handled |
Возвращает или задает значение, показывающее, используется ли объект ServiceDescriptionFormatExtension при импорте элемента расширения среды. (Унаследовано от ServiceDescriptionFormatExtension) |
Parent |
Возвращает родительский класс класса ServiceDescriptionFormatExtension. (Унаследовано от ServiceDescriptionFormatExtension) |
Required |
Возвращает или задает значение, показывающее, является ли класс ServiceDescriptionFormatExtension необходимым для действия, к которому он относится. (Унаследовано от ServiceDescriptionFormatExtension) |
Schema |
Возвращает схему привязки, которая должна использоваться для передачи данных с использованием протокола SOAP версии 1.1. |
Style |
Задает тип привязки SOAP, используемого текущим SoapBinding . |
Transport |
Возвращает или устанавливает URI со спецификацией для передачи HTTP данных SOAP. |
Методы
Equals(Object) |
Определяет, равен ли указанный объект текущему объекту. (Унаследовано от Object) |
GetHashCode() |
Служит хэш-функцией по умолчанию. (Унаследовано от Object) |
GetType() |
Возвращает объект Type для текущего экземпляра. (Унаследовано от Object) |
MemberwiseClone() |
Создает неполную копию текущего объекта Object. (Унаследовано от Object) |
ToString() |
Возвращает строку, представляющую текущий объект. (Унаследовано от Object) |