Exemplo n.º 1
0
        private static SoapOperationBinding CreateSoapOperationBinding(EnvelopeVersion version, OperationBinding wsdlOperationBinding)
        {
            SoapOperationBinding extension = null;

            if (version == EnvelopeVersion.Soap12)
            {
                extension = new Soap12OperationBinding();
            }
            else if (version == EnvelopeVersion.Soap11)
            {
                extension = new SoapOperationBinding();
            }
            wsdlOperationBinding.Extensions.Add(extension);
            return(extension);
        }
 private static object GetSoapOperationBinding(System.ServiceModel.Channels.Binding binding, string action)
 {
     if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap11)
     {
         SoapOperationBinding soapOperationBinding = new SoapOperationBinding();
         soapOperationBinding.SoapAction = action;
         soapOperationBinding.Style      = SoapBindingStyle.Document;
         return(soapOperationBinding);
     }
     else if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap12)
     {
         Soap12OperationBinding soapOperationBinding = new Soap12OperationBinding();
         soapOperationBinding.SoapAction = action;
         soapOperationBinding.Style      = SoapBindingStyle.Document;
         return(soapOperationBinding);
     }
     return(null);
 }
Exemplo n.º 3
0
        void CreateInputBinding(ServiceEndpoint endpoint, OperationBinding op_binding,
                                MessageDescription sm_md)
        {
            var in_binding = new InputBinding();

            op_binding.Input = in_binding;

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

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

            SoapBodyBinding      soap_body_binding;
            SoapOperationBinding soap_operation_binding;

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

            soap_body_binding.Use = SoapBindingUse.Literal;
            in_binding.Extensions.Add(soap_body_binding);

            //Set Action
            //<operation > <soap:operation soapAction .. >
            soap_operation_binding.SoapAction = sm_md.Action;
            soap_operation_binding.Style      = SoapBindingStyle.Document;
            op_binding.Extensions.Add(soap_operation_binding);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Helper method used to parse a soap bindings element looking for an operation
        /// with an Action property that defines the soapAction.
        /// </summary>
        /// <param name="portType">Service port type collection.</param>
        /// <returns>Soap action if found.</returns>
        private string GetSoapAction(PortType portType, string operationName)
        {
            string  soapAction  = null;
            Binding soapBinding = null;

            if (portType.ServiceDescription.Bindings != null)
            {
                foreach (Binding binding in portType.ServiceDescription.Bindings)
                {
                    // If this is the soap12 binding break;
                    if (binding.Extensions.Find(typeof(Soap12Binding)) != null)
                    {
                        if (binding.Type.Name == portType.Name)
                        {
                            soapBinding = binding;
                            break;
                        }
                    }
                }
                if (soapBinding != null)
                {
                    foreach (OperationBinding operationBinding in soapBinding.Operations)
                    {
                        if (operationBinding.Name == operationName)
                        {
                            Soap12OperationBinding soapActionBinding = (Soap12OperationBinding)operationBinding.Extensions.Find(typeof(Soap12OperationBinding));
                            if (soapActionBinding != null)
                            {
                                soapAction = soapActionBinding.SoapAction;
                                return(soapAction);
                            }
                        }
                    }
                }
            }
            return(null);
        }