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 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(
            __typeof(System::Web::Services::Description::ServiceCollection)))
        {
            // Remove the services at index 0 of the collection.
            (dynamic_cast<ServiceCollection*>(myServiceCollection))->Remove(
                myServiceDescription->Services->Item[0]);

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

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

            // Build a new Port for HTTP-GET.
            XmlQualifiedName* myXmlQualifiedName2 = 
                new XmlQualifiedName(S"s0:MathServiceHttpGet");
            Port* myHttpGetPort= new Port();
            myHttpGetPort->Name=S"MathServiceHttpGet";
            myHttpGetPort->Binding=myXmlQualifiedName2;
            HttpAddressBinding* myHttpAddressBinding = new HttpAddressBinding();
            myHttpAddressBinding->Location = S"http://localhost/"  
                S"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.
            (dynamic_cast<BindingCollection*>(myServiceCollection))->Remove(
                myServiceDescription->Bindings->Item[0]);

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

            // Create the operations for the binding.
            OperationBinding* addOperationBinding = CreateOperationBinding(
                S"Add", myServiceDescription->TargetNamespace);
            OperationBinding* subtractOperationBinding = CreateOperationBinding(
                S"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.
            (dynamic_cast<PortTypeCollection*>(myServiceCollection))->Remove(
                myServiceDescription->PortTypes->Item[0]);

            // Build a new PortType.
            PortType* myPortType = new PortType();
            myPortType->Name = S"MathServiceSoap";

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

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

            OperationOutput* myOperationOutputMessage1 = new OperationOutput();
            XmlQualifiedName* myXmlQualifiedName2 = 
                new XmlQualifiedName(S"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 = S"Subtract";

            // Build the Input and Output messages for the operations.
            OperationInput* myOperationInputMessage2 = new OperationInput();
            XmlQualifiedName* myXmlQualifiedName3 = 
                new XmlQualifiedName(S"s0:SubtractSoapIn");
            myOperationInputMessage2->Message = myXmlQualifiedName3;
            OperationOutput* myOperationOutputMessage2 = new OperationOutput();
            XmlQualifiedName* myXmlQualifiedName4 = 
                new XmlQualifiedName(S"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);
        }
    }

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft