コード例 #1
0
// <Snippet1>
// <Snippet2>
        static void Main()
        {
            string        myWsdlFileName = "MyWsdl_CS.wsdl";
            XmlTextReader myReader       = new XmlTextReader(myWsdlFileName);

            if (ServiceDescription.CanRead(myReader))
            {
                ServiceDescription myDescription =
                    ServiceDescription.Read(myWsdlFileName);

                // Remove the PortType at index 0 of the collection.
                PortTypeCollection myPortTypeCollection =
                    myDescription.PortTypes;
                myPortTypeCollection.Remove(myDescription.PortTypes[0]);

                // Build a new PortType.
                PortType myPortType = new PortType();
                myPortType.Name = "Service1Soap";
                Operation myOperation =
                    CreateOperation("Add", "s0:AddSoapIn", "s0:AddSoapOut", "");
                myPortType.Operations.Add(myOperation);

                // Add a new PortType to the PortType collection of
                // the ServiceDescription.
                myDescription.PortTypes.Add(myPortType);

                myDescription.Write("MyOutWsdl.wsdl");
                Console.WriteLine("New WSDL file generated successfully.");
            }
            else
            {
                Console.WriteLine("This file is not a WSDL file.");
            }
        }
コード例 #2
0
    public static void Main()
    {
        try
        {
// <Snippet1>
// <Snippet2>
// <Snippet3>
// <Snippet4>
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");

            PortTypeCollection myPortTypeCollection =
                myServiceDescription.PortTypes;
            int noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: " + noOfPortTypes);

            PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];

// </Snippet4>
            // Get the index in the collection.
            int index = myPortTypeCollection.IndexOf(myNewPortType);
// </Snippet3>
            Console.WriteLine("Removing the PortType named "
                              + myNewPortType.Name);

            // Remove the PortType from the collection.
            myPortTypeCollection.Remove(myNewPortType);
            noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: "
                              + noOfPortTypes);

            // Check whether the PortType exists in the collection.
            bool bContains = myPortTypeCollection.Contains(myNewPortType);
            Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: "
                              + bContains);

            Console.WriteLine("Adding the PortType");
            // Insert a new portType at the index location.
            myPortTypeCollection.Insert(index, myNewPortType);
// </Snippet2>

            // Display the number of portTypes after adding a port.
            Console.WriteLine("Total number of PortTypes after "
                              + "adding a new port: " + myServiceDescription.PortTypes.Count);

            bContains = myPortTypeCollection.Contains(myNewPortType);
            Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: "
                              + bContains);
            myServiceDescription.Write("MathService_New.wsdl");
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
コード例 #3
0
    public static void Main()
    {
        try
        {
            // Read the existing Web service description file.
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");
            PortTypeCollection myPortTypeCollection =
                myServiceDescription.PortTypes;
            int noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: "
                              + myServiceDescription.PortTypes.Count);

            // Get the first PortType in the collection.
            PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];
            int      index         = myPortTypeCollection.IndexOf(myNewPortType);
            Console.WriteLine("The PortType with the name " + myNewPortType.Name
                              + " is at index: " + (index + 1));

            Console.WriteLine("Removing the PortType: " + myNewPortType.Name);

            // Remove the PortType from the collection.
            myPortTypeCollection.Remove(myNewPortType);
            bool bContains = myPortTypeCollection.Contains(myNewPortType);
            Console.WriteLine("The PortType with the name " + myNewPortType.Name
                              + " exists: " + bContains);

            Console.WriteLine("Total number of PortTypes after removing: "
                              + myServiceDescription.PortTypes.Count);

            Console.WriteLine("Adding a PortType: " + myNewPortType.Name);

            // Add a new portType from the collection.
            myPortTypeCollection.Add(myNewPortType);

            // Display the number of portTypes after adding a port.
            Console.WriteLine("Total number of PortTypes after "
                              + "adding a new port: " + myServiceDescription.PortTypes.Count);

            // List the PortTypes available in the WSDL document.
            foreach (PortType myPortType in myPortTypeCollection)
            {
                Console.WriteLine("The PortType name is: " + myPortType.Name);
            }

            myServiceDescription.Write("MathService_New.wsdl");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
コード例 #4
0
    public static void Main()
    {
        try
        {
// <Snippet1>
// <Snippet2>
// <Snippet3>
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");
            PortTypeCollection myPortTypeCollection =
                myServiceDescription.PortTypes;

            int noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: "
                              + myServiceDescription.PortTypes.Count);

            // Get the first PortType in the collection.
            PortType myNewPortType = myPortTypeCollection[0];
            Console.WriteLine(
                "The PortType at index 0 is: " + myNewPortType.Name);
            Console.WriteLine("Removing the PortType " + myNewPortType.Name);

            // Remove the PortType from the collection.
            myPortTypeCollection.Remove(myNewPortType);

            // Display the number of PortTypes.
            Console.WriteLine("\nTotal number of PortTypes after removing: "
                              + myServiceDescription.PortTypes.Count);

            Console.WriteLine("Adding a PortType " + myNewPortType.Name);

            // Add a new PortType from the collection.
            myPortTypeCollection.Add(myNewPortType);

            // Display the number of PortTypes after adding a port.
            Console.WriteLine("Total number of PortTypes after " +
                              "adding a new port: " + myServiceDescription.PortTypes.Count);

            myServiceDescription.Write("MathService_New.wsdl");
// </Snippet3>
// </Snippet2>
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }