Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SoapBinding Class

Represents an extension added to a Binding within an XML Web service. This class cannot be inherited.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
public class SoapBinding : ServiceDescriptionFormatExtension
public class SoapBinding extends ServiceDescriptionFormatExtension
public class SoapBinding extends ServiceDescriptionFormatExtension
Not applicable.

This class specifies that the data transmission will use the SOAP protocol version 1.1.

For more information about specifying protocols for XML Web services, see XML Web Services Using ASP.NET. For more information about Web Services Description Language (WSDL), see the specification at http://www.w3.org/TR/wsdl/.


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");
    }
}

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.