Export (0) Print
Expand All

ServiceDescriptionBaseCollection Class

Forms the basis for the strongly typed collections that are members of the System.Web.Services.Description namespace.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

public abstract class ServiceDescriptionBaseCollection : CollectionBase
public abstract class ServiceDescriptionBaseCollection extends CollectionBase
public abstract class ServiceDescriptionBaseCollection extends CollectionBase
Not applicable.

public static void MyMethod(
   ServiceDescriptionBaseCollection myServiceCollection)
{
   Type myType = myServiceCollection.GetType();
   if (myType.Equals(
      typeof(System.Web.Services.Description.ServiceCollection)))
   {
      // Remove the services at index 0 of the collection.
      ((ServiceCollection)myServiceCollection).Remove(
         myServiceDescription.Services[0]);

      // Build a new Service.
      Service myService =new Service();
      myService.Name="MathService";
      XmlQualifiedName myXmlQualifiedName = 
         new XmlQualifiedName("s0:MathServiceSoap");

      // Build a new Port for SOAP.
      Port mySoapPort= new Port();
      mySoapPort.Name="MathServiceSoap";
      mySoapPort.Binding=myXmlQualifiedName;
      SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
      mySoapAddressBinding.Location = "http://localhost/" +
         "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      mySoapPort.Extensions.Add(mySoapAddressBinding);

      // Build a new Port for HTTP-GET.
      XmlQualifiedName myXmlQualifiedName2 = 
         new XmlQualifiedName("s0:MathServiceHttpGet");
      Port myHttpGetPort= new Port();
      myHttpGetPort.Name="MathServiceHttpGet";
      myHttpGetPort.Binding=myXmlQualifiedName2;
      HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
      myHttpAddressBinding.Location = "http://localhost/" + 
         "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      myHttpGetPort.Extensions.Add(myHttpAddressBinding);

      // Add the ports to the Service.
      myService.Ports.Add(myHttpGetPort);
      myService.Ports.Add(mySoapPort);

      // Add the Service to the ServiceCollection.
      myServiceDescription.Services.Add(myService);
   }
   else if(myType.Equals(
      typeof(System.Web.Services.Description.BindingCollection)))
   {
      // Remove the Binding in the BindingCollection at index 0.
      ((BindingCollection)myServiceCollection).Remove(
         myServiceDescription.Bindings[0]);

      // Build a new Binding.
      Binding myBinding = new Binding();
      myBinding.Name = "MathServiceSoap";
      XmlQualifiedName myXmlQualifiedName = 
         new XmlQualifiedName("s0:MathServiceSoap");
      myBinding.Type=myXmlQualifiedName;
      SoapBinding mySoapBinding = new SoapBinding();
      mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
      mySoapBinding.Style = SoapBindingStyle.Document;

      // Create the operations for the binding.
      OperationBinding addOperationBinding = CreateOperationBinding(
         "Add", myServiceDescription.TargetNamespace);
      OperationBinding subtractOperationBinding = CreateOperationBinding(
         "Subtract",myServiceDescription.TargetNamespace);

      // Add the operations to the Binding.
      myBinding.Operations.Add(subtractOperationBinding);
      myBinding.Operations.Add(addOperationBinding);
      myBinding.Extensions.Add(mySoapBinding);

      // Add the Binding to the Bindings collection.
      myServiceDescription.Bindings.Add(myBinding);
   }
   else if (myType.Equals(
      typeof(System.Web.Services.Description.PortTypeCollection)))
   {
      // Remove the PortType at index 0.
      ((PortTypeCollection)myServiceCollection).Remove(
         myServiceDescription.PortTypes[0]);

      // Build a new PortType.
       PortType myPortType = new PortType();
       myPortType.Name = "MathServiceSoap";

      // Build an Add Operation for the PortType.
       Operation myAddOperation = new Operation();
       myAddOperation.Name="Add";

       // Build the Input and Output messages for the Operations.
       OperationInput myOperationInputMessage1 = new OperationInput();
       XmlQualifiedName myXmlQualifiedName1 = 
          new XmlQualifiedName("s0:AddSoapIn");
       myOperationInputMessage1.Message = myXmlQualifiedName1;

       OperationOutput myOperationOutputMessage1 = new OperationOutput();
       XmlQualifiedName myXmlQualifiedName2 = 
          new XmlQualifiedName("s0:AddSoapOut");
       myOperationOutputMessage1.Message=myXmlQualifiedName2;

       // Add the messages to the operations.
       myAddOperation.Messages.Add(myOperationInputMessage1);
       myAddOperation.Messages.Add(myOperationOutputMessage1);

       // Build an Add Operation for the PortType.
       Operation mySubtractOperation = new Operation();
       mySubtractOperation.Name = "Subtract";

       // Build the Input and Output messages for the operations.
       OperationInput myOperationInputMessage2 = new OperationInput();
       XmlQualifiedName myXmlQualifiedName3 = 
          new XmlQualifiedName("s0:SubtractSoapIn");
       myOperationInputMessage2.Message = myXmlQualifiedName3;
       OperationOutput myOperationOutputMessage2 = new OperationOutput();
       XmlQualifiedName myXmlQualifiedName4 = 
          new XmlQualifiedName("s0:SubtractSoapOut");
       myOperationOutputMessage2.Message = myXmlQualifiedName4;

       // Add the messages to the operations.
       mySubtractOperation.Messages.Add(myOperationInputMessage2);
       mySubtractOperation.Messages.Add(myOperationOutputMessage2);

       // Add the operations to the PortType.
       myPortType.Operations.Add(myAddOperation);
       myPortType.Operations.Add(mySubtractOperation);

       // Add the PortType to the collection.
       myServiceDescription.PortTypes.Add(myPortType);
   }
 }

public static void MyMethod(ServiceDescriptionBaseCollection 
    myServiceCollection)
{
    Type myType = myServiceCollection.GetType();
    if (myType.Equals(System.Web.Services.Description.ServiceCollection.
        class.ToType())) {
        // Remove the services at index 0 of the collection.
        ((ServiceCollection)(myServiceCollection)).
            Remove(myServiceDescription.get_Services().get_Item(0));
        // Build a new Service.
        Service myService = new Service();
        myService.set_Name("MathService");
        XmlQualifiedName myXmlQualifiedName = new 
            XmlQualifiedName("s0:MathServiceSoap");
        // Build a new Port for SOAP.
        Port mySoapPort = new Port();
        mySoapPort.set_Name("MathServiceSoap");
        mySoapPort.set_Binding(myXmlQualifiedName);
        SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
        mySoapAddressBinding.set_Location("http://localhost/" 
            + "ServiceDescriptionBaseCollection/"
            + "AddSubtractService.JSL.asmx");
        mySoapPort.get_Extensions().Add(mySoapAddressBinding);
        // Build a new Port for HTTP-GET.
        XmlQualifiedName myXmlQualifiedName2 = new 
            XmlQualifiedName("s0:MathServiceHttpGet");
        Port myHttpGetPort = new Port();
        myHttpGetPort.set_Name("MathServiceHttpGet");
        myHttpGetPort.set_Binding(myXmlQualifiedName2);
        HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
        myHttpAddressBinding.set_Location("http://localhost/" 
            + "ServiceDescriptionBaseCollection/"
            + "AddSubtractService.JSL.asmx");
        myHttpGetPort.get_Extensions().Add(myHttpAddressBinding);
        // Add the ports to the Service.
        myService.get_Ports().Add(myHttpGetPort);
        myService.get_Ports().Add(mySoapPort);
        // Add the Service to the ServiceCollection.
        myServiceDescription.get_Services().Add(myService);
    }
    else {
        if (myType.Equals(System.Web.Services.Description.
            BindingCollection.class.ToType())) {
            // Remove the Binding in the BindingCollection at index 0.
            ((BindingCollection)(myServiceCollection)).
                Remove(myServiceDescription.get_Bindings().get_Item(0));
            // Build a new Binding.
            Binding myBinding = new Binding();
            myBinding.set_Name("MathServiceSoap");
            XmlQualifiedName myXmlQualifiedName = new 
                XmlQualifiedName("s0:MathServiceSoap");
            myBinding.set_Type(myXmlQualifiedName);
            SoapBinding mySoapBinding = new SoapBinding();
            mySoapBinding.set_Transport("http://"
                + "schemas.xmlsoap.org/soap/http");
            mySoapBinding.set_Style(SoapBindingStyle.Document);
            // Create the operations for the binding.
            OperationBinding addOperationBinding = CreateOperationBinding(
                "Add", myServiceDescription.get_TargetNamespace());
            OperationBinding subtractOperationBinding = 
                CreateOperationBinding("Subtract", 
                myServiceDescription.get_TargetNamespace());
            // Add the operations to the Binding.
            myBinding.get_Operations().Add(subtractOperationBinding);
            myBinding.get_Operations().Add(addOperationBinding);
            myBinding.get_Extensions().Add(mySoapBinding);
            // Add the Binding to the Bindings collection.
            myServiceDescription.get_Bindings().Add(myBinding);
        }
        else {
            if (myType.Equals(System.Web.Services.Description.
                PortTypeCollection.class.ToType())) {
                // Remove the PortType at index 0.
                ((PortTypeCollection)(myServiceCollection)).
                    Remove(myServiceDescription.get_PortTypes().get_Item(0));
                // Build a new PortType.
                PortType myPortType = new PortType();
                myPortType.set_Name("MathServiceSoap");
                // Build an Add Operation for the PortType.
                Operation myAddOperation = new Operation();
                myAddOperation.set_Name("Add");
                // Build the Input and Output messages for the Operations.
                OperationInput myOperationInputMessage1 = new 
                    OperationInput();
                XmlQualifiedName myXmlQualifiedName1 = new 
                    XmlQualifiedName("s0:AddSoapIn");
                myOperationInputMessage1.set_Message(myXmlQualifiedName1);

                OperationOutput myOperationOutputMessage1 = new 
                    OperationOutput();
                XmlQualifiedName myXmlQualifiedName2 = new 
                    XmlQualifiedName("s0:AddSoapOut");
                myOperationOutputMessage1.set_Message(myXmlQualifiedName2);
                // Add the messages to the operations.
                myAddOperation.get_Messages().Add(myOperationInputMessage1);
                myAddOperation.get_Messages().Add(myOperationOutputMessage1);
                // Build an Add Operation for the PortType.
                Operation mySubtractOperation = new Operation();
                mySubtractOperation.set_Name("Subtract");
                // Build the Input and Output messages for the operations.
                OperationInput myOperationInputMessage2 =
                    new OperationInput();
                XmlQualifiedName myXmlQualifiedName3 = new 
                    XmlQualifiedName("s0:SubtractSoapIn");
                myOperationInputMessage2.set_Message(myXmlQualifiedName3);
                OperationOutput myOperationOutputMessage2 = 
                    new OperationOutput();
                XmlQualifiedName myXmlQualifiedName4 = new 
                    XmlQualifiedName("s0:SubtractSoapOut");
                myOperationOutputMessage2.set_Message(myXmlQualifiedName4);
                // Add the messages to the operations.
                mySubtractOperation.get_Messages().
                    Add(myOperationInputMessage2);
                mySubtractOperation.get_Messages().
                    Add(myOperationOutputMessage2);
                // Add the operations to the PortType.
                myPortType.get_Operations().Add(myAddOperation);
                myPortType.get_Operations().Add(mySubtractOperation);
                // Add the PortType to the collection.
                myServiceDescription.get_PortTypes().Add(myPortType);
            }
        }
    }
} //MyMethod

System.Object
   System.Collections.CollectionBase
    System.Web.Services.Description.ServiceDescriptionBaseCollection
       Derived Classes

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

Community Additions

ADD
Show:
© 2014 Microsoft