Esempio n. 1
0
    public static void Main()
    {
        Console.WriteLine("Import Sample");
// <Snippet1>
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("StockQuote_cs.wsdl");

        myServiceDescription.Imports.Add(
            CreateImport("http://localhost/stockquote/schemas",
                         "http://localhost/stockquote/stockquote_cs.xsd"));
// </Snippet1>
        // Save the ServiceDescripition to an external file.
        myServiceDescription.Write("StockQuote_cs.wsdl");
        Console.WriteLine(
            "Successfully added import to WSDL document 'StockQuote_cs.wsdl'");

        // Print the import collection to the console.
        PrintImportCollection("StockQuote_cs.wsdl");
// <Snippet2>
        myServiceDescription =
            ServiceDescription.Read("StockQuoteService_cs.wsdl");
        myServiceDescription.Imports.Insert(
            0, CreateImport("http://localhost/stockquote/definitions",
                            "http://localhost/stockquote/stockquote_cs.wsdl"));
// </Snippet2>
        // Save the ServiceDescripition to an external file.
        myServiceDescription.Write("StockQuoteService_cs.wsdl");
        Console.WriteLine("");
        Console.WriteLine("Successfully added import to WSDL " +
                          "document 'StockQuoteService_cs.wsdl'");

        //Print the import collection to the console.
        PrintImportCollection("StockQuoteService_cs.wsdl");
    }
Esempio n. 2
0
    public static void Main()
    {
        Binding myBinding;
// <Snippet1>
// <Snippet2>
// <Snippet3>
// <Snippet4>
        ServiceDescription myServiceDescription = ServiceDescription.Read("MathService_input.wsdl");

        Console.WriteLine("Total Number of bindings defined are:" + myServiceDescription.Bindings.Count);
        myBinding = myServiceDescription.Bindings[0];

        // Remove the first binding in the collection.
        myServiceDescription.Bindings.Remove(myBinding);
        Console.WriteLine("Successfully removed binding " + myBinding.Name);
        Console.WriteLine("Total Number of bindings defined now are:" + myServiceDescription.Bindings.Count);
        myServiceDescription.Write("MathService_temp.wsdl");
// </Snippet1>
        // Add binding to the ServiceDescription instance.
        myServiceDescription.Bindings.Add(myBinding);
// </Snippet2>
        if (myServiceDescription.Bindings.Contains(myBinding))
        {
            Console.WriteLine("Successfully added binding " + myBinding.Name);
        }
// </Snippet3>
        Console.WriteLine("Binding was added at index " + myServiceDescription.Bindings.IndexOf(myBinding));
        Console.WriteLine("Total Number of bindings defined now are:" + myServiceDescription.Bindings.Count);
        myServiceDescription.Write("MathService_temp1.wsdl");
// </Snippet4>
        myServiceDescription = null;
        myBinding            = null;
    }
Esempio n. 3
0
    static void Resolve(ServiceData sd)
    {
        Console.Write("Resolving " + sd.Wsdl + " ");
        try
        {
            DiscoveryClientProtocol contract = new DiscoveryClientProtocol();
            contract.DiscoverAny(sd.Wsdl);

            if (sd.Protocols == null || sd.Protocols.Length == 0)
            {
                RetrieveServiceData(sd, contract);
            }

            string wsdlFile = GetWsdlFile(sd);
            CreateFolderForFile(wsdlFile);

            ServiceDescription doc = (ServiceDescription)contract.Documents [sd.Wsdl];
            doc.Write(wsdlFile);

            Console.WriteLine("OK");
            CleanFailures(sd);
        }
        catch (Exception ex)
        {
            Console.WriteLine("FAILED");
            ReportError("Error resolving: " + sd.Wsdl, ex.ToString());
            RegisterFailure(sd);
        }
    }
    public static void Main( )
    {
// <Snippet1>
        ServiceDescription myServiceDescription = new ServiceDescription();

        myServiceDescription =
            ServiceDescription.Read("ServiceDescription_Imports_Input_CS.wsdl");
        ImportCollection myImportCollection = myServiceDescription.Imports;

        // Create an Import.
        Import myImport = new Import();

        myImport.Namespace = myServiceDescription.TargetNamespace;

        // Set the location for the Import.
        myImport.Location = "http://www.contoso.com/";
        myImportCollection.Add(myImport);
        myServiceDescription.Write("ServiceDescription_Imports_Output_CS.wsdl");
        myImportCollection.Clear();
        myServiceDescription =
            ServiceDescription.Read("ServiceDescription_Imports_Output_CS.wsdl");
        myImportCollection = myServiceDescription.Imports;
        Console.WriteLine(
            "The Import elements added to the ImportCollection are: ");
        for (int i = 0; i < myImportCollection.Count; i++)
        {
            Console.WriteLine((i + 1) + ". " + myImportCollection[i].Location);
        }
// </Snippet1>
    }
    public static void Main()
    {
// <Snippet1>
// <Snippet2>
        ServiceDescription myServiceDescription = new ServiceDescription();

        myServiceDescription =
            ServiceDescription.Read("ServiceDescription_Extensions_Input_cs.wsdl");
        Console.WriteLine(
            myServiceDescription.Bindings[1].Extensions[0].ToString());
        SoapBinding mySoapBinding = new SoapBinding();

        mySoapBinding.Required = true;
        SoapBinding mySoapBinding1 = new SoapBinding();

        mySoapBinding1.Required = false;
        myServiceDescription.Extensions.Add(mySoapBinding);
        myServiceDescription.Extensions.Add(mySoapBinding1);
        foreach (ServiceDescriptionFormatExtension
                 myServiceDescriptionFormatExtension
                 in myServiceDescription.Extensions)
        {
            Console.WriteLine("Required: " +
                              myServiceDescriptionFormatExtension.Required);
        }
        myServiceDescription.Write(
            "ServiceDescription_Extensions_Output_cs.wsdl");
        myServiceDescription.RetrievalUrl = "http://www.contoso.com/";
        Console.WriteLine("Retrieval URL is: " +
                          myServiceDescription.RetrievalUrl);
// </Snippet2>
// </Snippet1>
    }
    public static void Main()
    {
        // Read the 'StockQuote.wsdl' file as input.
        ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuote.wsdl");

        // Get the operation fault collection and remove the operation fault with the name 'ErrorString'.
        PortTypeCollection       myPortTypeCollection       = myServiceDescription.PortTypes;
        PortType                 myPortType                 = myPortTypeCollection[0];
        OperationCollection      myOperationCollection      = myPortType.Operations;
        Operation                myOperation                = myOperationCollection[0];
        OperationFaultCollection myOperationFaultCollection = myOperation.Faults;

        if (myOperationFaultCollection.Contains(myOperationFaultCollection["ErrorString"]))
        {
            myOperationFaultCollection.Remove(myOperationFaultCollection["ErrorString"]);
        }

        // Get the fault binding collection and remove the fault binding with the name 'ErrorString'.
// <Snippet1>
        BindingCollection          myBindingCollection          = myServiceDescription.Bindings;
        Binding                    myBinding                    = myBindingCollection[0];
        OperationBindingCollection myOperationBindingCollection = myBinding.Operations;
        OperationBinding           myOperationBinding           = myOperationBindingCollection[0];
        FaultBindingCollection     myFaultBindingCollection     = myOperationBinding.Faults;

        if (myFaultBindingCollection.Contains(myFaultBindingCollection["ErrorString"]))
        {
            myFaultBindingCollection.Remove(myFaultBindingCollection["ErrorString"]);
        }
// </Snippet1>

        myServiceDescription.Write(Console.Out);
    }
Esempio n. 7
0
    public static void Main()
    {
        try
        {
// <Snippet1>
            PortTypeCollection myPortTypeCollection;

            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");

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

            // Copy the collection into an array.
            PortType[] myPortTypeArray = new PortType[noOfPortTypes];
            myPortTypeCollection.CopyTo(myPortTypeArray, 0);

            // Display names of all PortTypes.
            for (int i = 0; i < noOfPortTypes; i++)
            {
                Console.WriteLine("PortType name: " + myPortTypeArray[i].Name);
            }
            myServiceDescription.Write("MathService_New.wsdl");
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
        static void Main()
        {
            try
            {
                // Create the file stream.
                FileStream discoStream =
                    new FileStream("Service1_CS.disco", FileMode.Open);

                // Create the discovery document.
                DiscoveryDocument myDiscoveryDocument =
                    DiscoveryDocument.Read(discoStream);

                // Get the first ContractReference in the collection.
                ContractReference myContractReference =
                    (ContractReference)myDiscoveryDocument.References[0];

                // Set the client protocol.
                myContractReference.ClientProtocol             = new DiscoveryClientProtocol();
                myContractReference.ClientProtocol.Credentials =
                    CredentialCache.DefaultCredentials;

                // Get the service description.
                ServiceDescription myContract = myContractReference.Contract;

                // Create the service description file.
                myContract.Write("MyService1.wsdl");
                Console.WriteLine("The WSDL file created is MyService1.wsdl");

                discoStream.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
        }
Esempio n. 9
0
    public static void Main()
    {
        ServiceDescription myDescription = ServiceDescription.Read("Operation_5_Input_CS.wsdl");
        // Create a 'PortType' object.
        PortType myPortType = new PortType();

        myPortType.Name = "OperationServiceHttpPost";
        Operation myOperation = CreateOperation
                                    ("AddNumbers", "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut");

        myPortType.Operations.Add(myOperation);
// <Snippet5>
        // Get the PortType of the Operation.
        PortType myPort = myOperation.PortType;

        Console.WriteLine(
            "The port type of the operation is: " + myPort.Name);
// </Snippet5>
        // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
        myDescription.PortTypes.Add(myPortType);

        // Write the 'ServiceDescription' as a WSDL file.
        myDescription.Write("Operation_5_Output_CS.wsdl");
        Console.WriteLine("WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully");
    }
Esempio n. 10
0
        public ServiceDescription Convert(XmlDocument wsdl2Xml)
        {
            CannonizePrefix(wsdl2Xml);
            var ser    = new XmlSerializer(typeof(DescriptionType));
            var reader = new StringReader(wsdl2Xml.OuterXml);
            var wsdl2  = (DescriptionType)ser.Deserialize(reader);

            var wsdl1 = new ServiceDescription();

            ConvertDescription(wsdl2, wsdl1);
            ConvertImports(wsdl2, wsdl1);
            ConvertTypes(wsdl2, wsdl1);
            ConvertInterface(wsdl2, wsdl1);
            ConvertBinding(wsdl2, wsdl1);
            ConvertService(wsdl2, wsdl1);

            //not sure why needs to do it... but otherwise code generation fails
            var m = new MemoryStream();

            wsdl1.Write(m);
            string s = Encoding.UTF8.GetString(m.GetBuffer());

            wsdl1 = ServiceDescription.Read(new StringReader(s));

            return(wsdl1);
        }
Esempio n. 11
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.");
            }
        }
Esempio n. 12
0
        [Category("NotOnMac")]          // https://bugzilla.xamarin.com/show_bug.cgi?id=51254
        public void SimpleWrite()
        {
            ServiceDescription sd = new ServiceDescription();

            Assert.IsNull(sd.Name);
            sd.Write(TextWriter.Null);
        }
Esempio n. 13
0
    public static void Main()
    {
        try
        {
            Service        myService;
            PortCollection myPortCollection;

            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathServiceCopyTo_cs.wsdl");

            Console.WriteLine("Total Number of Services :"
                              + myServiceDescription.Services.Count);

            for (int i = 0; i < myServiceDescription.Services.Count; ++i)
            {
                myService = myServiceDescription.Services[i];
                Console.WriteLine("Name : " + myService.Name);

// <Snippet1>
// <Snippet2>
// <Snippet3>
                myPortCollection = myService.Ports;

                // Create an array of Port objects.
                Console.WriteLine("\nPort collection :");
                Port[] myPortArray = new Port[myService.Ports.Count];
                myPortCollection.CopyTo(myPortArray, 0);
                for (int i1 = 0; i1 < myService.Ports.Count; ++i1)
                {
                    Console.WriteLine("Port[" + i1 + "] : " + myPortArray[i1].Name);
                }
// </Snippet3>
                Port myIndexPort = myPortCollection[0];
                Console.WriteLine("\n\nThe index of port '"
                                  + myIndexPort.Name + "' is : "
                                  + myPortCollection.IndexOf(myIndexPort));
// </Snippet2>

                Port myPortTestInsert = myPortCollection[0];
                myPortCollection.Remove(myPortTestInsert);
                myPortCollection.Insert(0, myPortTestInsert);
                Console.WriteLine("\n\nTotal Number of Ports after inserting "
                                  + "a new port '" + myPortTestInsert.Name + "' is : "
                                  + myService.Ports.Count);
                for (int i1 = 0; i1 < myService.Ports.Count; ++i1)
                {
                    Console.WriteLine("Port[" + i1 + "]  : " + myPortArray[i1].Name);
                }
                myServiceDescription.Write("MathServiceCopyToNew_cs.wsdl");
// </Snippet1>
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception:" + ex.Message);
        }
    }
Esempio n. 14
0
    public static void Main()
    {
        try
        {
            ServiceDescription myDescription =
                ServiceDescription.Read("MimeXmlBinding_Part_3_Input_CS.wsdl");
            // Create the 'Binding' object.
            Binding myBinding = new Binding();
            // Initialize 'Name' property of 'Binding' class.
            myBinding.Name = "MimeXmlBinding_Part_3_ServiceHttpPost";
            XmlQualifiedName
                myXmlQualifiedName = new XmlQualifiedName("s0:MimeXmlBinding_Part_3_ServiceHttpPost");
            myBinding.Type = myXmlQualifiedName;
            // Create the 'HttpBinding' object.
            HttpBinding myHttpBinding = new HttpBinding();
            myHttpBinding.Verb = "POST";
            // Add the 'HttpBinding' to the 'Binding'.
            myBinding.Extensions.Add(myHttpBinding);
            // Create the 'OperationBinding' object.
            OperationBinding myOperationBinding = new OperationBinding();
            myOperationBinding.Name = "AddNumbers";
            HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding();
            myHttpOperationBinding.Location = "/AddNumbers";
            // Add the 'HttpOperationBinding' to 'OperationBinding'.
            myOperationBinding.Extensions.Add(myHttpOperationBinding);
            // Create the 'InputBinding' object.
            InputBinding       myInputBinding       = new InputBinding();
            MimeContentBinding myMimeContentBinding = new MimeContentBinding();
            myMimeContentBinding.Type = "application/x-www-form-urlencoded";
            myInputBinding.Extensions.Add(myMimeContentBinding);
            // Add the 'InputBinding' to 'OperationBinding'.
            myOperationBinding.Input = myInputBinding;
            // Create an OutputBinding.
            OutputBinding  myOutputBinding  = new OutputBinding();
            MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

            // Initialize the Part property of the MimeXmlBinding.
            myMimeXmlBinding.Part = "Body";

            // Add the MimeXmlBinding to the OutputBinding.
            myOutputBinding.Extensions.Add(myMimeXmlBinding);
            // Add the 'OutPutBinding' to 'OperationBinding'.
            myOperationBinding.Output = myOutputBinding;
            // Add the 'OperationBinding' to 'Binding'.
            myBinding.Operations.Add(myOperationBinding);
            // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
            myDescription.Bindings.Add(myBinding);
            // Write the 'ServiceDescription' as a WSDL file.
            myDescription.Write("MimeXmlBinding_Part_3_Output_CS.wsdl");
            Console.WriteLine("WSDL file with name 'MimeXmlBinding_Part_3_Output_CS.wsdl' is"
                              + " created successfully.");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
Esempio n. 15
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);
        }
    }
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimePartCollection_1_Input_cs.wsdl");
        ServiceDescriptionCollection myServiceDescriptionCol =
            new ServiceDescriptionCollection();

        myServiceDescriptionCol.Add(myServiceDescription);
        XmlQualifiedName myXmlQualifiedName =
            new  XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");
        // Create a 'Binding' object.
        Binding          myBinding          = myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
        OperationBinding myOperationBinding = null;

        for (int i = 0; i < myBinding.Operations.Count; i++)
        {
            if (myBinding.Operations[i].Name.Equals("AddNumbers"))
            {
                myOperationBinding = myBinding.Operations[i];
            }
        }
        OutputBinding myOutputBinding = myOperationBinding.Output;
        MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
        IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();

        while (myIEnumerator.MoveNext())
        {
            myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding)myIEnumerator.Current;
        }
        // Create an instances of 'MimePartCollection'.
        MimePartCollection myMimePartCollection = new MimePartCollection();

        myMimePartCollection = myMimeMultipartRelatedBinding.Parts;

        Console.WriteLine("Total number of mimepart elements initially is: "
                          + myMimePartCollection.Count);
        // Create an instance of 'MimePart'.
        MimePart myMimePart = new MimePart();
        // Create an instance of 'MimeXmlBinding'.
        MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

        myMimeXmlBinding.Part = "body";
        myMimePart.Extensions.Add(myMimeXmlBinding);
        // Insert a mimepart at first position.
        myMimePartCollection.Insert(0, myMimePart);
        Console.WriteLine("Inserting a mimepart object...");
        if (myMimePartCollection.Contains(myMimePart))
        {
            Console.WriteLine("'MimePart' is succesffully added at position: "
                              + myMimePartCollection.IndexOf(myMimePart));
            Console.WriteLine("Total number of mimepart elements after inserting is: "
                              + myMimePartCollection.Count);
        }
        myServiceDescription.Write("MimePartCollection_1_Output_CS.wsdl");
        Console.WriteLine("MimePartCollection_1_Output_CS.wsdl has been generated successfully.");
    }
    public static void Main()
    {
        try
        {
            // Read the 'MathService_Input_cs.wsdl' file.
            ServiceDescription myDescription =
                ServiceDescription.Read("MathService_Input_cs.wsdl");
            PortTypeCollection myPortTypeCollection = myDescription.PortTypes;
            // Get the 'OperationCollection' for 'SOAP' protocol.
            OperationCollection myOperationCollection =
                myPortTypeCollection[0].Operations;
            Operation myOperation = new Operation();
            myOperation.Name = "Add";
            OperationMessage myOperationMessageInput =
                (OperationMessage) new OperationInput();
            myOperationMessageInput.Message = new XmlQualifiedName
                                                  ("AddSoapIn", myDescription.TargetNamespace);
            OperationMessage myOperationMessageOutput =
                (OperationMessage) new OperationOutput();
            myOperationMessageOutput.Message = new XmlQualifiedName(
                "AddSoapOut", myDescription.TargetNamespace);
            myOperation.Messages.Add(myOperationMessageInput);
            myOperation.Messages.Add(myOperationMessageOutput);
            myOperationCollection.Add(myOperation);

            if (myOperationCollection.Contains(myOperation) == true)
            {
                Console.WriteLine("The index of the added 'myOperation' " +
                                  "operation is : " +
                                  myOperationCollection.IndexOf(myOperation));
            }

            myOperationCollection.Remove(myOperation);
            // Insert the 'myOpearation' operation at the index '0'.
            myOperationCollection.Insert(0, myOperation);
            Console.WriteLine("The operation at index '0' is : " +
                              myOperationCollection[0].Name);

            Operation[] myOperationArray = new Operation[
                myOperationCollection.Count];
            myOperationCollection.CopyTo(myOperationArray, 0);
            Console.WriteLine("The operation(s) in the collection are :");
            for (int i = 0; i < myOperationCollection.Count; i++)
            {
                Console.WriteLine(" " + myOperationArray[i].Name);
            }

            myDescription.Write("MathService_New_cs.wsdl");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.Source);
            Console.WriteLine("Message : " + e.Message);
        }
    }
Esempio n. 18
0
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("SoapHeaderBindingInput_cs.wsdl");
        Binding myBinding = new Binding();

        myBinding.Name = "MyWebServiceSoap";
        myBinding.Type = new XmlQualifiedName("s0:MyWebServiceSoap");

        SoapBinding mySoapBinding = new SoapBinding();

        mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
        mySoapBinding.Style     = SoapBindingStyle.Document;
        myBinding.Extensions.Add(mySoapBinding);

        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = "Hello";

        SoapOperationBinding mySoapOperationBinding =
            new SoapOperationBinding();

        mySoapOperationBinding.SoapAction = "http://tempuri.org/Hello";
        mySoapOperationBinding.Style      = SoapBindingStyle.Document;
        myOperationBinding.Extensions.Add(mySoapOperationBinding);

        // Create InputBinding for operation for the 'SOAP' protocol.
        InputBinding    myInputBinding    = new InputBinding();
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        mySoapBodyBinding.Use = SoapBindingUse.Literal;
        myInputBinding.Extensions.Add(mySoapBodyBinding);
        SoapHeaderBinding mySoapHeaderBinding = new SoapHeaderBinding();

        mySoapHeaderBinding.Message = new XmlQualifiedName("s0:HelloMyHeader");
        mySoapHeaderBinding.Part    = "MyHeader";
        mySoapHeaderBinding.Use     = SoapBindingUse.Literal;
        // Add mySoapHeaderBinding to 'myInputBinding' object.
        myInputBinding.Extensions.Add(mySoapHeaderBinding);
        // Create OutputBinding for operation for the 'SOAP' protocol.
        OutputBinding myOutputBinding = new OutputBinding();

        myOutputBinding.Extensions.Add(mySoapBodyBinding);

        // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
        myOperationBinding.Input  = myInputBinding;
        myOperationBinding.Output = myOutputBinding;
        myBinding.Operations.Add(myOperationBinding);

        myServiceDescription.Bindings.Add(myBinding);
        myServiceDescription.Write("SoapHeaderBindingOut_cs.wsdl");
        Console.WriteLine("'SoapHeaderBindingOut_cs.wsdl' file is generated.");
        Console.WriteLine("Proxy could be created using "
                          + "'wsdl SoapHeaderBindingOut_cs.wsdl'.");
    }
        public void Extensions()
        {
            FileStream    fs  = new FileStream("Test/System.Web.Services.Description/test.wsdl", FileMode.Open);
            XmlTextReader xtr = new XmlTextReader(fs);

            ServiceDescription sd = ServiceDescription.Read(xtr);

            fs.Close();

            Assert.IsNotNull(sd.Extensions);
            Assert.AreEqual(1, sd.Extensions.Count);

            CheckExtensions(sd, "sdElem", "sdVal");
            CheckExtensions(sd.Messages [0], "msgElem", "msgVal");
            CheckExtensions(sd.Messages [0].Parts [0], "partElem", "partVal");

            CheckExtensions(sd.PortTypes [0], "ptElem", "ptVal");
            CheckExtensions(sd.PortTypes [0].Operations [0], "opElem", "opVal");

            //Binding [0]
            Assert.IsNotNull(sd.Bindings [0].Extensions);
            Assert.AreEqual(2, sd.Bindings [0].Extensions.Count);
            CheckXmlElement(sd.Bindings [0].Extensions [0], "binElem");
            Assert.AreEqual(typeof(SoapBinding), sd.Bindings [0].Extensions [1].GetType());

            //Binding [0].Operations [0]
            Assert.IsNotNull(sd.Bindings [0].Operations [0].Extensions);
            Assert.AreEqual(1, sd.Bindings [0].Operations [0].Extensions.Count);
            Assert.AreEqual(typeof(SoapOperationBinding), sd.Bindings [0].Operations [0].Extensions [0].GetType());

            //Service
            CheckExtensions(sd.Services [0], "svcElem", "svcVal");

            //Service.Port
            Assert.IsNotNull(sd.Services [0].Ports [0].Extensions);
            Assert.AreEqual(2, sd.Services [0].Ports [0].Extensions.Count);
            Assert.AreEqual(typeof(SoapAddressBinding), sd.Services [0].Ports [0].Extensions [0].GetType());
            CheckXmlElement(sd.Services [0].Ports [0].Extensions [1], "portElem");

            string out_file = Path.GetTempFileName();

            try
            {
                using (FileStream out_fs = new FileStream(out_file, FileMode.Create))
                    sd.Write(out_fs);
            }
            finally
            {
                if (!String.IsNullOrEmpty(out_file))
                {
                    File.Delete(out_file);
                }
            }
        }
    public static void Main()
    {
        try
        {
            // Read the 'StockQuote.wsdl' file as input.
            ServiceDescription myServiceDescription = ServiceDescription.
                                                      Read("StockQuote_cs.wsdl");
            // Remove the operation fault with the name 'ErrorString'.
            PortTypeCollection myPortTypeCollection = myServiceDescription.
                                                      PortTypes;
            PortType            myPortType            = myPortTypeCollection[0];
            OperationCollection myOperationCollection = myPortType.Operations;
            Operation           myOperation           = myOperationCollection[0];

// <Snippet1>
            OperationFaultCollection myOperationFaultCollection =
                myOperation.Faults;
            OperationFault myOperationFault =
                myOperationFaultCollection["ErrorString"];
            if (myOperationFault != null)
            {
                myOperationFaultCollection.Remove(myOperationFault);
            }
// </Snippet1>

            // Remove the fault binding with the name 'ErrorString'.
            BindingCollection myBindingCollection = myServiceDescription.
                                                    Bindings;
            Binding myBinding = myBindingCollection[0];
            OperationBindingCollection myOperationBindingCollection =
                myBinding.Operations;
            OperationBinding myOperationBinding =
                myOperationBindingCollection[0];
            FaultBindingCollection myFaultBindingCollection =
                myOperationBinding.Faults;
            if (myFaultBindingCollection.Contains(
                    myFaultBindingCollection["ErrorString"]))
            {
                myFaultBindingCollection.Remove(
                    myFaultBindingCollection["ErrorString"]);
            }

            myServiceDescription.Write("OperationFaultCollection_out.wsdl");
            Console.WriteLine("WSDL file with name 'OperationFaultCollection_out.wsdl'" +
                              " created Successfully");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.Source);
            Console.WriteLine("Message : " + e.Message);
        }
    }
 /// <summary>
 /// Outputs service description to specified stream.
 /// </summary>
 public static void SaveTo(this ServiceDescription serviceDescription, Stream stream)
 {
     using (var writer = XmlWriter.Create(stream, new XmlWriterSettings {
         Indent = true, IndentChars = "  ", NewLineChars = "\r\n"
     }))
     {
         writer.WriteStartDocument();
         serviceDescription.Write(writer);
         writer.WriteEndDocument();
         writer.Flush();
     }
 }
    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);
        }
    }
Esempio n. 23
0
        static public void exportWSDLs(EA.Repository repository, EA.Diagram diagram)
        {
            WSDLManager mgr = new WSDLManager();

            //mgr.path = @"D:\SOA\Modelling\Schema\";
            mgr.path = @"D:\tmp\";
            foreach (EA.DiagramObject obj in diagram.DiagramObjects)
            {
                EA.Element         component = repository.GetElementByID(obj.ElementID);
                ServiceDescription sd        = mgr.exportWSDL(repository, component);
                sd.Write(mgr.path + "/" + sd.Name + ".wsdl");
            }
        }
Esempio n. 24
0
        public string Generate()
        {
            string wsdlContent;

            using (MemoryStream ms = new MemoryStream()) {
                _serviceDescription.Write(ms);

                ms.Seek(0L, SeekOrigin.Begin);
                wsdlContent = (new StreamReader(ms)).ReadToEnd();
            }

            return(wsdlContent);
        }
Esempio n. 25
0
        internal override void WriteReturns(object[] returnValues, Stream outputStream)
        {
            string   id       = Request.QueryString["schema"];
            Encoding encoding = new UTF8Encoding(false);

            if (id != null)
            {
                XmlSchema schema = serverType.GetSchema(id);
                if (schema == null)
                {
                    throw new InvalidOperationException(Res.GetString(Res.WebSchemaNotFound));
                }
                Response.ContentType = ContentType.Compose("text/xml", encoding);
                schema.Write(new StreamWriter(outputStream, encoding));
                return;
            }

            id = Request.QueryString["wsdl"];
            if (id != null)
            {
                ServiceDescription description = serverType.GetServiceDescription(id);
                if (description == null)
                {
                    throw new InvalidOperationException(Res.GetString(Res.ServiceDescriptionWasNotFound0));
                }
                Response.ContentType = ContentType.Compose("text/xml", encoding);
                description.Write(new StreamWriter(outputStream, encoding));
                return;
            }

            string queryString = Request.QueryString[null];

            if (queryString != null && string.Compare(queryString, "wsdl", true, CultureInfo.InvariantCulture) == 0)
            {
                Response.ContentType = ContentType.Compose("text/xml", encoding);
                serverType.Description.Write(new StreamWriter(outputStream, encoding));
                return;
            }

            if (queryString != null && string.Compare(queryString, "disco", true, CultureInfo.InvariantCulture) == 0)
            {
                Response.ContentType = ContentType.Compose("text/xml", encoding);
                serverType.Disco.Write(new StreamWriter(outputStream, encoding));
                return;
            }


            throw new InvalidOperationException(Res.GetString(Res.internalError0));
        }
Esempio n. 26
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);
        }
    }
Esempio n. 27
0
    public static void Main()
    {
        try
        {
// <Snippet2>
// <Snippet3>
            PortTypeCollection myPortTypeCollection;
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");

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

            PortType myPortType = myPortTypeCollection["MathServiceSoap"];
            myPortTypeCollection.Remove(myPortType);

            // Create a new PortType.
            PortType myNewPortType = new PortType();
            myNewPortType.Name = "MathServiceSoap";
            OperationCollection myOperationCollection =
                myServiceDescription.PortTypes[0].Operations;

            string inputMsg, outputMsg;
            for (int i = 0; i < myOperationCollection.Count; i++)
            {
                inputMsg  = myOperationCollection[i].Name + "SoapIn";
                outputMsg = myOperationCollection[i].Name + "SoapOut";
                Console.WriteLine(" Operation = " + myOperationCollection[i].Name);
                myNewPortType.Operations.Add(
                    CreateOperation(myOperationCollection[i].Name,
                                    inputMsg, outputMsg, myServiceDescription.TargetNamespace));
            }
            // Add the PortType to the collection.
            myPortTypeCollection.Add(myNewPortType);
            noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes : "
                              + noOfPortTypes);
            myServiceDescription.Write("MathService_New.wsdl");
// </Snippet3>
// </Snippet2>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception:" + e.Message);
        }
    }
Esempio n. 28
0
        internal override void WriteReturns(object[] returnValues, Stream outputStream)
        {
            string   id       = base.Request.QueryString["schema"];
            Encoding encoding = new UTF8Encoding(false);

            if (id != null)
            {
                XmlSchema schema = this.serverType.GetSchema(id);
                if (schema == null)
                {
                    throw new InvalidOperationException(Res.GetString("WebSchemaNotFound"));
                }
                base.Response.ContentType = ContentType.Compose("text/xml", encoding);
                schema.Write(new StreamWriter(outputStream, encoding));
            }
            else
            {
                id = base.Request.QueryString["wsdl"];
                if (id != null)
                {
                    ServiceDescription serviceDescription = this.serverType.GetServiceDescription(id);
                    if (serviceDescription == null)
                    {
                        throw new InvalidOperationException(Res.GetString("ServiceDescriptionWasNotFound0"));
                    }
                    base.Response.ContentType = ContentType.Compose("text/xml", encoding);
                    serviceDescription.Write(new StreamWriter(outputStream, encoding));
                }
                else
                {
                    string strA = base.Request.QueryString[null];
                    if ((strA != null) && (string.Compare(strA, "wsdl", StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        base.Response.ContentType = ContentType.Compose("text/xml", encoding);
                        this.serverType.Description.Write(new StreamWriter(outputStream, encoding));
                    }
                    else
                    {
                        if ((strA == null) || (string.Compare(strA, "disco", StringComparison.OrdinalIgnoreCase) != 0))
                        {
                            throw new InvalidOperationException(Res.GetString("internalError0"));
                        }
                        base.Response.ContentType = ContentType.Compose("text/xml", encoding);
                        this.serverType.Disco.Write(new StreamWriter(outputStream, encoding));
                    }
                }
            }
        }
    public static void Main()
    {
        // Read a ServiceDescription of existing WSDL.
        myServiceDescription = ServiceDescription.Read("Input_CS.wsdl");
        // Get the ServiceCollection of the ServiceDescription.
        ServiceCollection myServiceCollection = myServiceDescription.Services;

        MyMethod(myServiceCollection);
        BindingCollection myBindingCollection = myServiceDescription.Bindings;

        MyMethod(myBindingCollection);
        PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes;

        MyMethod(myPortTypeCollection);
        myServiceDescription.Write("Output.Wsdl");
    }
Esempio n. 30
0
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimePart_3_Input_cs.wsdl");
        ServiceDescriptionCollection myServiceDescriptionCol =
            new ServiceDescriptionCollection();

        myServiceDescriptionCol.Add(myServiceDescription);
        XmlQualifiedName myXmlQualifiedName =
            new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");

        // Create the Binding.
        Binding myBinding =
            myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
        OperationBinding myOperationBinding = null;

        for (int i = 0; i < myBinding.Operations.Count; i++)
        {
            if (myBinding.Operations[i].Name.Equals("AddNumbers"))
            {
                myOperationBinding = myBinding.Operations[i];
            }
        }
// <Snippet2>
// <Snippet3>
        // Create the OutputBinding.
        OutputBinding  myOutputBinding  = myOperationBinding.Output;
        MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

        myMimeXmlBinding.Part = "body";

        // Create the MimePart.
        MimePart myMimePart = new MimePart();

        myMimePart.Extensions.Add(myMimeXmlBinding);
        MimeMultipartRelatedBinding myMimePartRelatedBinding =
            new MimeMultipartRelatedBinding();

        // Add the MimePart to the MimePartRelatedBinding.
        myMimePartRelatedBinding.Parts.Add(myMimePart);
        myOutputBinding.Extensions.Add(myMimePartRelatedBinding);
// </Snippet3>
// </Snippet2>
        myServiceDescription.Write("MimePart_3_Output_CS.wsdl");
        Console.WriteLine(
            "MimePart_3_Output_CS.wsdl has been generated successfully.");
    }