Beispiel #1
0
        void CreateOutputBinding(ServiceEndpoint endpoint, OperationBinding op_binding,
                                 MessageDescription sm_md)
        {
            var out_binding = new OutputBinding();

            op_binding.Output = out_binding;

            var message_version = endpoint.Binding.MessageVersion ?? MessageVersion.None;

            if (message_version == MessageVersion.None)
            {
                return;
            }

            SoapBodyBinding soap_body_binding;

            if (message_version.Envelope == EnvelopeVersion.Soap11)
            {
                soap_body_binding = new SoapBodyBinding();
            }
            else if (message_version.Envelope == EnvelopeVersion.Soap12)
            {
                soap_body_binding = new Soap12BodyBinding();
            }
            else
            {
                throw new InvalidOperationException();
            }

            soap_body_binding.Use = SoapBindingUse.Literal;
            out_binding.Extensions.Add(soap_body_binding);
        }
// <Snippet8>
    // Used to create OperationBinding instances within 'Binding'.
    public static OperationBinding CreateOperationBinding(string operation, string targetNamespace)
    {
        // Create OperationBinding instance for operation.
        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = operation;
        // Create InputBinding for operation.
        InputBinding    myInputBinding    = new InputBinding();
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        mySoapBodyBinding.Use = SoapBindingUse.Literal;
        myInputBinding.Extensions.Add(mySoapBodyBinding);
        // Create OutputBinding for operation.
        OutputBinding myOutputBinding = new OutputBinding();

        myOutputBinding.Extensions.Add(mySoapBodyBinding);
        // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'.
        myOperationBinding.Input  = myInputBinding;
        myOperationBinding.Output = myOutputBinding;
        // Create extensibility element for 'SoapOperationBinding'.
        SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();

        mySoapOperationBinding.Style      = SoapBindingStyle.Document;
        mySoapOperationBinding.SoapAction = targetNamespace + operation;
        // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'.
        myOperationBinding.Extensions.Add(mySoapOperationBinding);
        return(myOperationBinding);
    }
    // Used to create OperationBinding instances within Binding.
    public static OperationBinding CreateOperationBinding(
        string myOperation, string targetNamespace)
    {
        // Create OperationBinding for Operation.
        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = myOperation;

        // Create InputBinding for operation.
        InputBinding myInputBinding =
            (InputBinding)CreateInputOutputBinding(null, true);

        // Create OutputBinding for operation.
        OutputBinding myOutputBinding =
            (OutputBinding)CreateInputOutputBinding(null, false);

        // Add InputBinding and OutputBinding to OperationBinding.
        myOperationBinding.Input  = myInputBinding;
        myOperationBinding.Output = myOutputBinding;

        // Create an extensibility element for SoapOperationBinding.
        SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();

        mySoapOperationBinding.Style      = SoapBindingStyle.Document;
        mySoapOperationBinding.SoapAction = targetNamespace + myOperation;

        // Add the extensibility element SoapOperationBinding to OperationBinding.
        myOperationBinding.Extensions.Add(mySoapOperationBinding);
        return(myOperationBinding);
    }
    public static MessageBinding CreateInputOutputBinding(string myBindName,
                                                          bool isInputBinding)
    {
// <Snippet2>

        // Value isInputBinding = true ---> return type = InputBinding.
        // Value isInputBinding = false --> return type = OutputBinding.
// <Snippet3>
// <Snippet4>
        MessageBinding myMessageBinding = null;

        switch (isInputBinding)
        {
        case true:
            myMessageBinding = new InputBinding();
            Console.WriteLine("Added an InputBinding");
            break;

        case false:
            myMessageBinding = new OutputBinding();
            Console.WriteLine("Added an OutputBinding");
            break;
        }
// </Snippet2>
        myMessageBinding.Name = myBindName;
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        mySoapBodyBinding.Use = SoapBindingUse.Literal;
        myMessageBinding.Extensions.Add(mySoapBodyBinding);
        Console.WriteLine("Added extensibility element of type : " +
                          mySoapBodyBinding.GetType());
// </Snippet3>
// </Snippet4>
        return(myMessageBinding);
    }
            public void BlobToQueue(
                [BlobTrigger("container2/%file%")] string blob,
                [Queue("queue2")] OutputBinding <string> queueOutput)

            {
                throw new NotImplementedException();
            }
Beispiel #6
0
        static void Main()
        {
// <Snippet1>
// <Snippet2>
// <Snippet3>
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MimeContentSample_cs.wsdl");

            // Get the Binding.
            Binding myBinding = myServiceDescription.Bindings["b1"];

            // Get the first OperationBinding.
            OperationBinding myOperationBinding = myBinding.Operations[0];
            OutputBinding    myOutputBinding    = myOperationBinding.Output;
            ServiceDescriptionFormatExtensionCollection
                myServiceDescriptionFormatExtensionCollection =
                myOutputBinding.Extensions;

            // Find all MimeContentBinding objects in extensions.
            MimeContentBinding[] myMimeContentBindings = (MimeContentBinding[])
                                                         myServiceDescriptionFormatExtensionCollection.FindAll(
                typeof(MimeContentBinding));

            // Enumerate the array and display MimeContentBinding properties.
            foreach (MimeContentBinding myMimeContentBinding in
                     myMimeContentBindings)
            {
                Console.WriteLine("Type: " + myMimeContentBinding.Type);
                Console.WriteLine("Part: " + myMimeContentBinding.Part);
            }
// </Snippet1>
// </Snippet2>
            Console.WriteLine("Namespace: " + MimeContentBinding.Namespace);
// </Snippet3>
        }
Beispiel #7
0
        public void Bind_GivenNoParameterWithTheCorrectName_Throw()
        {
            var binding    = new OutputBinding();
            var parameters = new Dictionary <string, string>();
            var info       = new BindingTest().GetType().GetMethod("Test").GetParameters().First();

            binding.Bind(parameters, info);
        }
Beispiel #8
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);
        }
    }
    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.");
    }
Beispiel #10
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'.");
    }
Beispiel #11
0
        public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,
                                           [Queue("functionstesting2", Connection = "AzureWebJobsStorage")] OutputBinding <string> name)
        {
            var response = new HttpResponseData(HttpStatusCode.OK);

            response.Body = "Success!!";

            name.SetValue("some name");

            return(response);
        }
Beispiel #12
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.");
    }
Beispiel #13
0
        public static HttpResponseData Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req, [Blob("test-samples/sample1.txt", Connection = "AzureWebJobsStorage")] string myBlob,
            [Queue("functionstesting2", Connection = "AzureWebJobsStorage")] OutputBinding <Book> book)
        {
            var bookVal = (Book)JsonSerializer.Deserialize(myBlob, typeof(Book));

            book.SetValue(bookVal);
            var response = new HttpResponseData(HttpStatusCode.OK);
            var headers  = new Dictionary <string, string>();

            headers.Add("Date", "Mon, 18 Jul 2016 16:06:00 GMT");
            headers.Add("Content", "Content - Type: text / html; charset = utf - 8");

            response.Headers = headers;
            response.Body    = "Book Sent to Queue!";

            return(response);
        }
Beispiel #14
0
        public void Bind_GivenAParameterContaining_Throw()
        {
            var binding    = new OutputBinding();
            var parameters = new Dictionary <string, string> {
                { "output", "{ 'CheckSumAsHash': 'd3dc4e53a3ac7a5a106dfde2a5c71243', 'ClientUserGuid': '3a00d580-a0a0-4b84-bb8f-e4e819bbceeb', 'ClientBrowserUserAgent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36', 'ClientDeviceIPAddressAsHash': 'f6c28486c968d4582bd488ca2d67b50d', 'Response': { 'RadioButtonSelection': '0', 'DontknowSelection': '0', 'FreeText': 'Helle Helle', 'Grading': '30', 'Log': 'Any debug info you may need, e.g. streaming issues etc' }, 'Events': [ { 'DateTime': '2015-01-07T07:06.560Z', 'Type': 'TrialStart' }, { 'DateTime': '2015-01-07T07:08.560Z', 'Type': 'StimulusStart' }, { 'DateTime': '2015-01-07T08:09.560Z', 'Type': 'ReponseStart' }, { 'DateTime': '2015-01-07T08:12.560Z', 'Type': 'ResponseStop' }, { 'DateTime': '2015-01-07T07:56.560Z', 'Type': 'TrialStop' } ] }" }
            };
            var info = new BindingTest().GetType().GetMethod("Test").GetParameters().First();

            var result = (OutputDto)binding.Bind(parameters, info);

            Assert.That(result.ComplexValues.Count, Is.EqualTo(1));
            Assert.That(result.MultiValues.Count, Is.EqualTo(1));
            Assert.That(result.SingleValues.Count, Is.EqualTo(4));
            Assert.That(result.MultiValues.First().Key, Is.EqualTo("Events"));
            Assert.That(result.ComplexValues.First().Key, Is.EqualTo("Response"));
            Assert.That(result.ComplexValues.First().Value.SingleValues.First().Key, Is.EqualTo("RadioButtonSelection"));
            Assert.That(result.ComplexValues.First().Value.SingleValues.First().Value, Is.EqualTo("0"));
        }
        void CheckBasicHttpBinding(WSServiceDescription wsd, string binding_name, XmlQualifiedName binding_type,
                                   string operation_name, string action, bool has_input, bool has_output, string label)
        {
            WSBinding        b  = GetBinding(wsd, binding_name, label);
            OperationBinding op = GetOperationBinding(b, operation_name, label + " CheckBasicHttpBinding");

            Assert.AreEqual(binding_type, b.Type, label + " #cbh0");

            if (has_input)
            {
                InputBinding inb = op.Input;
                Assert.IsNotNull(inb, label + " #cbh1");
                Assert.AreEqual(1, inb.Extensions.Count, label + " #cbh2");

                Assert.AreEqual(typeof(SoapBodyBinding), inb.Extensions [0].GetType(), label + " #cbh3");
                SoapBodyBinding soap_binding = (SoapBodyBinding)inb.Extensions [0];
                Assert.AreEqual(SoapBindingUse.Literal, soap_binding.Use, label + " #cbh4");

                if (action != null)
                {
                    Assert.AreEqual(1, op.Extensions.Count, label + " #chb5");
                    Assert.AreEqual(typeof(SoapOperationBinding), op.Extensions [0].GetType(), label + " #cbh6");
                    SoapOperationBinding sopb = (SoapOperationBinding)op.Extensions [0];
                    Assert.AreEqual(action, sopb.SoapAction, label + " #cbh7");
                }
            }

            if (has_output)
            {
                OutputBinding outb = op.Output;
                Assert.IsNotNull(outb, label + " #cbh10");
                Assert.AreEqual(1, outb.Extensions.Count, label + " #cbh11");

                Assert.AreEqual(typeof(SoapBodyBinding), outb.Extensions [0].GetType(), label + " #cbh12");
                SoapBodyBinding soap_binding = (SoapBodyBinding)outb.Extensions [0];
                Assert.AreEqual(SoapBindingUse.Literal, soap_binding.Use, label + " #cbh13");
            }

            Assert.AreEqual(1, b.Extensions.Count, label + " #cbh20");
            Assert.AreEqual(typeof(SoapBinding), b.Extensions [0].GetType(), label + " #cbh21");
            SoapBinding sb = (SoapBinding)b.Extensions [0];

            Assert.AreEqual(SoapBinding.HttpTransport, sb.Transport, label + " #cbh22");
        }
        static void Main()
        {
// <Snippet2>
            ServiceDescription myServicDescription =
                ServiceDescription.Read("MimeMultiPartRelatedSample_cs.wsdl");

            // Get the binding collection.
            BindingCollection myBindingCollection = myServicDescription.Bindings;
            int index = 0;

            for (int i = 0; i < myBindingCollection.Count; i++)
            {
                // Get the collection for MimeServiceHttpPost.
                if (myBindingCollection[i].Name == "MimeServiceHttpPost")
                {
                    OperationBindingCollection myOperationBindingCollection =
                        myBindingCollection[i].Operations;
                    OutputBinding myOutputBinding =
                        myOperationBindingCollection[0].Output;
                    ServiceDescriptionFormatExtensionCollection
                        myServiceDescriptionFormatExtensionCollection =
                        myOutputBinding.Extensions;
                    MimeMultipartRelatedBinding myMimeMultipartRelatedBinding =
                        (MimeMultipartRelatedBinding)
                        myServiceDescriptionFormatExtensionCollection.Find(
                            typeof(MimeMultipartRelatedBinding));
                    MimePartCollection myMimePartCollection =
                        myMimeMultipartRelatedBinding.Parts;
                    foreach (MimePart myMimePart in myMimePartCollection)
                    {
                        Console.WriteLine("Extension types added to MimePart: " +
                                          index++);
                        Console.WriteLine("----------------------------");
                        foreach (object myExtension in myMimePart.Extensions)
                        {
                            Console.WriteLine(myExtension.GetType());
                        }
                        Console.WriteLine();
                    }
                    break;
                }
            }
// </Snippet2>
        }
Beispiel #17
0
        private void AddBindingOperation(OperationDefinition operationDefinition)
        {
            var inputBinding = new InputBinding();

            AddOperationMessageBindingContent(operationDefinition.InputBinaryMode, inputBinding);

            var outputBinding = new OutputBinding();

            AddOperationMessageBindingContent(operationDefinition.OutputBinaryMode, outputBinding);

            binding.Operations.Add(new OperationBinding
            {
                Name       = operationDefinition.Name.LocalName,
                Extensions =
                {
                    CreateXRoadOperationVersionBinding(operationDefinition),
                    protocol.Style.CreateSoapOperationBinding()
                },
                Input  = inputBinding,
                Output = outputBinding
            });
        }
        public static void Run([CosmosDBTrigger(
                                    databaseName: "%CosmosDb%",
                                    collectionName: "%CosmosCollIn%",
                                    ConnectionStringSetting = "CosmosConnection",
                                    LeaseCollectionName = "leases",
                                    CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <MyDocument> input,
                               [CosmosDB(
                                    databaseName: "%CosmosDb%",
                                    collectionName: "%CosmosCollOut%",
                                    ConnectionStringSetting = "CosmosConnection",
                                    CreateIfNotExists = true)] OutputBinding <IEnumerable <object> > output,
                               FunctionExecutionContext context)
        {
            if (input != null && input.Count > 0)
            {
                foreach (var doc in input)
                {
                    context.Logger.LogInformation($"id: {doc.Id}");
                }

                output.SetValue(input.Select(p => new { id = p.Id }));
            }
        }
Beispiel #19
0
// </Snippet13>
// <Snippet3>
    // Used to create OperationBinding instances within 'Binding'.
    public static OperationBinding CreateOperationBinding(string operation,
                                                          string targetNamespace)
    {
        // Create OperationBinding for operation.
        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = operation;
// <Snippet1>
// <Snippet2>
        // Create InputBinding for operation.
        InputBinding    myInputBinding    = new InputBinding();
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        mySoapBodyBinding.Use = SoapBindingUse.Literal;
        myInputBinding.Extensions.Add(mySoapBodyBinding);
// </Snippet2>
// </Snippet1>
        // Create OutputBinding for operation.
        OutputBinding myOutputBinding = new OutputBinding();

        myOutputBinding.Extensions.Add(mySoapBodyBinding);

        // Add InputBinding and OutputBinding to OperationBinding.
        myOperationBinding.Input  = myInputBinding;
        myOperationBinding.Output = myOutputBinding;

        // Create an extensibility element for SoapOperationBinding.
        SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();

        mySoapOperationBinding.Style      = SoapBindingStyle.Document;
        mySoapOperationBinding.SoapAction = targetNamespace + operation;

        // Add the extensibility element SoapOperationBinding to OperationBinding.
        myOperationBinding.Extensions.Add(mySoapOperationBinding);
        return(myOperationBinding);
    }
 public void QueueToBlob(
     [QueueTrigger("queueName", Connection = "MyConnection")] string queuePayload,
     [Blob("container1/hello.txt", FileAccess.ReadWrite, Connection = "MyOtherConnection")] OutputBinding <string> blobOutput)
 {
     throw new NotImplementedException();
 }
        private static List <ServiceEndpoint> ConstructBindings(InterfaceContract serviceInterfaceContract, System.Web.Services.Description.ServiceDescription desc, string portTypeName, PortType portType)
        {
            // Here we have a list of WCF endpoints.
            // Currently we populate this list with only two endpoints that has default
            // BasicHttpBinding and default NetTcpBinding.
            List <ServiceEndpoint> endpoints = new List <ServiceEndpoint>();

            BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

            endpoints.Add(ServiceEndpointFactory <IDummyContract> .CreateServiceEndpoint(basicHttpBinding));

            // BDS (10/22/2007): Commented out the TCP binding generation as we are not going to support this feature
            // in this version.
            //NetTcpBinding netTcpBinding = new NetTcpBinding();
            //endpoints.Add(ServiceEndpointFactory<IDummyContract>.CreateServiceEndpoint(netTcpBinding));

            // Now, for each endpoint we have to create a binding in our service description.
            foreach (ServiceEndpoint endpoint in endpoints)
            {
                // Create a WSDL BindingCollection.
                BindingCollection bindings = desc.Bindings;
                System.Web.Services.Description.Binding binding = new System.Web.Services.Description.Binding();
                binding.Name = endpoint.Name.Replace(Constants.InternalContractName, portTypeName);
                binding.Type = new XmlQualifiedName(portType.Name, desc.TargetNamespace);

                // Create Operation binding for each operation and add it the the BindingCollection.
                foreach (Operation op in serviceInterfaceContract.Operations)
                {
                    // SOAP 1.1 Operation bindings.
                    OperationBinding operationBinding1 = new OperationBinding();
                    operationBinding1.Name = op.Name;

                    InputBinding inputBinding1        = new InputBinding();
                    object       bodyBindingExtension = GetSoapBodyBinding(endpoint.Binding);
                    if (bodyBindingExtension != null)
                    {
                        inputBinding1.Extensions.Add(bodyBindingExtension);
                    }
                    operationBinding1.Input = inputBinding1;

                    // Input message.
                    // Look up the message headers for each Message and add them to the current binding.
                    foreach (MessageHeader inHeader in op.MessagesCollection[0].HeadersCollection)
                    {
                        object headerBindingExtension = GetSoapHeaderBinding(endpoint.Binding, inHeader.Message, desc.TargetNamespace);
                        if (headerBindingExtension != null)
                        {
                            inputBinding1.Extensions.Add(headerBindingExtension);
                        }
                    }

                    if (op.Mep == Mep.RequestResponse)
                    {
                        // Output message.
                        OutputBinding outputBinding1 = new OutputBinding();
                        object        responseBodyBindingExtension = GetSoapBodyBinding(endpoint.Binding);
                        if (responseBodyBindingExtension != null)
                        {
                            outputBinding1.Extensions.Add(responseBodyBindingExtension);
                        }
                        operationBinding1.Output = outputBinding1;

                        // Look up the message headers for each Message and add them to the current binding.
                        foreach (MessageHeader outHeader in op.MessagesCollection[1].HeadersCollection)
                        {
                            object headerBindingExtension = GetSoapHeaderBinding(endpoint.Binding, outHeader.Message, desc.TargetNamespace);
                            if (headerBindingExtension != null)
                            {
                                outputBinding1.Extensions.Add(headerBindingExtension);
                            }
                        }
                    }

                    string action = desc.TargetNamespace + ":" + op.Input.Name;
                    object operationBindingExtension = GetSoapOperationBinding(endpoint.Binding, action);
                    if (operationBindingExtension != null)
                    {
                        operationBinding1.Extensions.Add(operationBindingExtension);
                    }

                    binding.Operations.Add(operationBinding1);
                    // End of SOAP 1.1 operation bindings.
                }

                object soapBindingExtension = GetSoapBinding(endpoint.Binding);
                if (soapBindingExtension != null)
                {
                    binding.Extensions.Add(soapBindingExtension);
                }
                bindings.Add(binding);
            }
            return(endpoints);
        }
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("SoapBindingStyleInput_cs.wsdl");
        Binding myBinding = new Binding();

        myBinding.Name = "SOAPSvrMgr_SOAPBinding";
        myBinding.Type = new XmlQualifiedName("tns:SOAPSvrMgr_portType");

// <Snippet1>
        SoapBinding mySoapBinding = new SoapBinding();

        mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
        // Message to be transmitted contains parameters to call a procedure.
        mySoapBinding.Style = SoapBindingStyle.Rpc;
        myBinding.Extensions.Add(mySoapBinding);
// </Snippet1>

        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = "GetServerStats";

        SoapOperationBinding mySoapOperationBinding =
            new SoapOperationBinding();

        mySoapOperationBinding.SoapAction =
            "http://tempuri.org/soapsvcmgr/GetServerStats";
        myOperationBinding.Extensions.Add(mySoapOperationBinding);

        // Create InputBinding for operation for the 'SOAP' protocol.
        InputBinding myInputBinding = new InputBinding();
// <Snippet2>
// <Snippet3>
// <Snippet4>
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        // Encode SOAP body using rules specified by the 'Encoding' property.
        mySoapBodyBinding.Use = SoapBindingUse.Encoded;
        // Set URI representing the encoding style for encoding the body.
        mySoapBodyBinding.Encoding = "http://schemas.xmlsoap.org/soap/encoding/";
        // Set the Uri representing the location of the specification
        // for encoding of content not defined by 'Encoding' property'.
        mySoapBodyBinding.Namespace = "http://tempuri.org/soapsvcmgr/";
        myInputBinding.Extensions.Add(mySoapBodyBinding);
// </Snippet4>
// </Snippet3>
// </Snippet2>

// <Snippet5>
// <Snippet6>
        SoapHeaderBinding mySoapHeaderBinding = new SoapHeaderBinding();

        mySoapHeaderBinding.Message =
            new XmlQualifiedName("tns:Soapsvcmgr_Headers_Request");
        mySoapHeaderBinding.Part = "AuthCS";
        // Encode SOAP header using rules specified by the 'Encoding' property.
        mySoapHeaderBinding.Use = SoapBindingUse.Encoded;
        // Set URI representing the encoding style for encoding the header.
        mySoapHeaderBinding.Encoding = "http://schemas.xmlsoap.org/soap/encoding/";
        // Set the Uri representing the location of the specification
        // for encoding of content not defined by 'Encoding' property'.
        mySoapHeaderBinding.Namespace = "http://tempuri.org/SOAPSvr/soapsvcmgr/headers.xsd";
        // Add mySoapHeaderBinding to the 'myInputBinding' object.
        myInputBinding.Extensions.Add(mySoapHeaderBinding);
// </Snippet5>
// </Snippet6>
        // Create OutputBinding for operation.
        OutputBinding myOutputBinding = new OutputBinding();

        myOutputBinding.Extensions.Add(mySoapBodyBinding);
        mySoapHeaderBinding.Part    = "AuthSC";
        mySoapHeaderBinding.Message =
            new XmlQualifiedName("tns:Soapsvcmgr_Headers_Response");
        myOutputBinding.Extensions.Add(mySoapHeaderBinding);

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

        myServiceDescription.Bindings.Add(myBinding);
        myServiceDescription.Write("SoapBindingStyleOutput_cs.wsdl");
        Console.WriteLine("'SoapBindingStyleOutput_cs.wsdl' file is generated.");
        Console.WriteLine("Proxy could be created using command" +
                          " 'wsdl SoapBindingStyleOutput_cs.wsdl'");
    }
Beispiel #23
0
    public static void Main()
    {
        try
        {
            ServiceDescription myDescription =
                ServiceDescription.Read("Operation_2_Input_CS.wsdl");
            Binding myBinding = new Binding();
            myBinding.Name = "Operation_2_ServiceHttpPost";
            XmlQualifiedName myQualifiedName =
                new XmlQualifiedName("s0:Operation_2_ServiceHttpPost");
            myBinding.Type = myQualifiedName;
            HttpBinding myHttpBinding = new HttpBinding();
            myHttpBinding.Verb = "POST";
            // Add the 'HttpBinding' to the 'Binding'.
            myBinding.Extensions.Add(myHttpBinding);
            OperationBinding myOperationBinding = new OperationBinding();
            myOperationBinding.Name = "AddNumbers";
            HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding();
            myHttpOperationBinding.Location = "/AddNumbers";
            // Add the 'HttpOperationBinding' to 'OperationBinding'.
            myOperationBinding.Extensions.Add(myHttpOperationBinding);
            InputBinding       myInputBinding           = new InputBinding();
            MimeContentBinding myPostMimeContentbinding = new MimeContentBinding();
            myPostMimeContentbinding.Type = "application/x-www-form-urlencoded";
            myInputBinding.Extensions.Add(myPostMimeContentbinding);
            // Add the 'InputBinding' to 'OperationBinding'.
            myOperationBinding.Input = myInputBinding;
            OutputBinding  myOutputBinding      = new OutputBinding();
            MimeXmlBinding myPostMimeXmlbinding = new MimeXmlBinding();
            myPostMimeXmlbinding.Part = "Body";
            myOutputBinding.Extensions.Add(myPostMimeXmlbinding);
            // 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);
            Port myPostPort = new Port();
            myPostPort.Name    = "Operation_2_ServiceHttpPost";
            myPostPort.Binding = new XmlQualifiedName("s0:Operation_2_ServiceHttpPost");
            HttpAddressBinding myPostAddressBinding = new HttpAddressBinding();
            myPostAddressBinding.Location =
                "http://localhost/Operation_2/Operation_2_Service.cs.asmx";
            // Add the 'HttpAddressBinding' to the 'Port'.
            myPostPort.Extensions.Add(myPostAddressBinding);
            // Add the 'Port' to 'PortCollection' of 'ServiceDescription'.
            myDescription.Services[0].Ports.Add(myPostPort);
            PortType myPostPortType = new PortType();
            myPostPortType.Name = "Operation_2_ServiceHttpPost";
            Operation myPostOperation = new Operation();
            myPostOperation.Name = "AddNumbers";
            OperationMessage myPostOperationInput = (OperationMessage) new OperationInput();
            myPostOperationInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn");
            OperationMessage myPostOperationOutput = (OperationMessage) new OperationOutput();
            myPostOperationOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostout");
            myPostOperation.Messages.Add(myPostOperationInput);
            myPostOperation.Messages.Add(myPostOperationOutput);
            // Add the 'Operation' to 'PortType'.
            myPostPortType.Operations.Add(myPostOperation);
            // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'.
            myDescription.PortTypes.Add(myPostPortType);
            Message myPostMessage1 = new Message();
            myPostMessage1.Name = "AddNumbersHttpPostIn";
            MessagePart myPostMessagePart1 = new MessagePart();
            myPostMessagePart1.Name = "firstnumber";
            myPostMessagePart1.Type = new XmlQualifiedName("s:string");
            MessagePart myPostMessagePart2 = new MessagePart();
            myPostMessagePart2.Name = "secondnumber";
            myPostMessagePart2.Type = new XmlQualifiedName("s:string");
            // Add the 'MessagePart' objects to 'Messages'.
            myPostMessage1.Parts.Add(myPostMessagePart1);
            myPostMessage1.Parts.Add(myPostMessagePart2);
            Message myPostMessage2 = new Message();
            myPostMessage2.Name = "AddNumbersHttpPostout";
            MessagePart myPostMessagePart3 = new MessagePart();
            myPostMessagePart3.Name    = "Body";
            myPostMessagePart3.Element = new XmlQualifiedName("s0:int");
            // Add the 'MessagePart' to 'Message'.
            myPostMessage2.Parts.Add(myPostMessagePart3);
            // Add the 'Message' objects to 'ServiceDescription'.
            myDescription.Messages.Add(myPostMessage1);
            myDescription.Messages.Add(myPostMessage2);
            // Write the 'ServiceDescription' as a WSDL file.
            myDescription.Write("Operation_2_Output_CS.wsdl");
            Console.WriteLine(" 'Operation_2_Output_CS.wsdl' file created Successfully");
// <Snippet1>
// <Snippet2>
            string    myString    = null;
            Operation myOperation = new Operation();
            myDescription = ServiceDescription.Read("Operation_2_Input_CS.wsdl");
            Message[] myMessage = new Message[myDescription.Messages.Count];

            // Copy the messages from the service description.
            myDescription.Messages.CopyTo(myMessage, 0);
            for (int i = 0; i < myDescription.Messages.Count; i++)
            {
                MessagePart[] myMessagePart =
                    new MessagePart[myMessage[i].Parts.Count];

                // Copy the message parts into a MessagePart.
                myMessage[i].Parts.CopyTo(myMessagePart, 0);
                for (int j = 0; j < myMessage[i].Parts.Count; j++)
                {
                    myString += myMessagePart[j].Name;
                    myString += " ";
                }
            }
            // Set the ParameterOrderString equal to the list of
            // message part names.
            myOperation.ParameterOrderString = myString;
            string[] myString1 = myOperation.ParameterOrder;
            int      k         = 0;
            Console.WriteLine("The list of message part names is as follows:");
            while (k < 5)
            {
                Console.WriteLine(myString1[k]);
                k++;
            }
// </Snippet2>
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("The following Exception is raised : " + e.Message);
        }
    }
Beispiel #24
0
    public static void Main()
    {
        try
        {
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MimeText_Binding_Match_8_Input_CS.wsdl");

            // Create a Binding.
            Binding myBinding = new Binding();

            // Initialize the Name property of the Binding.
            myBinding.Name = "MimeText_Binding_MatchServiceHttpPost";
            XmlQualifiedName myXmlQualifiedName =
                new XmlQualifiedName("s0:MimeText_Binding_MatchServiceHttpPost");
            myBinding.Type = myXmlQualifiedName;

            // Create an HttpBinding.
            HttpBinding myHttpBinding = new HttpBinding();
            myHttpBinding.Verb = "POST";

            // Add the HttpBinding to the Binding.
            myBinding.Extensions.Add(myHttpBinding);

            // Create an OperationBinding.
            OperationBinding myOperationBinding = new OperationBinding();
            myOperationBinding.Name = "AddNumbers";

            HttpOperationBinding myHttpOperationBinding =
                new HttpOperationBinding();
            myHttpOperationBinding.Location = "/AddNumbers";

            // Add the HttpOperationBinding to the OperationBinding.
            myOperationBinding.Extensions.Add(myHttpOperationBinding);

            // Create an InputBinding.
            InputBinding       myInputBinding         = new InputBinding();
            MimeContentBinding postMimeContentbinding = new MimeContentBinding();
            postMimeContentbinding.Type = "application/x-www-form-urlencoded";
            myInputBinding.Extensions.Add(postMimeContentbinding);

            // Add the InputBinding to the OperationBinding.
            myOperationBinding.Input = myInputBinding;
// <Snippet8>
// <Snippet7>
// <Snippet6>
// <Snippet5>
// <Snippet4>
// <Snippet3>
// <Snippet2>
            // Create an OutputBinding.
            OutputBinding myOutputBinding = new OutputBinding();

            // Create a MimeTextBinding.
            MimeTextBinding myMimeTextBinding = new MimeTextBinding();

            // Create a MimeTextMatch.
            MimeTextMatch           myMimeTextMatch = new MimeTextMatch();
            MimeTextMatchCollection myMimeTextMatchCollection;

            // Initialize properties of the MimeTextMatch.
            myMimeTextMatch.Name       = "Title";
            myMimeTextMatch.Type       = "*/*";
            myMimeTextMatch.Pattern    = "'TITLE&gt;(.*?)&lt;";
            myMimeTextMatch.IgnoreCase = true;

            // Initialize a MimeTextMatchCollection.
            myMimeTextMatchCollection = myMimeTextBinding.Matches;

            // Add the MimeTextMatch to the MimeTextMatchCollection.
            myMimeTextMatchCollection.Add(myMimeTextMatch);
            myOutputBinding.Extensions.Add(myMimeTextBinding);

            // Add the OutputBinding to the OperationBinding.
            myOperationBinding.Output = myOutputBinding;
// </Snippet2>
// </Snippet3>
// </Snippet4>
// </Snippet5>
// </Snippet6>
// </Snippet7>
// </Snippet8>
            // Add the OutputBinding to the OperationBinding.
            myOperationBinding.Output = myOutputBinding;

            // Add the OperationBinding to the Binding.
            myBinding.Operations.Add(myOperationBinding);

            // Add the Binding to the BindingCollection of the ServiceDescription.
            myServiceDescription.Bindings.Add(myBinding);

            // Write the ServiceDescription as a WSDL file.
            myServiceDescription.Write("MimeText_Binding_Match_8_Output_CS.wsdl");
            Console.WriteLine(
                "WSDL file named 'MimeText_Binding_Match_8_Output_CS.wsdl' was"
                + " created successfully.");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
Beispiel #25
0
    public static void Main()
    {
        ServiceDescription myDescription = ServiceDescription.Read("AddNumbers1.wsdl");

        // Create the 'Binding' object.
        Binding myBinding = new Binding();

        myBinding.Name = "Service1HttpPost";
        XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1HttpPost");

        myBinding.Type = qualifiedName;

// <Snippet1>
// <Snippet2>

        // Create the 'HttpBinding' object.
        HttpBinding myHttpBinding = new HttpBinding();

        myHttpBinding.Verb = "POST";
        // Add the 'HttpBinding' to the 'Binding'.
        myBinding.Extensions.Add(myHttpBinding);
// </Snippet2>
// </Snippet1>

        // Create the 'OperationBinding' object.
        OperationBinding myOperationBinding = new OperationBinding();

        myOperationBinding.Name = "AddNumbers";

        HttpOperationBinding myOperation = new HttpOperationBinding();

        myOperation.Location = "/AddNumbers";
        // Add the 'HttpOperationBinding' to 'OperationBinding'.
        myOperationBinding.Extensions.Add(myOperation);

        // Create the 'InputBinding' object.
        InputBinding       myInput = new InputBinding();
        MimeContentBinding postMimeContentbinding = new MimeContentBinding();

        postMimeContentbinding.Type = "application/x-www-form-urlencoded";
        myInput.Extensions.Add(postMimeContentbinding);
        // Add the 'InputBinding' to 'OperationBinding'.
        myOperationBinding.Input = myInput;
        // Create the 'OutputBinding' object.
        OutputBinding  myOutput           = new OutputBinding();
        MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding();

        postMimeXmlbinding.Part = "Body";
        myOutput.Extensions.Add(postMimeXmlbinding);

        // Add 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);

        // Create  a 'Port' object.
        Port postPort = new Port();

        postPort.Name    = "Service1HttpPost";
        postPort.Binding = new XmlQualifiedName("s0:Service1HttpPost");

// <Snippet3>
// <Snippet4>

        // Create the 'HttpAddressBinding' object.
        HttpAddressBinding postAddressBinding = new HttpAddressBinding();

        postAddressBinding.Location = "http://localhost/Service1.asmx";

        // Add the 'HttpAddressBinding' to the 'Port'.
        postPort.Extensions.Add(postAddressBinding);
// </Snippet4>
// </Snippet3>

        // Add the 'Port' to 'PortCollection' of 'ServiceDescription'.
        myDescription.Services[0].Ports.Add(postPort);

        // Create a 'PortType' object.
        PortType postPortType = new PortType();

        postPortType.Name = "Service1HttpPost";

        Operation postOperation = new Operation();

        postOperation.Name = "AddNumbers";

        OperationMessage postInput = (OperationMessage) new OperationInput();

        postInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn");
        OperationMessage postOutput = (OperationMessage) new OperationOutput();

        postOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut");

        postOperation.Messages.Add(postInput);
        postOperation.Messages.Add(postOutput);

        // Add the 'Operation' to 'PortType'.
        postPortType.Operations.Add(postOperation);

        // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'.
        myDescription.PortTypes.Add(postPortType);

        // Create the 'Message' object.
        Message postMessage1 = new Message();

        postMessage1.Name = "AddNumbersHttpPostIn";
        // Create the 'MessageParts'.
        MessagePart postMessagePart1 = new MessagePart();

        postMessagePart1.Name = "firstnumber";
        postMessagePart1.Type = new XmlQualifiedName("s:string");

        MessagePart postMessagePart2 = new MessagePart();

        postMessagePart2.Name = "secondnumber";
        postMessagePart2.Type = new XmlQualifiedName("s:string");
        // Add the 'MessagePart' objects to 'Messages'.
        postMessage1.Parts.Add(postMessagePart1);
        postMessage1.Parts.Add(postMessagePart2);

        // Create another 'Message' object.
        Message postMessage2 = new Message();

        postMessage2.Name = "AddNumbersHttpPostOut";

        MessagePart postMessagePart3 = new MessagePart();

        postMessagePart3.Name    = "Body";
        postMessagePart3.Element = new XmlQualifiedName("s0:int");
        // Add the 'MessagePart' to 'Message'
        postMessage2.Parts.Add(postMessagePart3);

        // Add the 'Message' objects to 'ServiceDescription'.
        myDescription.Messages.Add(postMessage1);
        myDescription.Messages.Add(postMessage2);

        // Write the 'ServiceDescription' as a WSDL file.
        myDescription.Write("AddNumbers.wsdl");
        Console.WriteLine("WSDL file with name 'AddNumber.Wsdl' file created Successfully");
    }
    static void Main()
    {
        try
        {
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_input_cs.wsdl");
            string myTargetNamespace = myServiceDescription.TargetNamespace;

// <Snippet2>
// <Snippet3>
            // Create an OperationBinding for the Add operation.
            OperationBinding addOperationBinding = new OperationBinding();
            string           addOperation        = "Add";
            addOperationBinding.Name = addOperation;
// </Snippet3>

// <Snippet4>
            // Create an InputBinding for the Add operation.
            InputBinding    myInputBinding    = new InputBinding();
            SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
            mySoapBodyBinding.Use = SoapBindingUse.Literal;
            myInputBinding.Extensions.Add(mySoapBodyBinding);

            // Add the InputBinding to the OperationBinding.
            addOperationBinding.Input = myInputBinding;
// </Snippet4>

// <Snippet5>
            // Create an OutputBinding for the Add operation.
            OutputBinding myOutputBinding = new OutputBinding();
            myOutputBinding.Extensions.Add(mySoapBodyBinding);

            // Add the OutputBinding to the OperationBinding.
            addOperationBinding.Output = myOutputBinding;
// </Snippet5>

// <Snippet6>
            // Create an extensibility element for a SoapOperationBinding.
            SoapOperationBinding mySoapOperationBinding =
                new SoapOperationBinding();
            mySoapOperationBinding.Style      = SoapBindingStyle.Document;
            mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation;

            // Add the extensibility element SoapOperationBinding to
            // the OperationBinding.
            addOperationBinding.Extensions.Add(mySoapOperationBinding);
// </Snippet6>
// </Snippet2>

// <Snippet7>
            ServiceDescriptionFormatExtensionCollection myExtensions;

            // Get the FaultBindingCollection from the OperationBinding.
            FaultBindingCollection myFaultBindingCollection =
                addOperationBinding.Faults;
            FaultBinding myFaultBinding = new FaultBinding();
            myFaultBinding.Name = "ErrorFloat";

            // Associate SOAP fault binding to the fault binding of the operation.
            myExtensions = myFaultBinding.Extensions;
            SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding();
            mySoapFaultBinding.Use       = SoapBindingUse.Literal;
            mySoapFaultBinding.Namespace = myTargetNamespace;
            myExtensions.Add(mySoapFaultBinding);
            myFaultBindingCollection.Add(myFaultBinding);
// </Snippet7>

            // Get the BindingCollection from the ServiceDescription.
            BindingCollection myBindingCollection =
                myServiceDescription.Bindings;

            // Get the OperationBindingCollection of SOAP binding
            // from the BindingCollection.
            OperationBindingCollection myOperationBindingCollection =
                myBindingCollection[0].Operations;
            myOperationBindingCollection.Add(addOperationBinding);

            Console.WriteLine(
                "The operations supported by this service are:");
            foreach (OperationBinding myOperationBinding in
                     myOperationBindingCollection)
            {
// <Snippet8>
                Binding myBinding = myOperationBinding.Binding;
                Console.WriteLine(" Binding : " + myBinding.Name +
                                  " :: Name of operation : " + myOperationBinding.Name);
// </Snippet8>
                FaultBindingCollection myFaultBindingCollection1 =
                    myOperationBinding.Faults;
                foreach (FaultBinding myFaultBinding1 in
                         myFaultBindingCollection1)
                {
                    Console.WriteLine("    Fault : " + myFaultBinding1.Name);
                }
            }
            // Save the ServiceDescription to an external file.
            myServiceDescription.Write("MathService_new_cs.wsdl");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.Source);
            Console.WriteLine("Message : " + e.Message);
        }
    }
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimePartCollection_8_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;
// <Snippet1>
// <Snippet2>
// <Snippet3>
// <Snippet4>
        MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
        IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();

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

        myMimePartCollection = myMimeMultipartRelatedBinding.Parts;
        Console.WriteLine("Total number of mimepart elements in the collection initially" +
                          " is: " + myMimePartCollection.Count);
        // Get the type of first 'Item' in collection.
        Console.WriteLine("The first object in collection is of type: "
                          + myMimePartCollection[0].ToString());
        MimePart myMimePart1 = new MimePart();
        // Create an instance of 'MimeXmlBinding'.
        MimeXmlBinding myMimeXmlBinding1 = new MimeXmlBinding();

        myMimeXmlBinding1.Part = "body";
        myMimePart1.Extensions.Add(myMimeXmlBinding1);
        //  a mimepart at first position.
        myMimePartCollection.Insert(0, myMimePart1);
        Console.WriteLine("Inserting a mimepart object...");
        // Check whether 'Insert' was successful or not.
        if (myMimePartCollection.Contains(myMimePart1))
        {
            // Display the index of inserted 'MimePart'.
            Console.WriteLine("'MimePart' is succesfully inserted at position: "
                              + myMimePartCollection.IndexOf(myMimePart1));
        }
// </Snippet4>
// </Snippet3>
// </Snippet2>
// </Snippet1>
        Console.WriteLine("Total number of mimepart elements after inserting is: "
                          + myMimePartCollection.Count);

// <Snippet5>
// <Snippet6>
        MimePart       myMimePart2       = new MimePart();
        MimeXmlBinding myMimeXmlBinding2 = new MimeXmlBinding();

        myMimeXmlBinding2.Part = "body";
        myMimePart2.Extensions.Add(myMimeXmlBinding2);
        // Add a mimepart to the mimepartcollection.
        myMimePartCollection.Add(myMimePart2);
        Console.WriteLine("Adding a mimepart object...");
        // Check if collection contains added mimepart object.
        if (myMimePartCollection.Contains(myMimePart2))
        {
            Console.WriteLine("'MimePart' is succesfully added at position: "
                              + myMimePartCollection.IndexOf(myMimePart2));
        }
// </Snippet6>
// </Snippet5>
        Console.WriteLine("Total number of mimepart elements after adding is: "
                          + myMimePartCollection.Count);

// <Snippet7>
        MimePart[] myArray = new MimePart[myMimePartCollection.Count];
        // Copy the mimepartcollection to an array.
        myMimePartCollection.CopyTo(myArray, 0);
        Console.WriteLine("Displaying the array copied from mimepartcollection");
        for (int j = 0; j < myMimePartCollection.Count; j++)
        {
            Console.WriteLine("Mimepart object at position : " + j);
            for (int i = 0; i < myArray[j].Extensions.Count; i++)
            {
                MimeXmlBinding myMimeXmlBinding3 = (MimeXmlBinding)myArray[j].Extensions[i];
                Console.WriteLine("Part: " + (myMimeXmlBinding3.Part));
            }
        }
// </Snippet7>
// <Snippet8>
        Console.WriteLine("Removing a mimepart object...");
        // Remove the mimepart from the mimepartcollection.
        myMimePartCollection.Remove(myMimePart1);
        // Check whether the mimepart is removed or not.
        if (!myMimePartCollection.Contains(myMimePart1))
        {
            Console.WriteLine("Mimepart is succesfully removed from mimepartcollection");
        }
// </Snippet8>
        Console.WriteLine("Total number of elements in collection after removing is: "
                          + myMimePartCollection.Count);
        MimePart[] myArray1 = new MimePart[myMimePartCollection.Count];
        myMimePartCollection.CopyTo(myArray1, 0);
        Console.WriteLine("Dispalying the 'MimePartCollection' after removing");
        for (int j = 0; j < myMimePartCollection.Count; j++)
        {
            Console.WriteLine("Mimepart object at position :" + j);
            for (int i = 0; i < myArray1[j].Extensions.Count; i++)
            {
                MimeXmlBinding myMimeXmlBinding3 = (MimeXmlBinding)myArray1[j].Extensions[i];
                Console.WriteLine("part:  " + (myMimeXmlBinding3.Part));
            }
        }
        myServiceDescription.Write("MimePartCollection_8_output.wsdl");
        Console.WriteLine("MimePartCollection_8_output.wsdl has been generated successfully.");
    }
    public static void Main()
    {
        try
        {
            ServiceDescription myDescription =
                ServiceDescription.Read("AddNumbersIn_cs.wsdl");

            // Add the ServiceHttpPost binding.
            Binding myBinding = new Binding();
            myBinding.Name = "ServiceHttpPost";
            XmlQualifiedName myXmlQualifiedName =
                new XmlQualifiedName("s0:ServiceHttpPost");
            myBinding.Type = myXmlQualifiedName;
            HttpBinding myHttpBinding = new HttpBinding();
            myHttpBinding.Verb = "POST";
            myBinding.Extensions.Add(myHttpBinding);

            // Add the operation name AddNumbers.
            OperationBinding myOperationBinding = new OperationBinding();
            myOperationBinding.Name = "AddNumbers";
            HttpOperationBinding myOperation = new HttpOperationBinding();
            myOperation.Location = "/AddNumbers";
            myOperationBinding.Extensions.Add(myOperation);

            // Add the input binding.
            InputBinding       myInput = new InputBinding();
            MimeContentBinding postMimeContentbinding =
                new MimeContentBinding();
            postMimeContentbinding.Type = "application/x-www-form-urlencoded";
            myInput.Extensions.Add(postMimeContentbinding);

            // Add the InputBinding to the OperationBinding.
            myOperationBinding.Input = myInput;

            // Add the ouput binding.
            OutputBinding  myOutput           = new OutputBinding();
            MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding();
            postMimeXmlbinding.Part = "Body";
            myOutput.Extensions.Add(postMimeXmlbinding);

            // Add the OutPutBinding to the OperationBinding.
            myOperationBinding.Output = myOutput;

            myBinding.Operations.Add(myOperationBinding);
            myDescription.Bindings.Add(myBinding);

            // Add the port definition.
            Port postPort = new Port();
            postPort.Name    = "ServiceHttpPost";
            postPort.Binding = new XmlQualifiedName("s0:ServiceHttpPost");
            HttpAddressBinding postAddressBinding = new HttpAddressBinding();
            postAddressBinding.Location = "http://localhost/Service_cs.asmx";
            postPort.Extensions.Add(postAddressBinding);
            myDescription.Services[0].Ports.Add(postPort);

            // Add the post port type definition.
            PortType postPortType = new PortType();
            postPortType.Name = "ServiceHttpPost";
            Operation postOperation = new Operation();
            postOperation.Name = "AddNumbers";
            OperationMessage postInput =
                (OperationMessage) new OperationInput();
            postInput.Message =
                new XmlQualifiedName("s0:AddNumbersHttpPostIn");
// <Snippet2>
            OperationOutput postOutput = new OperationOutput();
            postOutput.Message =
                new XmlQualifiedName("s0:AddNumbersHttpPostOut");

            postOperation.Messages.Add(postInput);
            postOperation.Messages.Add(postOutput);
            postPortType.Operations.Add(postOperation);
// </Snippet2>
            myDescription.PortTypes.Add(postPortType);

            // Add the first message information.
            Message postMessage1 = new Message();
            postMessage1.Name = "AddNumbersHttpPostIn";
            MessagePart postMessagePart1 = new MessagePart();
            postMessagePart1.Name = "firstnumber";
            postMessagePart1.Type = new XmlQualifiedName("s:string");

            // Add the second message information.
            MessagePart postMessagePart2 = new MessagePart();
            postMessagePart2.Name = "secondnumber";
            postMessagePart2.Type = new XmlQualifiedName("s:string");
            postMessage1.Parts.Add(postMessagePart1);
            postMessage1.Parts.Add(postMessagePart2);
            Message postMessage2 = new Message();
            postMessage2.Name = "AddNumbersHttpPostOut";

            // Add the third message information.
            MessagePart postMessagePart3 = new MessagePart();
            postMessagePart3.Name    = "Body";
            postMessagePart3.Element = new XmlQualifiedName("s0:int");
            postMessage2.Parts.Add(postMessagePart3);

            myDescription.Messages.Add(postMessage1);
            myDescription.Messages.Add(postMessage2);

            // Write the ServiceDescription as a WSDL file.
            myDescription.Write("AddNumbersOut_cs.wsdl");
            Console.WriteLine("WSDL file named AddNumbersOut_cs.Wsdl" +
                              " created successfully.");
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.Source);
            Console.WriteLine("Message : " + e.Message);
        }
    }
Beispiel #29
0
    public static void Main()
    {
        ServiceDescription myServiceDescription = ServiceDescription.Read("Operation_IsBoundBy_Input_CS.wsdl");
        // Create the 'Binding' object.
        Binding myBinding = new Binding();

        myBinding.Name = "MyOperationIsBoundByServiceHttpPost";
        XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:OperationServiceHttpPost");

        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 myPostMimeContentBinding = new MimeContentBinding();

        myPostMimeContentBinding.Type = "application/x-www-form-urlencoded";
        myInputBinding.Extensions.Add(myPostMimeContentBinding);
        // Add the 'InputBinding' to 'OperationBinding'.
        myOperationBinding.Input = myInputBinding;
        // Create the 'OutputBinding' object.
        OutputBinding  myOutputBinding      = new OutputBinding();
        MimeXmlBinding myPostMimeXmlBinding = new MimeXmlBinding();

        myPostMimeXmlBinding.Part = "Body";
        myOutputBinding.Extensions.Add(myPostMimeXmlBinding);

        // Add the 'OutPutBinding' to 'OperationBinding'.
        myOperationBinding.Output = myOutputBinding;

        // Add the 'OperationBinding' to 'Binding'.
        myBinding.Operations.Add(myOperationBinding);

        // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
        myServiceDescription.Bindings.Add(myBinding);

        // Create a 'PortType' object.
        PortType myPostPortType = new PortType();

        myPostPortType.Name = "OperationServiceHttpPost";
// <Snippet1>
        Operation myPostOperation = new Operation();

        myPostOperation.Name = myOperationBinding.Name;
        Console.WriteLine("'Operation' instance uses 'OperationBinding': "
                          + myPostOperation.IsBoundBy(myOperationBinding));
// </Snippet1>
        OperationMessage myOperationMessage = (OperationMessage) new OperationInput();

        myOperationMessage.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn");
        OperationMessage myOperationMessage1 = (OperationMessage) new OperationOutput();

        myOperationMessage1.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut");

        myPostOperation.Messages.Add(myOperationMessage);
        myPostOperation.Messages.Add(myOperationMessage1);

        // Add the 'Operation' to 'PortType'.
        myPostPortType.Operations.Add(myPostOperation);

        // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'.
        myServiceDescription.PortTypes.Add(myPostPortType);

        // Write the 'ServiceDescription' as a WSDL file.
        myServiceDescription.Write("Operation_IsBoundBy_Output_CS.wsdl");
        Console.WriteLine("WSDL file with name 'Operation_IsBoundBy_Output_CS.wsdl' created Successfully");
    }
        void ExportEndpoint(ServiceEndpoint endpoint, bool rejectDuplicate)
        {
            List <IWsdlExportExtension> extensions = ExportContractInternal(endpoint.Contract, rejectDuplicate);

            //FIXME: Namespace
            WSServiceDescription sd = GetServiceDescription("http://tempuri.org/");

            if (sd.TargetNamespace != endpoint.Contract.Namespace)
            {
                sd.Namespaces.Add("i0", endpoint.Contract.Namespace);

                //Import
                Import import = new Import();
                import.Namespace = endpoint.Contract.Namespace;

                sd.Imports.Add(import);
            }

            if (endpoint.Binding == null)
            {
                throw new ArgumentException(String.Format(
                                                "Binding for ServiceEndpoint named '{0}' is null",
                                                endpoint.Name));
            }

            bool msg_version_none =
                endpoint.Binding.MessageVersion != null &&
                endpoint.Binding.MessageVersion.Equals(MessageVersion.None);
            //ExportBinding
            WSBinding ws_binding = new WSBinding();

            //<binding name = ..
            ws_binding.Name = String.Concat(endpoint.Binding.Name, "_", endpoint.Contract.Name);

            //<binding type = ..
            ws_binding.Type = new QName(endpoint.Contract.Name, endpoint.Contract.Namespace);
            sd.Bindings.Add(ws_binding);

            if (!msg_version_none)
            {
                SoapBinding soap_binding = new SoapBinding();
                soap_binding.Transport = SoapBinding.HttpTransport;
                soap_binding.Style     = SoapBindingStyle.Document;
                ws_binding.Extensions.Add(soap_binding);
            }

            //	<operation
            foreach (OperationDescription sm_op in endpoint.Contract.Operations)
            {
                OperationBinding op_binding = new OperationBinding();
                op_binding.Name = sm_op.Name;

                //FIXME: Move to IWsdlExportExtension .. ?
                foreach (MessageDescription sm_md in sm_op.Messages)
                {
                    if (sm_md.Direction == MessageDirection.Input)
                    {
                        //<input
                        InputBinding in_binding = new InputBinding();

                        if (!msg_version_none)
                        {
                            SoapBodyBinding soap_body_binding = new SoapBodyBinding();
                            soap_body_binding.Use = SoapBindingUse.Literal;
                            in_binding.Extensions.Add(soap_body_binding);

                            //Set Action
                            //<operation > <soap:operation soapAction .. >
                            SoapOperationBinding soap_operation_binding = new SoapOperationBinding();
                            soap_operation_binding.SoapAction = sm_md.Action;
                            soap_operation_binding.Style      = SoapBindingStyle.Document;
                            op_binding.Extensions.Add(soap_operation_binding);
                        }

                        op_binding.Input = in_binding;
                    }
                    else
                    {
                        //<output
                        OutputBinding out_binding = new OutputBinding();

                        if (!msg_version_none)
                        {
                            SoapBodyBinding soap_body_binding = new SoapBodyBinding();
                            soap_body_binding.Use = SoapBindingUse.Literal;
                            out_binding.Extensions.Add(soap_body_binding);
                        }

                        op_binding.Output = out_binding;
                    }
                }

                ws_binding.Operations.Add(op_binding);
            }

            //Add <service
            Port ws_port = ExportService(sd, ws_binding, endpoint.Address, msg_version_none);

            //Call IWsdlExportExtension.ExportEndpoint
            WsdlContractConversionContext contract_context = new WsdlContractConversionContext(
                endpoint.Contract, sd.PortTypes [endpoint.Contract.Name]);
            WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext(
                contract_context, endpoint, ws_port, ws_binding);

            if (extensions != null)
            {
                foreach (IWsdlExportExtension extn in extensions)
                {
                    extn.ExportEndpoint(this, endpoint_context);
                }
            }
        }