Example #1
0
 private void MoveToBinding(System.Web.Services.Description.Service service, System.Web.Services.Description.Port port, System.Web.Services.Description.Binding binding, System.Web.Services.Description.PortType portType)
 {
     this.service        = service;
     this.port           = port;
     this.portType       = portType;
     this.binding        = binding;
     this.encodedBinding = false;
 }
        private void ReflectBinding(ReflectedBinding reflectedBinding)
        {
            string identifier = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
            string ns         = reflectedBinding.bindingAttr.Namespace;

            if (identifier.Length == 0)
            {
                identifier = this.Service.Name + this.ProtocolName;
            }
            if (ns.Length == 0)
            {
                ns = this.ServiceDescription.TargetNamespace;
            }
            WsiProfiles none = WsiProfiles.None;

            if (reflectedBinding.bindingAttr.Location.Length > 0)
            {
                this.portType = null;
                this.binding  = null;
            }
            else
            {
                this.bindingServiceDescription = this.GetServiceDescription(ns);
                CodeIdentifiers identifiers = new CodeIdentifiers();
                foreach (System.Web.Services.Description.Binding binding in this.bindingServiceDescription.Bindings)
                {
                    identifiers.AddReserved(binding.Name);
                }
                identifier         = identifiers.AddUnique(identifier, this.binding);
                this.portType      = new System.Web.Services.Description.PortType();
                this.binding       = new System.Web.Services.Description.Binding();
                this.portType.Name = identifier;
                this.binding.Name  = identifier;
                this.binding.Type  = new XmlQualifiedName(this.portType.Name, ns);
                none = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
                if (reflectedBinding.bindingAttr.EmitConformanceClaims && (none != WsiProfiles.None))
                {
                    System.Web.Services.Description.ServiceDescription.AddConformanceClaims(this.binding.GetDocumentationElement(), none);
                }
                this.bindingServiceDescription.Bindings.Add(this.binding);
                this.bindingServiceDescription.PortTypes.Add(this.portType);
            }
            if (this.portNames == null)
            {
                this.portNames = new CodeIdentifiers();
                foreach (System.Web.Services.Description.Port port in this.Service.Ports)
                {
                    this.portNames.AddReserved(port.Name);
                }
            }
            this.port         = new System.Web.Services.Description.Port();
            this.port.Binding = new XmlQualifiedName(identifier, ns);
            this.port.Name    = this.portNames.AddUnique(identifier, this.port);
            this.Service.Ports.Add(this.port);
            this.BeginClass();
            if ((reflectedBinding.methodList != null) && (reflectedBinding.methodList.Count > 0))
            {
                foreach (LogicalMethodInfo info in reflectedBinding.methodList)
                {
                    this.MoveToMethod(info);
                    this.operation      = new System.Web.Services.Description.Operation();
                    this.operation.Name = XmlConvert.EncodeLocalName(info.Name);
                    if ((this.methodAttr.Description != null) && (this.methodAttr.Description.Length > 0))
                    {
                        this.operation.Documentation = this.methodAttr.Description;
                    }
                    this.operationBinding      = new System.Web.Services.Description.OperationBinding();
                    this.operationBinding.Name = this.operation.Name;
                    this.inputMessage          = null;
                    this.outputMessage         = null;
                    this.headerMessages        = null;
                    if (this.ReflectMethod())
                    {
                        if (this.inputMessage != null)
                        {
                            this.bindingServiceDescription.Messages.Add(this.inputMessage);
                        }
                        if (this.outputMessage != null)
                        {
                            this.bindingServiceDescription.Messages.Add(this.outputMessage);
                        }
                        if (this.headerMessages != null)
                        {
                            foreach (Message message in this.headerMessages)
                            {
                                this.bindingServiceDescription.Messages.Add(message);
                            }
                        }
                        this.binding.Operations.Add(this.operationBinding);
                        this.portType.Operations.Add(this.operation);
                    }
                }
            }
            if (((this.binding != null) && (none == WsiProfiles.BasicProfile1_1)) && (this.ProtocolName == "Soap"))
            {
                BasicProfileViolationCollection violations = new BasicProfileViolationCollection();
                WebServicesInteroperability.AnalyzeBinding(this.binding, this.bindingServiceDescription, this.ServiceDescriptions, violations);
                if (violations.Count > 0)
                {
                    throw new InvalidOperationException(System.Web.Services.Res.GetString("WebWsiViolation", new object[] { this.ServiceType.FullName, violations.ToString() }));
                }
            }
            this.EndClass();
        }
        public ServiceEndpointCollection ImportEndpoints(System.Web.Services.Description.PortType wsdlPortType)
        {
            Contract.Ensures(Contract.Result <System.ServiceModel.Description.ServiceEndpointCollection>() != null);

            return(default(ServiceEndpointCollection));
        }
 public ContractDescription ImportContract(System.Web.Services.Description.PortType wsdlPortType)
 {
     return(default(ContractDescription));
 }
Example #5
0
        internal bool GenerateCode(System.CodeDom.CodeNamespace codeNamespace, System.Xml.Serialization.ImportContext importContext, Hashtable exportContext)
        {
            this.bindingCount  = 0;
            this.anyPorts      = false;
            this.codeNamespace = codeNamespace;
            Hashtable hashtable  = new Hashtable();
            Hashtable hashtable2 = new Hashtable();

            foreach (ServiceDescription description in this.ServiceDescriptions)
            {
                foreach (System.Web.Services.Description.Service service in description.Services)
                {
                    foreach (System.Web.Services.Description.Port port in service.Ports)
                    {
                        System.Web.Services.Description.Binding key = this.ServiceDescriptions.GetBinding(port.Binding);
                        if (!hashtable.Contains(key))
                        {
                            System.Web.Services.Description.PortType portType = this.ServiceDescriptions.GetPortType(key.Type);
                            this.MoveToBinding(service, port, key, portType);
                            if (this.IsBindingSupported())
                            {
                                this.bindingCount++;
                                this.anyPorts = true;
                                hashtable.Add(key, key);
                            }
                            else if (key != null)
                            {
                                hashtable2[key] = key;
                            }
                        }
                    }
                }
            }
            if (this.bindingCount == 0)
            {
                foreach (ServiceDescription description2 in this.ServiceDescriptions)
                {
                    foreach (System.Web.Services.Description.Binding binding2 in description2.Bindings)
                    {
                        if (!hashtable2.Contains(binding2))
                        {
                            System.Web.Services.Description.PortType type2 = this.ServiceDescriptions.GetPortType(binding2.Type);
                            this.MoveToBinding(binding2, type2);
                            if (this.IsBindingSupported())
                            {
                                this.bindingCount++;
                            }
                        }
                    }
                }
            }
            if (this.bindingCount == 0)
            {
                return(codeNamespace.Comments.Count > 0);
            }
            this.importContext = importContext;
            this.exportContext = exportContext;
            this.BeginNamespace();
            hashtable.Clear();
            foreach (ServiceDescription description3 in this.ServiceDescriptions)
            {
                if (this.anyPorts)
                {
                    foreach (System.Web.Services.Description.Service service2 in description3.Services)
                    {
                        foreach (System.Web.Services.Description.Port port2 in service2.Ports)
                        {
                            System.Web.Services.Description.Binding  binding = this.ServiceDescriptions.GetBinding(port2.Binding);
                            System.Web.Services.Description.PortType type3   = this.ServiceDescriptions.GetPortType(binding.Type);
                            this.MoveToBinding(service2, port2, binding, type3);
                            if (this.IsBindingSupported() && !hashtable.Contains(binding))
                            {
                                this.GenerateClassForBinding();
                                hashtable.Add(binding, binding);
                            }
                        }
                    }
                }
                else
                {
                    foreach (System.Web.Services.Description.Binding binding4 in description3.Bindings)
                    {
                        System.Web.Services.Description.PortType type4 = this.ServiceDescriptions.GetPortType(binding4.Type);
                        this.MoveToBinding(binding4, type4);
                        if (this.IsBindingSupported())
                        {
                            this.GenerateClassForBinding();
                        }
                    }
                }
            }
            this.EndNamespace();
            return(true);
        }
Example #6
0
 private void MoveToBinding(System.Web.Services.Description.Binding binding, System.Web.Services.Description.PortType portType)
 {
     this.MoveToBinding(null, null, binding, portType);
 }
		public System.Web.Services.Description.PortType ReadObject_PortType (bool isNullable, bool checkType)
		{
			System.Web.Services.Description.PortType ob = null;
			if (isNullable && ReadNull()) return null;

			if (checkType) 
			{
				System.Xml.XmlQualifiedName t = GetXsiType();
				if (t != null) 
				{
					if (t.Name != "PortType" || t.Namespace != "http://schemas.xmlsoap.org/wsdl/")
						throw CreateUnknownTypeException(t);
				}
			}

			ob = new System.Web.Services.Description.PortType ();

			Reader.MoveToElement();

			while (Reader.MoveToNextAttribute())
			{
				if (Reader.LocalName == "name" && Reader.NamespaceURI == "") {
					ob.Name = XmlConvert.DecodeName(Reader.Value);
				}
				else if (IsXmlnsAttribute (Reader.Name)) {
				}
				else {
					UnknownNode (ob);
				}
			}

			Reader.MoveToElement();
			if (Reader.IsEmptyElement) {
				Reader.Skip ();
				return ob;
			}

			Reader.ReadStartElement();
			Reader.MoveToContent();

			bool b34=false, b35=false;

			System.Web.Services.Description.OperationCollection o37 = ob.Operations;
			int n36=0;

			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
			{
				if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
				{
					if (Reader.LocalName == "operation" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b34) {
						if (o37 == null)
							throw CreateReadOnlyCollectionException ("System.Web.Services.Description.OperationCollection");
						o37.Add (ReadObject_Operation (false, true));
						n36++;
					}
					else if (Reader.LocalName == "documentation" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b35) {
						b35 = true;
						ob.Documentation = Reader.ReadElementString ();
					}
					else {
						UnknownNode (ob);
					}
				}
				else
					UnknownNode(ob);

				Reader.MoveToContent();
			}


			ReadEndElement();

			return ob;
		}
 private void ReflectBinding(ReflectedBinding reflectedBinding)
 {
     string identifier = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
     string ns = reflectedBinding.bindingAttr.Namespace;
     if (identifier.Length == 0)
     {
         identifier = this.Service.Name + this.ProtocolName;
     }
     if (ns.Length == 0)
     {
         ns = this.ServiceDescription.TargetNamespace;
     }
     WsiProfiles none = WsiProfiles.None;
     if (reflectedBinding.bindingAttr.Location.Length > 0)
     {
         this.portType = null;
         this.binding = null;
     }
     else
     {
         this.bindingServiceDescription = this.GetServiceDescription(ns);
         CodeIdentifiers identifiers = new CodeIdentifiers();
         foreach (System.Web.Services.Description.Binding binding in this.bindingServiceDescription.Bindings)
         {
             identifiers.AddReserved(binding.Name);
         }
         identifier = identifiers.AddUnique(identifier, this.binding);
         this.portType = new System.Web.Services.Description.PortType();
         this.binding = new System.Web.Services.Description.Binding();
         this.portType.Name = identifier;
         this.binding.Name = identifier;
         this.binding.Type = new XmlQualifiedName(this.portType.Name, ns);
         none = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
         if (reflectedBinding.bindingAttr.EmitConformanceClaims && (none != WsiProfiles.None))
         {
             System.Web.Services.Description.ServiceDescription.AddConformanceClaims(this.binding.GetDocumentationElement(), none);
         }
         this.bindingServiceDescription.Bindings.Add(this.binding);
         this.bindingServiceDescription.PortTypes.Add(this.portType);
     }
     if (this.portNames == null)
     {
         this.portNames = new CodeIdentifiers();
         foreach (System.Web.Services.Description.Port port in this.Service.Ports)
         {
             this.portNames.AddReserved(port.Name);
         }
     }
     this.port = new System.Web.Services.Description.Port();
     this.port.Binding = new XmlQualifiedName(identifier, ns);
     this.port.Name = this.portNames.AddUnique(identifier, this.port);
     this.Service.Ports.Add(this.port);
     this.BeginClass();
     if ((reflectedBinding.methodList != null) && (reflectedBinding.methodList.Count > 0))
     {
         foreach (LogicalMethodInfo info in reflectedBinding.methodList)
         {
             this.MoveToMethod(info);
             this.operation = new System.Web.Services.Description.Operation();
             this.operation.Name = XmlConvert.EncodeLocalName(info.Name);
             if ((this.methodAttr.Description != null) && (this.methodAttr.Description.Length > 0))
             {
                 this.operation.Documentation = this.methodAttr.Description;
             }
             this.operationBinding = new System.Web.Services.Description.OperationBinding();
             this.operationBinding.Name = this.operation.Name;
             this.inputMessage = null;
             this.outputMessage = null;
             this.headerMessages = null;
             if (this.ReflectMethod())
             {
                 if (this.inputMessage != null)
                 {
                     this.bindingServiceDescription.Messages.Add(this.inputMessage);
                 }
                 if (this.outputMessage != null)
                 {
                     this.bindingServiceDescription.Messages.Add(this.outputMessage);
                 }
                 if (this.headerMessages != null)
                 {
                     foreach (Message message in this.headerMessages)
                     {
                         this.bindingServiceDescription.Messages.Add(message);
                     }
                 }
                 this.binding.Operations.Add(this.operationBinding);
                 this.portType.Operations.Add(this.operation);
             }
         }
     }
     if (((this.binding != null) && (none == WsiProfiles.BasicProfile1_1)) && (this.ProtocolName == "Soap"))
     {
         BasicProfileViolationCollection violations = new BasicProfileViolationCollection();
         WebServicesInteroperability.AnalyzeBinding(this.binding, this.bindingServiceDescription, this.ServiceDescriptions, violations);
         if (violations.Count > 0)
         {
             throw new InvalidOperationException(System.Web.Services.Res.GetString("WebWsiViolation", new object[] { this.ServiceType.FullName, violations.ToString() }));
         }
     }
     this.EndClass();
 }
Example #9
0
 internal void SetParent(System.Web.Services.Description.PortType parent)
 {
     this.parent = parent;
 }
 internal void SetParent(System.Web.Services.Description.PortType parent)
 {
     this.parent = parent;
 }
 private void MoveToBinding(System.Web.Services.Description.Service service, System.Web.Services.Description.Port port, System.Web.Services.Description.Binding binding, System.Web.Services.Description.PortType portType)
 {
     this.service = service;
     this.port = port;
     this.portType = portType;
     this.binding = binding;
     this.encodedBinding = false;
 }