void MoveToOperation(Operation operation)
        {
            this.operation = operation;

            operationBinding = null;
            foreach (OperationBinding b in binding.Operations)
            {
                if (operation.IsBoundBy(b))
                {
                    if (operationBinding != null)
                    {
                        throw OperationSyntaxException(Res.GetString(Res.DuplicateInputOutputNames0));
                    }
                    operationBinding = b;
                }
            }
            if (operationBinding == null)
            {
                throw OperationSyntaxException(Res.GetString(Res.MissingBinding0));
            }
            //NOTE: The following two excepions would never happen since IsBoundBy checks these conditions already.
            if (operation.Messages.Input != null && operationBinding.Input == null)
            {
                throw OperationSyntaxException(Res.GetString(Res.MissingInputBinding0));
            }
            if (operation.Messages.Output != null && operationBinding.Output == null)
            {
                throw OperationSyntaxException(Res.GetString(Res.MissingOutputBinding0));
            }

            this.inputMessage  = operation.Messages.Input == null ? null : ServiceDescriptions.GetMessage(operation.Messages.Input.Message);
            this.outputMessage = operation.Messages.Output == null ? null : ServiceDescriptions.GetMessage(operation.Messages.Output.Message);
        }
Exemple #2
0
        private void ConvertBinding(DescriptionType wsdl2, ServiceDescription wsdl1)
        {
            var bindings = wsdl2.Items.Where(s => s is BindingType);

            foreach (BindingType b2 in bindings)
            {
                var b1 = new Binding();
                wsdl1.Bindings.Add(b1);

                b1.Name = b2.name;
                b1.Type = b2.@interface;

                var v = GetSoapVersion(b2);
                if (v == SoapVersion.Soap11)
                {
                    b1.Extensions.Add(new SoapBinding {
                        Transport = "http://schemas.xmlsoap.org/soap/http"
                    });
                }
                else
                {
                    b1.Extensions.Add(new Soap12Binding {
                        Transport = "http://schemas.xmlsoap.org/soap/http"
                    });
                }

                var operations = b2.Items.Where(s => s is BindingOperationType);

                foreach (BindingOperationType op2 in operations)
                {
                    var op1 = new OperationBinding();
                    b1.Operations.Add(op1);

                    op1.Name = [email protected];

                    var soap = v == SoapVersion.Soap11 ? new SoapOperationBinding() : new Soap12OperationBinding();
                    op1.Extensions.Add(soap);

                    soap.SoapAction = FindSoapAction(op2);
                    soap.Style      = SoapBindingStyle.Document;

                    var body = v == SoapVersion.Soap11 ? new SoapBodyBinding() : new Soap12BodyBinding();
                    body.Use = SoapBindingUse.Literal;

                    op1.Input = new InputBinding();
                    op1.Input.Extensions.Add(body);

                    op1.Output = new OutputBinding();
                    op1.Output.Extensions.Add(body);

                    HandleHeaders(wsdl1, op2, ItemsChoiceType1.input, op1.Input, v);
                    HandleHeaders(wsdl1, op2, ItemsChoiceType1.output, op1.Output, v);
                }
            }
        }
Exemple #3
0
 private static Operation FindOperation(OperationCollection operations, OperationBinding bindingOperation)
 {
     foreach (Operation operation in operations)
     {
         if (operation.IsBoundBy(bindingOperation))
         {
             return(operation);
         }
     }
     return(null);
 }
        static WsdlNS.SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation)
        {
            WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);

            foreach (object o in wsdlOperationBinding.Extensions)
            {
                if (o is WsdlNS.SoapOperationBinding)
                {
                    return((WsdlNS.SoapOperationBinding)o);
                }
            }
            return(null);
        }
 internal static WsdlNS.SoapBindingStyle GetStyle(WsdlNS.OperationBinding operationBinding, WsdlNS.SoapBindingStyle defaultBindingStyle)
 {
     WsdlNS.SoapBindingStyle style = defaultBindingStyle;
     if (operationBinding != null)
     {
         WsdlNS.SoapOperationBinding soapOperationBinding = operationBinding.Extensions.Find(typeof(WsdlNS.SoapOperationBinding)) as WsdlNS.SoapOperationBinding;
         if (soapOperationBinding != null)
         {
             if (soapOperationBinding.Style != WsdlNS.SoapBindingStyle.Default)
             {
                 style = soapOperationBinding.Style;
             }
         }
     }
     return(style);
 }
        static ExplorerItem CreateExplorerOperation(Type serviceType, OperationBinding operation)
        {
            var method = serviceType.GetMethod(operation.Name);
            var parameters = method.GetParameters();
            var description = operation.DocumentationElement == null
                ? ""
                : operation.DocumentationElement.InnerText;
            var item = new ExplorerItem(operation.Name, ExplorerItemKind.QueryableObject, ExplorerIcon.StoredProc) {
                ToolTipText = description,
                DragText = GetMethodCallString(method.Name, from p in parameters select p.Name),
                Children = (
                    from p in parameters
                    select new ExplorerItem(p.Name, ExplorerItemKind.Parameter, ExplorerIcon.Parameter)
                ).ToList()
            };

            return item;
        }
Exemple #7
0
        public bool IsBoundBy(OperationBinding operationBinding)
        {
            if (operationBinding.Name != base.Name)
            {
                return(false);
            }
            OperationMessage input = this.Messages.Input;

            if (input != null)
            {
                if (operationBinding.Input == null)
                {
                    return(false);
                }
                string str = this.GetMessageName(base.Name, input.Name, true);
                if (this.GetMessageName(operationBinding.Name, operationBinding.Input.Name, true) != str)
                {
                    return(false);
                }
            }
            else if (operationBinding.Input != null)
            {
                return(false);
            }
            OperationMessage output = this.Messages.Output;

            if (output != null)
            {
                if (operationBinding.Output == null)
                {
                    return(false);
                }
                string str3 = this.GetMessageName(base.Name, output.Name, false);
                if (this.GetMessageName(operationBinding.Name, operationBinding.Output.Name, false) != str3)
                {
                    return(false);
                }
            }
            else if (operationBinding.Output != null)
            {
                return(false);
            }
            return(true);
        }
        internal static WsdlNS.SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter)
        {
            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
            {
                return(null);
            }

            WsdlNS.SoapOperationBinding existingSoapOperationBinding = GetSoapOperationBinding(endpointContext, operation);
            WsdlNS.OperationBinding     wsdlOperationBinding         = endpointContext.GetOperationBinding(operation);
            EnvelopeVersion             version = GetSoapVersion(endpointContext.WsdlBinding);

            if (existingSoapOperationBinding != null)
            {
                return(existingSoapOperationBinding);
            }

            WsdlNS.SoapOperationBinding soapOperationBinding = CreateSoapOperationBinding(version, wsdlOperationBinding);
            return(soapOperationBinding);
        }
 public bool IsBoundBy(OperationBinding operationBinding)
 {
     if (operationBinding.Name != base.Name)
     {
         return false;
     }
     OperationMessage input = this.Messages.Input;
     if (input != null)
     {
         if (operationBinding.Input == null)
         {
             return false;
         }
         string str = this.GetMessageName(base.Name, input.Name, true);
         if (this.GetMessageName(operationBinding.Name, operationBinding.Input.Name, true) != str)
         {
             return false;
         }
     }
     else if (operationBinding.Input != null)
     {
         return false;
     }
     OperationMessage output = this.Messages.Output;
     if (output != null)
     {
         if (operationBinding.Output == null)
         {
             return false;
         }
         string str3 = this.GetMessageName(base.Name, output.Name, false);
         if (this.GetMessageName(operationBinding.Name, operationBinding.Output.Name, false) != str3)
         {
             return false;
         }
     }
     else if (operationBinding.Output != null)
     {
         return false;
     }
     return true;
 }
        void ImportOperationBinding()
        {
            operationBinding      = new OperationBinding();
            operationBinding.Name = methodStubInfo.OperationName;

            InputBinding inOp = new InputBinding();

            operationBinding.Input = inOp;

            OutputBinding outOp = new OutputBinding();

            operationBinding.Output = outOp;

            if (methodStubInfo.OperationName != methodStubInfo.Name)
            {
                inOp.Name = outOp.Name = methodStubInfo.Name;
            }

            binding.Operations.Add(operationBinding);
        }
Exemple #11
0
        public string GenerateHttpGetMessage(Port port, OperationBinding obin, Operation oper, OperationMessage msg)
        {
            string req = "";

            if (msg is OperationInput) {
                HttpAddressBinding sab = port.Extensions.Find(typeof(HttpAddressBinding)) as HttpAddressBinding;
                HttpOperationBinding sob = obin.Extensions.Find(typeof(HttpOperationBinding)) as HttpOperationBinding;
                string location = new Uri(sab.Location).AbsolutePath + sob.Location + "?" + BuildQueryString(msg);
                req += "GET " + location + "\n";
                req += "Host: " + GetLiteral("string");
            }
            else {
                req += "HTTP/1.0 200 OK\n";
                req += "Content-Type: text/xml; charset=utf-8\n";
                req += "Content-Length: " + GetLiteral("string") + "\n\n";

                MimeXmlBinding mxb = (MimeXmlBinding)obin.Output.Extensions.Find(typeof(MimeXmlBinding)) as MimeXmlBinding;
                if (mxb == null) return req;

                Message message = descriptions.GetMessage(msg.Message);
                XmlQualifiedName ename = null;
                foreach (MessagePart part in message.Parts)
                    if (part.Name == mxb.Part) ename = part.Element;

                if (ename == null) return req + GetLiteral("string");

                StringWriter sw = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                xtw.Formatting = Formatting.Indented;
                currentUse = SoapBindingUse.Literal;
                WriteRootElementSample(xtw, ename);
                xtw.Close();
                req += sw.ToString();
            }

            return req;
        }
        public override void Check(ConformanceCheckContext ctx, OperationBinding value)
        {
            bool r2754 = false;
            bool r2723 = false;

            foreach (FaultBinding fb in value.Faults)
            {
                SoapFaultBinding sfb = (SoapFaultBinding)value.Extensions.Find(typeof(SoapFaultBinding));
                if (sfb == null)
                {
                    continue;
                }
                r2754 |= sfb.Name != fb.Name;
                r2723 |= sfb.Use == SoapBindingUse.Encoded;
            }
            if (r2754)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2754);
            }
            if (r2723)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2723);
            }
        }
Exemple #13
0
		OperationBinding CreateOperationBinding (ServiceEndpoint endpoint, OperationDescription sm_op)
		{
			OperationBinding op_binding = new OperationBinding ();
			op_binding.Name = sm_op.Name;
			
			foreach (MessageDescription sm_md in sm_op.Messages) {
				if (sm_md.Direction == MessageDirection.Input) {
					//<input
					CreateInputBinding (endpoint, op_binding, sm_md);
				} else {
					//<output
					CreateOutputBinding (endpoint, op_binding, sm_md);
				}
			}

			return op_binding;
		}
 public int Add(OperationBinding bindingOperation)
 {
     return(base.List.Add(bindingOperation));
 }
 internal static string ReadSoapAction(WsdlNS.OperationBinding wsdlOperationBinding)
 {
     WsdlNS.SoapOperationBinding soapOperationBinding = (WsdlNS.SoapOperationBinding)wsdlOperationBinding.Extensions.Find(typeof(WsdlNS.SoapOperationBinding));
     return(soapOperationBinding != null ? soapOperationBinding.SoapAction : null);
 }
        static WsdlNS.SoapOperationBinding CreateSoapOperationBinding(EnvelopeVersion version, WsdlNS.OperationBinding wsdlOperationBinding)
        {
            WsdlNS.SoapOperationBinding soapOperationBinding = null;

            if (version == EnvelopeVersion.Soap12)
            {
                soapOperationBinding = new WsdlNS.Soap12OperationBinding();
            }
            else if (version == EnvelopeVersion.Soap11)
            {
                soapOperationBinding = new WsdlNS.SoapOperationBinding();
            }
            Fx.Assert(soapOperationBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class");

            wsdlOperationBinding.Extensions.Add(soapOperationBinding);
            return(soapOperationBinding);
        }
        void ReflectBinding(ReflectedBinding reflectedBinding)
        {
            string bindingName      = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
            string bindingNamespace = reflectedBinding.bindingAttr.Namespace;

            if (bindingName.Length == 0)
            {
                bindingName = Service.Name + ProtocolName;
            }
            if (bindingNamespace.Length == 0)
            {
                bindingNamespace = ServiceDescription.TargetNamespace;
            }
            WsiProfiles claims = WsiProfiles.None;

            if (reflectedBinding.bindingAttr.Location.Length > 0)
            {
                // If a URL is specified for the WSDL, file, then we just import the
                // binding from there instead of generating it in this WSDL file.
                portType = null;
                binding  = null;
            }
            else
            {
                bindingServiceDescription = GetServiceDescription(bindingNamespace);
                CodeIdentifiers bindingNames = new CodeIdentifiers();
                foreach (Binding b in bindingServiceDescription.Bindings)
                {
                    bindingNames.AddReserved(b.Name);
                }

                bindingName = bindingNames.AddUnique(bindingName, binding);

                portType      = new PortType();
                binding       = new Binding();
                portType.Name = bindingName;
                binding.Name  = bindingName;
                binding.Type  = new XmlQualifiedName(portType.Name, bindingNamespace);
                claims        = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
                if (reflectedBinding.bindingAttr.EmitConformanceClaims && claims != WsiProfiles.None)
                {
                    ServiceDescription.AddConformanceClaims(binding.GetDocumentationElement(), claims);
                }
                bindingServiceDescription.Bindings.Add(binding);
                bindingServiceDescription.PortTypes.Add(portType);
            }

            if (portNames == null)
            {
                portNames = new CodeIdentifiers();
                foreach (Port p in Service.Ports)
                {
                    portNames.AddReserved(p.Name);
                }
            }

            port         = new Port();
            port.Binding = new XmlQualifiedName(bindingName, bindingNamespace);
            port.Name    = portNames.AddUnique(bindingName, port);
            Service.Ports.Add(port);

            BeginClass();

            if (reflectedBinding.methodList != null && reflectedBinding.methodList.Count > 0)
            {
                foreach (LogicalMethodInfo method in reflectedBinding.methodList)
                {
                    MoveToMethod(method);

                    operation      = new Operation();
                    operation.Name = XmlConvert.EncodeLocalName(method.Name);
                    if (methodAttr.Description != null && methodAttr.Description.Length > 0)
                    {
                        operation.Documentation = methodAttr.Description;
                    }

                    operationBinding      = new OperationBinding();
                    operationBinding.Name = operation.Name;

                    inputMessage   = null;
                    outputMessage  = null;
                    headerMessages = null;

                    if (ReflectMethod())
                    {
                        if (inputMessage != null)
                        {
                            bindingServiceDescription.Messages.Add(inputMessage);
                        }
                        if (outputMessage != null)
                        {
                            bindingServiceDescription.Messages.Add(outputMessage);
                        }
                        if (headerMessages != null)
                        {
                            foreach (Message headerMessage in headerMessages)
                            {
                                bindingServiceDescription.Messages.Add(headerMessage);
                            }
                        }
                        binding.Operations.Add(operationBinding);
                        portType.Operations.Add(operation);
                    }
                }
            }
            if (binding != null && claims == WsiProfiles.BasicProfile1_1 && ProtocolName == "Soap")
            {
                BasicProfileViolationCollection warnings = new BasicProfileViolationCollection();
                WebServicesInteroperability.AnalyzeBinding(binding, bindingServiceDescription, ServiceDescriptions, warnings);
                if (warnings.Count > 0)
                {
                    throw new InvalidOperationException(Res.GetString(Res.WebWsiViolation, ServiceType.FullName, warnings.ToString()));
                }
            }
            EndClass();
        }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.Remove"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Remove(OperationBinding bindingOperation) {
     List.Remove(bindingOperation);
 }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.Add"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int Add(OperationBinding bindingOperation) {
     return List.Add(bindingOperation);
 }
        void MoveToOperation(Operation operation) {
            this.operation = operation;

            operationBinding = null;
            foreach (OperationBinding b in binding.Operations) {
                if (operation.IsBoundBy(b)) {
                    if (operationBinding != null) throw OperationSyntaxException(Res.GetString(Res.DuplicateInputOutputNames0));
                    operationBinding = b;
                }
            }
            if (operationBinding == null) {
                throw OperationSyntaxException(Res.GetString(Res.MissingBinding0));
            }
            //NOTE: The following two excepions would never happen since IsBoundBy checks these conditions already.
            if (operation.Messages.Input != null && operationBinding.Input == null) {
                throw OperationSyntaxException(Res.GetString(Res.MissingInputBinding0));
            }
            if (operation.Messages.Output != null && operationBinding.Output == null) {
                throw OperationSyntaxException(Res.GetString(Res.MissingOutputBinding0));
            }

            this.inputMessage = operation.Messages.Input == null ? null : ServiceDescriptions.GetMessage(operation.Messages.Input.Message);
            this.outputMessage = operation.Messages.Output == null ? null : ServiceDescriptions.GetMessage(operation.Messages.Output.Message);
        }
Exemple #21
0
 public virtual void Check(ConformanceCheckContext ctx, OperationBinding value)
 {
 }
Exemple #22
0
		public bool IsBoundBy (OperationBinding operationBinding)
		{
			return (operationBinding.Name == Name);
		}
            /// <summary>
            /// Creates a <see cref="SoapDocumentMethodAttribute"/> or a <see cref="SoapRpcMethodAttribute"/>
            /// that should be applied to proxy method.
            /// </summary>
            private static CustomAttributeBuilder CreateSoapMethodAttribute(Operation operation,
                OperationBinding operationBinding, SoapOperationBinding soapOperationBinding,
                XmlMembersMapping inputMembersMapping, XmlMembersMapping outputMembersMapping)
            {
                ReflectionUtils.CustomAttributeBuilderBuilder cabb;

                string inputMembersMappingElementName = inputMembersMapping.ElementName;
                string inputMembersMappingNamespace = inputMembersMapping.Namespace;

                if (soapOperationBinding.Style == SoapBindingStyle.Rpc)
                {
                    cabb = new ReflectionUtils.CustomAttributeBuilderBuilder(typeof(SoapRpcMethodAttribute));
                }
                else
                {
                    cabb = new ReflectionUtils.CustomAttributeBuilderBuilder(typeof(SoapDocumentMethodAttribute));
                    cabb.AddPropertyValue("ParameterStyle", SoapParameterStyle.Wrapped);
                }

                cabb.AddContructorArgument(soapOperationBinding.SoapAction);
                cabb.AddPropertyValue("Use", SoapBindingUse.Literal);

                if (inputMembersMappingElementName.Length > 0 &&
                    inputMembersMappingElementName != operation.Name)
                {
                    cabb.AddPropertyValue("RequestElementName", inputMembersMappingElementName);
                }

                if (inputMembersMappingNamespace != null)
                {
                    cabb.AddPropertyValue("RequestNamespace", inputMembersMappingNamespace);
                }

                if (outputMembersMapping == null)
                {
                    cabb.AddPropertyValue("OneWay", true);
                }
                else
                {
                    string outputMembersMappingElementName = outputMembersMapping.ElementName;
                    string outputMembersMappingNamespace = outputMembersMapping.Namespace;

                    if (outputMembersMappingElementName.Length > 0 &&
                        outputMembersMappingElementName != (operation.Name + "Response"))
                    {
                        cabb.AddPropertyValue("ResponseElementName", outputMembersMappingElementName);
                    }

                    if (outputMembersMappingNamespace != null)
                    {
                        cabb.AddPropertyValue("ResponseNamespace", outputMembersMappingNamespace);
                    }
                }

                return cabb.Build();
            }
            private void MoveToMethod(MethodInfo targetMethod)
            {
                operation = GetOperation(this.wsDescriptions, this.wsBinding, targetMethod);
                operationBinding = GetOperationBinding(operation, this.wsBinding);
                soapOperationBinding = (SoapOperationBinding)operationBinding.Extensions.Find(typeof(SoapOperationBinding));

                string inputMessageName = (!StringUtils.IsNullOrEmpty(operationBinding.Input.Name) && (soapOperationBinding.Style != SoapBindingStyle.Rpc)) ? operationBinding.Input.Name : operation.Name;
                SoapBodyBinding inputSoapBodyBinding = (SoapBodyBinding)operationBinding.Input.Extensions.Find(typeof(SoapBodyBinding));

                if (inputSoapBodyBinding.Use != SoapBindingUse.Literal)
                {
                    throw new NotSupportedException("WebServiceProxyFactory only supports document-literal and rpc-literal SOAP messages to conform to WS-I Basic Profiles.");
                }

                Message inputMessage = this.wsDescriptions.GetMessage(operation.Messages.Input.Message);
                inputMembersMapping = GetMembersMapping(inputMessageName, inputMessage.Parts, inputSoapBodyBinding, soapOperationBinding.Style);

                outputMembersMapping = null;
                if (operation.Messages.Output != null)
                {
                    string outputMessageName = (!StringUtils.IsNullOrEmpty(operationBinding.Output.Name) && (soapOperationBinding.Style != SoapBindingStyle.Rpc)) ? operationBinding.Output.Name : (operation.Name + "Response");
                    SoapBodyBinding outputSoapBodyBinding = (SoapBodyBinding)operationBinding.Output.Extensions.Find(typeof(SoapBodyBinding));
                    Message outputMessage = this.wsDescriptions.GetMessage(operation.Messages.Output.Message);
                    outputMembersMapping = GetMembersMapping(outputMessageName, outputMessage.Parts, outputSoapBodyBinding, soapOperationBinding.Style);
                }
            }
 public void Remove(OperationBinding bindingOperation)
 {
     base.List.Remove(bindingOperation);
 }
Exemple #26
0
        internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            bool        flag     = false;
            bool        flag2    = false;
            SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding));

            if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
            {
                return(false);
            }
            SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;

            if (binding2.Transport.Length == 0)
            {
                violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
            }
            else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
            {
                violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
            }
            PortType  portType  = descriptions.GetPortType(binding.Type);
            Hashtable hashtable = new Hashtable();

            if (portType != null)
            {
                foreach (Operation operation in portType.Operations)
                {
                    if (operation.Messages.Flow == OperationFlow.Notification)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (operation.Messages.Flow == OperationFlow.SolicitResponse)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (hashtable[operation.Name] != null)
                    {
                        violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                    }
                    else
                    {
                        OperationBinding binding3 = null;
                        foreach (OperationBinding binding4 in binding.Operations)
                        {
                            if (operation.IsBoundBy(binding4))
                            {
                                if (binding3 != null)
                                {
                                    violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                                }
                                binding3 = binding4;
                            }
                        }
                        if (binding3 == null)
                        {
                            violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                        }
                        else
                        {
                            hashtable.Add(operation.Name, operation);
                        }
                    }
                }
            }
            Hashtable        wireSignatures = new Hashtable();
            SoapBindingStyle style2         = SoapBindingStyle.Default;

            foreach (OperationBinding binding5 in binding.Operations)
            {
                SoapBindingStyle style3 = style;
                string           name   = binding5.Name;
                if (name != null)
                {
                    if (hashtable[name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                    Operation            operation2 = FindOperation(portType.Operations, binding5);
                    SoapOperationBinding binding6   = (SoapOperationBinding)binding5.Extensions.Find(typeof(SoapOperationBinding));
                    if (binding6 != null)
                    {
                        if (style2 == SoapBindingStyle.Default)
                        {
                            style2 = binding6.Style;
                        }
                        flag  |= style2 != binding6.Style;
                        style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
                    }
                    if (binding5.Input != null)
                    {
                        SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                        {
                            Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                                int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                                CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                                if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    if (binding5.Output != null)
                    {
                        SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                        {
                            Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                                int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                                CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                                if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    foreach (FaultBinding binding9 in binding5.Faults)
                    {
                        foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                        {
                            if (extension is SoapFaultBinding)
                            {
                                SoapFaultBinding item = (SoapFaultBinding)extension;
                                if (item.Use == SoapBindingUse.Encoded)
                                {
                                    violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                }
                                else
                                {
                                    if ((item.Name == null) || (item.Name.Length == 0))
                                    {
                                        violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    else if (item.Name != binding9.Name)
                                    {
                                        violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    if ((item.Namespace != null) && (item.Namespace.Length > 0))
                                    {
                                        violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                    }
                                }
                            }
                        }
                    }
                    if (hashtable[binding5.Name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                }
            }
            if (flag2)
            {
                violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
            }
            if (flag)
            {
                violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
            }
            return(true);
        }
Exemple #27
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);
		}
Exemple #28
0
        void ClasifySchemas(ArrayList importInfo)
        {
            // I don't like this, but I could not find any other way of clasifying
            // schemas between encoded and literal.

            xmlSchemas  = new XmlSchemas();
            soapSchemas = new XmlSchemas();

            foreach (ImportInfo info in importInfo)
            {
                foreach (Service service in info.ServiceDescription.Services)
                {
                    foreach (Port port in service.Ports)
                    {
                        this.iinfo = info;
                        this.port  = port;
                        binding    = ServiceDescriptions.GetBinding(port.Binding);
                        if (binding == null)
                        {
                            continue;
                        }
                        portType = ServiceDescriptions.GetPortType(binding.Type);
                        if (portType == null)
                        {
                            continue;
                        }

                        foreach (OperationBinding oper in binding.Operations)
                        {
                            operationBinding = oper;
                            operation        = FindPortOperation();
                            if (operation == null)
                            {
                                continue;
                            }

                            foreach (OperationMessage omsg in operation.Messages)
                            {
                                Message msg = ServiceDescriptions.GetMessage(omsg.Message);
                                if (msg == null)
                                {
                                    continue;
                                }

                                if (omsg is OperationInput)
                                {
                                    inputMessage = msg;
                                }
                                else
                                {
                                    outputMessage = msg;
                                }
                            }

                            if (GetMessageEncoding(oper.Input) == SoapBindingUse.Encoded)
                            {
                                AddMessageSchema(soapSchemas, oper.Input, inputMessage);
                            }
                            else
                            {
                                AddMessageSchema(xmlSchemas, oper.Input, inputMessage);
                            }

                            if (oper.Output != null)
                            {
                                if (GetMessageEncoding(oper.Output) == SoapBindingUse.Encoded)
                                {
                                    AddMessageSchema(soapSchemas, oper.Output, outputMessage);
                                }
                                else
                                {
                                    AddMessageSchema(xmlSchemas, oper.Output, outputMessage);
                                }
                            }
                        }
                    }
                }
            }

            XmlSchemas defaultList = xmlSchemas;

            if (xmlSchemas.Count == 0 && soapSchemas.Count > 0)
            {
                defaultList = soapSchemas;
            }

            // Schemas not referenced by any message
            foreach (XmlSchema sc in Schemas)
            {
                if (!soapSchemas.Contains(sc) && !xmlSchemas.Contains(sc))
                {
                    if (ImportsEncodedNamespace(sc))
                    {
                        soapSchemas.Add(sc);
                    }
                    else
                    {
                        defaultList.Add(sc);
                    }
                }
            }
        }
 WsdlNS.OperationBinding CreateWsdlOperationBinding(ContractDescription contract, OperationDescription operation)
 {
     WsdlNS.OperationBinding wsdlOperationBinding = new WsdlNS.OperationBinding();
     wsdlOperationBinding.Name = WsdlNamingHelper.GetWsdlOperationName(operation, contract);
     return wsdlOperationBinding;
 }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.IndexOf"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int IndexOf(OperationBinding bindingOperation) {
     return List.IndexOf(bindingOperation);
 }
 internal FaultBindingCollection(OperationBinding operationBinding) : base(operationBinding)
 {
 }
 internal FaultBindingCollection(OperationBinding operationBinding) : base(operationBinding) { }
    private static IEnumerable<IEditorScript> GetScripts(OperationBinding opBinding, XmlSchemaSet schemas)
    {
      var binding = opBinding.Binding;
      var service = binding.ServiceDescription;
      var operation = service.PortTypes[binding.Type.Name].Operations.OfType<Operation>()
        .FirstOrDefault(o => o.Name == opBinding.Name);
      var elem = service.Messages[operation.Messages.Input.Message.Name].Parts[0].Element;
      //var schemaElem = service.Types.Schemas
      //  .SelectMany(s => s.Elements.Values.OfType<XmlSchemaElement>())
      //  .FirstOrDefault(e => e.Name == elem.Name);

      var settings = new XmlWriterSettings()
      {
        OmitXmlDeclaration = true,
        Indent = true,
        IndentChars = "  "
      };

      using (var writer = new StringWriter())
      using (var xml = XmlTextWriter.Create(writer, settings))
      {
        var generator = new Microsoft.Xml.XMLGen.XmlSampleGenerator(schemas, elem);

        xml.WriteStartElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
        xml.WriteAttributeString("xmlns", "soap", null, elem.Namespace);
        xml.WriteStartElement("soapenv", "Header", "http://schemas.xmlsoap.org/soap/envelope/");
        xml.WriteEndElement();
        xml.WriteStartElement("soapenv", "Body", "http://schemas.xmlsoap.org/soap/envelope/");

        generator.WriteXml(xml);

        xml.WriteEndElement();
        xml.WriteEndElement();

        xml.Flush();
        writer.Flush();
        return Enumerable.Repeat<IEditorScript>(new EditorScript()
        {
          Name = "Sample Request",
          Script = writer.ToString(),
          Action = opBinding.Name
        }, 1);
      }
    }
		internal void SetParent (OperationBinding ob)
		{
			operationBinding = ob;
		}
Exemple #35
0
        public string GenerateHttpSoapMessage(Port port, OperationBinding obin, Operation oper, OperationMessage msg)
        {
            string req = "";

            if (msg is OperationInput) {
                SoapAddressBinding sab = port.Extensions.Find(typeof(SoapAddressBinding)) as SoapAddressBinding;
                SoapOperationBinding sob = obin.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding;

                req += "POST " + GetAbsolutePath(sab.Location) + "\n";
                req += "SOAPAction: " + sob.SoapAction + "\n";
                req += "Content-Type: text/xml; charset=utf-8\n";
                req += "Content-Length: " + GetLiteral("string") + "\n";
                req += "Host: " + GetLiteral("string") + "\n\n";
            }
            else {
                req += "HTTP/1.0 200 OK\n";
                req += "Content-Type: text/xml; charset=utf-8\n";
                req += "Content-Length: " + GetLiteral("string") + "\n\n";
            }

            req += GenerateSoapMessage(obin, oper, msg);
            return req;
        }
 public int IndexOf(OperationBinding bindingOperation)
 {
     return(base.List.IndexOf(bindingOperation));
 }
Exemple #37
0
        public string GenerateMessage(Port port, OperationBinding obin, Operation oper, string protocol, bool generateInput)
        {
            OperationMessage msg = null;
            foreach (OperationMessage opm in oper.Messages) {
                if (opm is OperationInput && generateInput) msg = opm;
                else if (opm is OperationOutput && !generateInput) msg = opm;
            }
            if (msg == null) return null;

            switch (protocol) {
                case "Soap": return GenerateHttpSoapMessage(port, obin, oper, msg);
                case "HttpGet": return GenerateHttpGetMessage(port, obin, oper, msg);
                case "HttpPost": return GenerateHttpPostMessage(port, obin, oper, msg);
            }
            return "Unknown protocol";
        }
 public bool Contains(OperationBinding bindingOperation)
 {
     return(base.List.Contains(bindingOperation));
 }
Exemple #39
0
        public string GenerateSoapMessage(OperationBinding obin, Operation oper, OperationMessage msg)
        {
            SoapOperationBinding sob = obin.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding;
            SoapBindingStyle style = (sob != null) ? sob.Style : SoapBindingStyle.Document;

            MessageBinding msgbin = (msg is OperationInput) ? (MessageBinding)obin.Input : (MessageBinding)obin.Output;
            SoapBodyBinding sbb = msgbin.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
            SoapBindingUse bodyUse = (sbb != null) ? sbb.Use : SoapBindingUse.Literal;

            StringWriter sw = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);
            xtw.Formatting = Formatting.Indented;

            xtw.WriteStartDocument();
            xtw.WriteStartElement("soap", "Envelope", SoapEnvelopeNamespace);
            xtw.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            xtw.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);

            if (bodyUse == SoapBindingUse.Encoded) {
                xtw.WriteAttributeString("xmlns", "soapenc", null, SoapEncodingNamespace);
                xtw.WriteAttributeString("xmlns", "tns", null, msg.Message.Namespace);
            }

            // Serialize headers

            bool writtenHeader = false;
            foreach (object ob in msgbin.Extensions) {
                SoapHeaderBinding hb = ob as SoapHeaderBinding;
                if (hb == null) continue;

                if (!writtenHeader) {
                    xtw.WriteStartElement("soap", "Header", SoapEnvelopeNamespace);
                    writtenHeader = true;
                }

                WriteHeader(xtw, hb);
            }

            if (writtenHeader)
                xtw.WriteEndElement();

            // Serialize body
            xtw.WriteStartElement("soap", "Body", SoapEnvelopeNamespace);

            currentUse = bodyUse;
            WriteBody(xtw, oper, msg, sbb, style);

            xtw.WriteEndElement();
            xtw.WriteEndElement();
            xtw.Close();
            return sw.ToString();
        }
Exemple #40
0
 public bool IsBoundBy(OperationBinding operationBinding)
 {
     return(operationBinding.Name == Name);
 }
		public override void ExportEndpoint (ServiceEndpoint endpoint)
		{
			List<IWsdlExportExtension> extensions = ExportContractInternal (endpoint.Contract);
			
			//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);

			foreach (IWsdlExportExtension extn in extensions)
				extn.ExportEndpoint (this, endpoint_context);

				
		}
Exemple #42
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);
		}
        void ReflectBinding(ReflectedBinding reflectedBinding)
        {
            string bindingName      = reflectedBinding.bindingAttr.Name;
            string bindingNamespace = reflectedBinding.bindingAttr.Namespace;

            if (bindingName.Length == 0)
            {
                bindingName = Service.Name + ProtocolName;
            }
            if (bindingNamespace.Length == 0)
            {
                bindingNamespace = ServiceDescription.TargetNamespace;
            }

            if (reflectedBinding.bindingAttr.Location.Length > 0)
            {
                // If a URL is specified for the WSDL, file, then we just import the
                // binding from there instead of generating it in this WSDL file.
                portType = null;
                binding  = null;
            }
            else
            {
                bindingServiceDescription = GetServiceDescription(bindingNamespace);
                CodeIdentifiers bindingNames = new CodeIdentifiers();
                foreach (Binding b in bindingServiceDescription.Bindings)
                {
                    bindingNames.AddReserved(b.Name);
                }

                bindingName = bindingNames.AddUnique(bindingName, binding);

                portType      = new PortType();
                binding       = new Binding();
                portType.Name = bindingName;
                binding.Name  = bindingName;
                binding.Type  = new XmlQualifiedName(portType.Name, bindingNamespace);
                bindingServiceDescription.Bindings.Add(binding);
                bindingServiceDescription.PortTypes.Add(portType);
            }

            if (portNames == null)
            {
                portNames = new CodeIdentifiers();
                foreach (Port p in Service.Ports)
                {
                    portNames.AddReserved(p.Name);
                }
            }

            port         = new Port();
            port.Binding = new XmlQualifiedName(bindingName, bindingNamespace);
            port.Name    = portNames.AddUnique(bindingName, port);
            Service.Ports.Add(port);

            BeginClass();

            foreach (LogicalMethodInfo method in reflectedBinding.methodList)
            {
                MoveToMethod(method);

                operation               = new Operation();
                operation.Name          = method.Name;
                operation.Documentation = methodAttr.Description;

                operationBinding      = new OperationBinding();
                operationBinding.Name = operation.Name;

                inputMessage   = null;
                outputMessage  = null;
                headerMessages = null;

                if (ReflectMethod())
                {
                    if (inputMessage != null)
                    {
                        bindingServiceDescription.Messages.Add(inputMessage);
                    }
                    if (outputMessage != null)
                    {
                        bindingServiceDescription.Messages.Add(outputMessage);
                    }
                    if (headerMessages != null)
                    {
                        foreach (Message headerMessage in headerMessages)
                        {
                            bindingServiceDescription.Messages.Add(headerMessage);
                        }
                    }
                    binding.Operations.Add(operationBinding);
                    portType.Operations.Add(operation);
                }
            }

            EndClass();
        }
Exemple #44
0
        void ImportPortBinding(bool multipleBindings)
        {
            if (port != null)
            {
                if (multipleBindings)
                {
                    className = binding.Name;
                }
                else
                {
                    className = service.Name;
                }
            }
            else
            {
                className = binding.Name;
            }

            className = classNames.AddUnique(CodeIdentifier.MakeValid(className), port);
            className = className.Replace("_x0020_", ""); // MS.NET seems to do this

            try
            {
                portType = ServiceDescriptions.GetPortType(binding.Type);
                if (portType == null)
                {
                    throw new Exception("Port type not found: " + binding.Type);
                }

                CodeTypeDeclaration codeClass = BeginClass();
                codeTypeDeclaration = codeClass;
                AddCodeType(codeClass, port != null ? port.Documentation : null);
                codeClass.Attributes = MemberAttributes.Public;

                if (service != null && service.Documentation != null && service.Documentation != "")
                {
                    AddComments(codeClass, service.Documentation);
                }

                if (Style == ServiceDescriptionImportStyle.Client)
                {
                    CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Diagnostics.DebuggerStepThroughAttribute");
                    AddCustomAttribute(codeClass, att, true);

                    att = new CodeAttributeDeclaration("System.ComponentModel.DesignerCategoryAttribute");
                    att.Arguments.Add(GetArg("code"));
                    AddCustomAttribute(codeClass, att, true);
                }
                else
                {
                    codeClass.TypeAttributes = System.Reflection.TypeAttributes.Abstract | System.Reflection.TypeAttributes.Public;
                }

                if (binding.Operations.Count == 0)
                {
                    warnings |= ServiceDescriptionImportWarnings.NoMethodsGenerated;
                    return;
                }

                foreach (OperationBinding oper in binding.Operations)
                {
                    operationBinding = oper;
                    operation        = FindPortOperation();
                    if (operation == null)
                    {
                        throw new Exception("Operation " + operationBinding.Name + " not found in portType " + PortType.Name);
                    }

                    inputMessage  = null;
                    outputMessage = null;

                    foreach (OperationMessage omsg in operation.Messages)
                    {
                        Message msg = ServiceDescriptions.GetMessage(omsg.Message);
                        if (msg == null)
                        {
                            throw new Exception("Message not found: " + omsg.Message);
                        }

                        if (omsg is OperationInput)
                        {
                            inputMessage = msg;
                        }
                        else
                        {
                            outputMessage = msg;
                        }
                    }

                    CodeMemberMethod method = GenerateMethod();

                    if (method != null)
                    {
                        methodName = method.Name;
                        if (operation.Documentation != null && operation.Documentation != "")
                        {
                            AddComments(method, operation.Documentation);
                        }
#if NET_2_0
                        if (Style == ServiceDescriptionImportStyle.Client)
                        {
                            AddAsyncMembers(method.Name, method);
                        }
#endif
                    }
                }

#if NET_2_0
                if (Style == ServiceDescriptionImportStyle.Client)
                {
                    AddAsyncTypes();
                }
#endif

                EndClass();
            }
            catch (InvalidOperationException ex)
            {
                warnings |= ServiceDescriptionImportWarnings.NoCodeGenerated;
                UnsupportedBindingWarning(ex.Message);
            }
        }
Exemple #45
0
 public OperationDescription GetOperationDescription(WsdlNS.OperationBinding operationBinding)
 {
     return(_operationDescriptionBindings[operationBinding]);
 }
        /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="Operation.IsBoundBy"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public bool IsBoundBy(OperationBinding operationBinding) {
            if (operationBinding.Name != Name) return false;
            OperationMessage input = Messages.Input;
            if (input != null) {
                if (operationBinding.Input == null) return false;

                string portTypeInputName = GetMessageName(Name, input.Name, true);
                string bindingInputName = GetMessageName(operationBinding.Name, operationBinding.Input.Name, true);
                if (bindingInputName != portTypeInputName) return false;
            }
            else if (operationBinding.Input != null)
                return false;
                
            OperationMessage output = Messages.Output;
            if (output != null) {
                if (operationBinding.Output == null) return false;

                string portTypeOutputName = GetMessageName(Name, output.Name, false);
                string bindingOutputName = GetMessageName(operationBinding.Name, operationBinding.Output.Name, false);
                if (bindingOutputName != portTypeOutputName) return false;
            }
            else if (operationBinding.Output != null)
                return false;
            return true;
        }
Exemple #47
0
        // --------------------------------------------------------------------------------------------------

        internal void AddOperationBinding(OperationDescription operationDescription, WsdlNS.OperationBinding wsdlOperationBinding)
        {
            _wsdlOperationBindings.Add(operationDescription, wsdlOperationBinding);
            _operationDescriptionBindings.Add(wsdlOperationBinding, operationDescription);
        }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.Insert"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Insert(int index, OperationBinding bindingOperation) {
     List.Insert(index, bindingOperation);
 }
 internal void AddOperationBinding(OperationDescription operationDescription, OperationBinding wsdlOperationBinding)
 {
     this.wsdlOperationBindings.Add(operationDescription, wsdlOperationBinding);
     this.operationDescriptionBindings.Add(wsdlOperationBinding, operationDescription);
 }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.Contains"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public bool Contains(OperationBinding bindingOperation) {
     return List.Contains(bindingOperation);
 }
 public OperationDescription GetOperationDescription(OperationBinding operationBinding)
 {
     return this.operationDescriptionBindings[operationBinding];
 }
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="OperationBindingCollection.CopyTo"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void CopyTo(OperationBinding[] array, int index) {
     List.CopyTo(array, index);
 }
 public void Insert(int index, OperationBinding bindingOperation)
 {
     base.List.Insert(index, bindingOperation);
 }
 internal void SetParent(OperationBinding parent) {
     this.parent = parent;
 }
Exemple #55
0
 internal void SetParent(OperationBinding ob)
 {
     operationBinding = ob;
 }
Exemple #56
0
		void ImportOperationBinding ()
		{
			operationBinding = new OperationBinding ();
			operationBinding.Name = methodStubInfo.OperationName;
			
			InputBinding inOp = new InputBinding ();
			operationBinding.Input = inOp;
			
			OutputBinding outOp = new OutputBinding ();
			operationBinding.Output = outOp;
			
			if (methodStubInfo.OperationName != methodStubInfo.Name)
				inOp.Name = outOp.Name = methodStubInfo.Name;
			
			binding.Operations.Add (operationBinding);
		}
Exemple #57
0
        public string GenerateHttpPostMessage(Port port, OperationBinding obin, Operation oper, OperationMessage msg)
        {
            string req = "";

            if (msg is OperationInput) {
                HttpAddressBinding sab = port.Extensions.Find(typeof(HttpAddressBinding)) as HttpAddressBinding;
                HttpOperationBinding sob = obin.Extensions.Find(typeof(HttpOperationBinding)) as HttpOperationBinding;
                string location = new Uri(sab.Location).AbsolutePath + sob.Location;
                req += "POST " + location + "\n";
                req += "Content-Type: application/x-www-form-urlencoded\n";
                req += "Content-Length: " + GetLiteral("string") + "\n";
                req += "Host: " + GetLiteral("string") + "\n\n";
                req += BuildQueryString(msg);
            }
            else return GenerateHttpGetMessage(port, obin, oper, msg);

            return req;
        }