SoapBinding クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)


このクラスは、データ伝送に SOAP プロトコル Version 1.1 を使用することを指定します。
XML Web サービスのプロトコルの指定の詳細については、「ASP.NET を使用した XML Web サービス」を参照してください。WSDL (Web Services Description Language) の詳細については、http://www.w3.org/TR/wsdl/ の仕様を参照してください。

Imports System 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 'Main End Class 'MySoapClass
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"); } }
#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" ); }
import System.*; import System.Web.Services.Description.*; import System.Collections.*; import System.Xml.*; class MySoapClass { public static void main(String[] args) { ServiceDescription myDescription = ServiceDescription.Read("AddNumbersInput_jsl.wsdl"); // Create a 'Binding' object for the 'SOAP' protocol. Binding myBinding = new Binding(); myBinding.set_Name("Service1Soap"); XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1Soap"); myBinding.set_Type(qualifiedName); SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.set_Transport(SoapBinding.HttpTransport); mySoapBinding.set_Style(SoapBindingStyle.Document); // Add the 'SoapBinding' object to the 'Binding' object. myBinding.get_Extensions().Add(mySoapBinding); // Create the 'OperationBinding' object for the 'SOAP' protocol. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.set_Name("AddNumbers"); // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.set_SoapAction("http://tempuri.org/AddNumbers"); mySoapOperationBinding.set_Style(SoapBindingStyle.Document); // Add the 'SoapOperationBinding' object to 'OperationBinding' object. myOperationBinding.get_Extensions().Add(mySoapOperationBinding); // Create the 'InputBinding' object for the 'SOAP' protocol. InputBinding myInput = new InputBinding(); SoapBodyBinding mySoapBinding1 = new SoapBodyBinding(); mySoapBinding1.set_Use(SoapBindingUse.Literal); myInput.get_Extensions().Add(mySoapBinding1); // Assign the 'InputBinding' to 'OperationBinding'. myOperationBinding.set_Input(myInput); // Create the 'OutputBinding' object' for the 'SOAP' protocol.. OutputBinding myOutput = new OutputBinding(); myOutput.get_Extensions().Add(mySoapBinding1); // Assign the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.set_Output(myOutput); // Add the 'OperationBinding' to 'Binding'. myBinding.get_Operations().Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.get_Bindings().Add(myBinding); Port soapPort = new Port(); soapPort.set_Name("Service1Soap"); soapPort.set_Binding(new XmlQualifiedName("s0:Service1Soap")); // Create a 'SoapAddressBinding' object for the 'SOAP' protocol. SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding(); mySoapAddressBinding.set_Location("http://localhost/AddNumbers.jsl.asmx"); // Add the 'SoapAddressBinding' to the 'Port'. soapPort.get_Extensions().Add(mySoapAddressBinding); // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.get_Services().get_Item(0).get_Ports().Add(soapPort); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("AddNumbersOut_jsl.wsdl"); Console.WriteLine(" 'AddNumbersOut_jsl.Wsdl' file was generated"); } //main } //MySoapClass

System.Web.Services.Description.ServiceDescriptionFormatExtension
System.Web.Services.Description.SoapBinding
System.Web.Services.Description.Soap12Binding


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SoapBinding クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)


SOAP バインディングは、XML Web サービス用のインターフェイスに似ています。バージョン管理や特定の SOAP バインディングを実装している XML Web サービスの検索に役立ちます。たとえば、探索ドキュメントは SOAP バインディングに関するオプション情報を含んでおり、このオプション情報により参照先の Web サービスが実装している SOAP バインディングを指定します。SOAP バインディングは、Namespace 定数と等しい XML 名前空間を持つ SOAP XML 要素を追加することにより、探索ドキュメント内に含まれている XML ドキュメント内で指定されます。Address プロパティは XML Web サービスの URL を指定し、Binding プロパティは XML Web サービスが実装している SOAP バインディングを指定します。

Imports System Imports System.Net Imports System.Security.Permissions Imports System.Xml Imports System.Web.Services.Discovery Class DiscoverySoapBindingMod Shared Sub Main() Run() End Sub 'Main <PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _ Shared Sub Run() Try ' 'dataservice.disco' is a sample discovery document. Dim myStringUrl As String = "http://localhost/dataservice.disco" ' Call the Discover method to populate the Documents property. Dim myDiscoveryClientProtocol As DiscoveryClientProtocol = _ New DiscoveryClientProtocol() myDiscoveryClientProtocol.Credentials = _ CredentialCache.DefaultCredentials Dim myDiscoveryDocument As DiscoveryDocument = _ myDiscoveryClientProtocol.Discover(myStringUrl) Console.WriteLine("Demonstrating the Discovery.SoapBinding class.") ' Create a SOAP binding. Dim mySoapBinding As SoapBinding = New SoapBinding() ' Assign the address to the SOAP binding. mySoapBinding.Address = "http://schemas.xmlsoap.org/disco/scl/" ' Bind the created SOAP binding with a new XmlQualifiedName. mySoapBinding.Binding = New XmlQualifiedName("string", _ "http://www.w3.org/2001/XMLSchema") ' Add the created SOAP binding to the DiscoveryClientProtocol. myDiscoveryClientProtocol.AdditionalInformation.Add(mySoapBinding) ' Display the namespace associated with the SOAP binding. Console.WriteLine("Namespace associated with Soap Binding is: " _ + SoapBinding.Namespace) ' Write all the information of the DiscoveryClientProtocol. myDiscoveryClientProtocol.WriteAll(".","results.discomap") Catch e As Exception Console.WriteLine(e.ToString) End Try End Sub 'Run End Class
using System; using System.Net; using System.Security.Permissions; using System.Xml; using System.Web.Services.Discovery; class DiscoverySoapBindingClass { static void Main() { Run(); } [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")] static void Run() { try { // 'dataservice.disco' is a sample discovery document. string myStringUrl = "http://localhost/dataservice.disco"; // Call the Discover method to populate the Documents property. DiscoveryClientProtocol myDiscoveryClientProtocol = new DiscoveryClientProtocol(); myDiscoveryClientProtocol.Credentials = CredentialCache.DefaultCredentials; DiscoveryDocument myDiscoveryDocument = myDiscoveryClientProtocol.Discover(myStringUrl); Console.WriteLine("Demonstrating the Discovery.SoapBinding class."); // Create a SOAP binding. SoapBinding mySoapBinding = new SoapBinding(); // Assign an address to the created SOAP binding. mySoapBinding.Address = "http://schemas.xmlsoap.org/disco/scl/"; // Bind the created SOAP binding with a new XmlQualifiedName. mySoapBinding.Binding = new XmlQualifiedName("string" , "http://www.w3.org/2001/XMLSchema"); // Add the created SOAP binding to the DiscoveryClientProtocol. myDiscoveryClientProtocol.AdditionalInformation.Add(mySoapBinding); // Display the namespace associated with SOAP binding. Console.WriteLine("Namespace associated with the SOAP binding is: " + SoapBinding.Namespace); // Write all the information of the DiscoveryClientProtocol. myDiscoveryClientProtocol.WriteAll(".","results.discomap"); } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
#using <System.dll> #using <System.Xml.dll> #using <System.Web.Services.dll> using namespace System; using namespace System::Net; using namespace System::Xml; using namespace System::Web::Services::Discovery; int main() { try { // 'dataservice.disco' is a sample discovery document. String^ myStringUrl = "http://localhost/dataservice.disco"; // Call the Discover method to populate the Documents property. DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myStringUrl ); Console::WriteLine( "Demonstrating the Discovery::SoapBinding class." ); // Create a SOAP binding. SoapBinding^ mySoapBinding = gcnew SoapBinding; // Assign an address to the created SOAP binding. mySoapBinding->Address = "http://schemas.xmlsoap.org/disco/scl/"; // Bind the created SOAP binding with a new XmlQualifiedName. mySoapBinding->Binding = gcnew XmlQualifiedName( "String*","http://www.w3.org/2001/XMLSchema" ); // Add the created SOAP binding to the DiscoveryClientProtocol. myDiscoveryClientProtocol->AdditionalInformation->Add( mySoapBinding ); // Display the namespace associated with SOAP binding. Console::WriteLine( "Namespace associated with the SOAP binding is: {0}", SoapBinding::Namespace ); // Write all the information of the DiscoveryClientProtocol. myDiscoveryClientProtocol->WriteAll( ".", "results.discomap" ); } catch ( Exception^ e ) { Console::WriteLine( e ); } }

System.Web.Services.Discovery.SoapBinding


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapBinding クラスのページへのリンク