internal void Reflect() { Hashtable reflectedBindings = new Hashtable(); for (int i = 0; i < reflector.Methods.Length; i++) { MoveToMethod(reflector.Methods[i]); string bindingName = ReflectMethodBinding(); if (bindingName == null) { bindingName = string.Empty; } ReflectedBinding reflectedBinding = (ReflectedBinding)reflectedBindings[bindingName]; if (reflectedBinding == null) { reflectedBinding = new ReflectedBinding(); if (bindingName.Length == 0) { reflectedBinding.bindingAttr = new WebServiceBindingAttribute(); } else { reflectedBinding.bindingAttr = WebServiceBindingReflector.GetAttribute(method, bindingName); } reflectedBindings.Add(bindingName, reflectedBinding); } if (reflectedBinding.methodList == null) { reflectedBinding.methodList = new ArrayList(); } if (reflectedBinding.bindingAttr.Location.Length == 0) { reflectedBinding.methodList.Add(method); } else { AddImport(reflectedBinding.bindingAttr.Namespace, reflectedBinding.bindingAttr.Location); } } foreach (ReflectedBinding reflectedBinding in reflectedBindings.Values) { ReflectBinding(reflectedBinding); } }
internal void Reflect() { this.emptyBinding = false; Hashtable hashtable = new Hashtable(); Hashtable hashtable2 = new Hashtable(); for (int i = 0; i < this.reflector.Methods.Length; i++) { this.MoveToMethod(this.reflector.Methods[i]); string str = this.ReflectMethodBinding(); if (str == null) { str = string.Empty; } ReflectedBinding binding = (ReflectedBinding)hashtable2[str]; if (binding == null) { binding = new ReflectedBinding { bindingAttr = WebServiceBindingReflector.GetAttribute(this.method, str) }; if ((binding.bindingAttr == null) || ((str.Length == 0) && (binding.bindingAttr.Location.Length > 0))) { binding.bindingAttr = new WebServiceBindingAttribute(); } hashtable2.Add(str, binding); } if (binding.bindingAttr.Location.Length == 0) { if (binding.methodList == null) { binding.methodList = new ArrayList(); } binding.methodList.Add(this.method); hashtable[binding.bindingAttr.Name] = this.method; } else { this.AddImport(binding.bindingAttr.Namespace, binding.bindingAttr.Location); } } foreach (ReflectedBinding binding2 in hashtable2.Values) { this.ReflectBinding(binding2); } if (hashtable2.Count == 0) { this.emptyBinding = true; ReflectedBinding reflectedBinding = null; foreach (WebServiceBindingAttribute attribute in this.ServiceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false)) { if (hashtable[attribute.Name] == null) { if (reflectedBinding != null) { reflectedBinding = null; break; } reflectedBinding = new ReflectedBinding(attribute); } } if (reflectedBinding != null) { this.ReflectBinding(reflectedBinding); } } foreach (Type type in this.ServiceType.GetInterfaces()) { foreach (WebServiceBindingAttribute attribute2 in type.GetCustomAttributes(typeof(WebServiceBindingAttribute), false)) { if (hashtable[attribute2.Name] == null) { this.ReflectBinding(new ReflectedBinding(attribute2)); } } } this.ReflectDescription(); }
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(); }
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(); }
internal void Reflect() { emptyBinding = false; Hashtable bindings = new Hashtable(); Hashtable reflectedBindings = new Hashtable(); for (int i = 0; i < reflector.Methods.Length; i++) { MoveToMethod(reflector.Methods[i]); string bindingName = ReflectMethodBinding(); if (bindingName == null) { bindingName = string.Empty; } ReflectedBinding reflectedBinding = (ReflectedBinding)reflectedBindings[bindingName]; if (reflectedBinding == null) { reflectedBinding = new ReflectedBinding(); reflectedBinding.bindingAttr = WebServiceBindingReflector.GetAttribute(method, bindingName); if (reflectedBinding.bindingAttr == null || (bindingName.Length == 0 && reflectedBinding.bindingAttr.Location.Length > 0)) { reflectedBinding.bindingAttr = new WebServiceBindingAttribute(); } reflectedBindings.Add(bindingName, reflectedBinding); } if (reflectedBinding.bindingAttr.Location.Length == 0) { if (reflectedBinding.methodList == null) { reflectedBinding.methodList = new ArrayList(); } reflectedBinding.methodList.Add(method); bindings[reflectedBinding.bindingAttr.Name] = method; } else { AddImport(reflectedBinding.bindingAttr.Namespace, reflectedBinding.bindingAttr.Location); } } foreach (ReflectedBinding reflectedBinding in reflectedBindings.Values) { ReflectBinding(reflectedBinding); } // Only check for empty binding if we do not have real bindings if (reflectedBindings.Count == 0) { // It should be possible to get the value for WebReference.ServiceLocationUrl even if the web service has no web methods. // This is a common scenario for Whitehorse during the early stages of development when a user is defining the web // components and their inter-connections, but not the details of whatmethods will be present on each web service. // get all WebServiceBindings emptyBinding = true; ReflectedBinding binding = null; object[] attrs = ServiceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) { continue; } if (binding != null) { binding = null; break; } binding = new ReflectedBinding(bindingAttribute); } if (binding != null) { ReflectBinding(binding); } } Type[] interfaces = ServiceType.GetInterfaces(); // iterate through all the interfaces for this type foreach (Type bindingInterface in interfaces) { object[] attrs = bindingInterface.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) { continue; } ReflectBinding(new ReflectedBinding(bindingAttribute)); } } ReflectDescription(); }
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(); }
internal void Reflect() { emptyBinding = false; Hashtable bindings = new Hashtable(); Hashtable reflectedBindings = new Hashtable(); for (int i = 0; i < reflector.Methods.Length; i++) { MoveToMethod(reflector.Methods[i]); string bindingName = ReflectMethodBinding(); if (bindingName == null) bindingName = string.Empty; ReflectedBinding reflectedBinding = (ReflectedBinding)reflectedBindings[bindingName]; if (reflectedBinding == null) { reflectedBinding = new ReflectedBinding(); reflectedBinding.bindingAttr = WebServiceBindingReflector.GetAttribute(method, bindingName); if (reflectedBinding.bindingAttr == null || (bindingName.Length == 0 && reflectedBinding.bindingAttr.Location.Length > 0)) { reflectedBinding.bindingAttr = new WebServiceBindingAttribute(); } reflectedBindings.Add(bindingName, reflectedBinding); } if (reflectedBinding.bindingAttr.Location.Length == 0) { if (reflectedBinding.methodList == null) reflectedBinding.methodList = new ArrayList(); reflectedBinding.methodList.Add(method); bindings[reflectedBinding.bindingAttr.Name] = method; } else { AddImport(reflectedBinding.bindingAttr.Namespace, reflectedBinding.bindingAttr.Location); } } foreach (ReflectedBinding reflectedBinding in reflectedBindings.Values) { ReflectBinding(reflectedBinding); } // Only check for empty binding if we do not have real bindings if (reflectedBindings.Count == 0) { // It should be possible to get the value for WebReference.ServiceLocationUrl even if the web service has no web methods. // This is a common scenario for Whitehorse during the early stages of development when a user is defining the web // components and their inter-connections, but not the details of whatmethods will be present on each web service. // get all WebServiceBindings emptyBinding = true; ReflectedBinding binding = null; object[] attrs = ServiceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) continue; if (binding != null) { binding = null; break; } binding = new ReflectedBinding(bindingAttribute); } if (binding != null) ReflectBinding(binding); } Type[] interfaces = ServiceType.GetInterfaces(); // iterate through all the interfaces for this type foreach (Type bindingInterface in interfaces) { object[] attrs = bindingInterface.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) continue; ReflectBinding(new ReflectedBinding(bindingAttribute)); } } ReflectDescription(); }
internal void Reflect() { this.emptyBinding = false; Hashtable hashtable = new Hashtable(); Hashtable hashtable2 = new Hashtable(); for (int i = 0; i < this.reflector.Methods.Length; i++) { this.MoveToMethod(this.reflector.Methods[i]); string str = this.ReflectMethodBinding(); if (str == null) { str = string.Empty; } ReflectedBinding binding = (ReflectedBinding) hashtable2[str]; if (binding == null) { binding = new ReflectedBinding { bindingAttr = WebServiceBindingReflector.GetAttribute(this.method, str) }; if ((binding.bindingAttr == null) || ((str.Length == 0) && (binding.bindingAttr.Location.Length > 0))) { binding.bindingAttr = new WebServiceBindingAttribute(); } hashtable2.Add(str, binding); } if (binding.bindingAttr.Location.Length == 0) { if (binding.methodList == null) { binding.methodList = new ArrayList(); } binding.methodList.Add(this.method); hashtable[binding.bindingAttr.Name] = this.method; } else { this.AddImport(binding.bindingAttr.Namespace, binding.bindingAttr.Location); } } foreach (ReflectedBinding binding2 in hashtable2.Values) { this.ReflectBinding(binding2); } if (hashtable2.Count == 0) { this.emptyBinding = true; ReflectedBinding reflectedBinding = null; foreach (WebServiceBindingAttribute attribute in this.ServiceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false)) { if (hashtable[attribute.Name] == null) { if (reflectedBinding != null) { reflectedBinding = null; break; } reflectedBinding = new ReflectedBinding(attribute); } } if (reflectedBinding != null) { this.ReflectBinding(reflectedBinding); } } foreach (Type type in this.ServiceType.GetInterfaces()) { foreach (WebServiceBindingAttribute attribute2 in type.GetCustomAttributes(typeof(WebServiceBindingAttribute), false)) { if (hashtable[attribute2.Name] == null) { this.ReflectBinding(new ReflectedBinding(attribute2)); } } } this.ReflectDescription(); }
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(); }