bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo) { serviceDescription = desc; // Look for an unused name int n=0; string name = binfo.Name; bool found; do { found = false; foreach (Binding bi in desc.Bindings) if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; } } while (found); // Create the binding binding = new Binding (); binding.Name = name; binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace); if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.EmitConformanceClaims) { XmlDocument doc = new XmlDocument (); XmlElement docElement = doc.CreateElement ("wsdl", "documentation", "http://schemas.xmlsoap.org/wsdl/"); XmlElement claimsElement = doc.CreateElement ("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/"); claimsElement.Attributes.Append (doc.CreateAttribute ("conformsTo")).Value = "http://ws-i.org/profiles/basic/1.1"; docElement.AppendChild (claimsElement); binding.DocumentationElement = docElement; } portType = new PortType (); portType.Name = binding.Name; BeginClass (); foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectDescription (); } foreach (MethodStubInfo method in typeInfo.Methods) { methodStubInfo = method; string metBinding = ReflectMethodBinding (); if (typeInfo.GetBinding (metBinding) != binfo) continue; operation = new Operation (); operation.Name = method.OperationName; operation.Documentation = method.MethodAttribute.Description; // FIXME: SOAP 1.1 and SOAP 1.2 should share // the same message definitions. inputMessage = new Message (); inputMessage.Name = method.Name + ProtocolName + "In"; ServiceDescription.Messages.Add (inputMessage); outputMessage = new Message (); outputMessage.Name = method.Name + ProtocolName + "Out"; ServiceDescription.Messages.Add (outputMessage); OperationInput inOp = new OperationInput (); if (method.Name != method.OperationName) inOp.Name = method.Name; Operation.Messages.Add (inOp); inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace); OperationOutput outOp = new OperationOutput (); if (method.Name != method.OperationName) outOp.Name = method.Name; Operation.Messages.Add (outOp); outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace); portType.Operations.Add (operation); ImportOperationBinding (); if (!ReflectMethod ()) { // (It is somewhat hacky) If we don't // add input/output Messages, update // portType/input/@message and // porttype/output/@message. Message dupIn = Parent.MappedMessagesIn [method.MethodInfo]; ServiceDescription.Messages.Remove (inputMessage); inOp.Message = new XmlQualifiedName (dupIn.Name, ServiceDescription.TargetNamespace); Message dupOut = Parent.MappedMessagesOut [method.MethodInfo]; ServiceDescription.Messages.Remove (outputMessage); outOp.Message = new XmlQualifiedName (dupOut.Name, ServiceDescription.TargetNamespace); } foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectMethod (); } } EndClass (); if (portType.Operations.Count > 0) { desc.Bindings.Add (binding); desc.PortTypes.Add (portType); return true; } else return false; }
bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo) { serviceDescription = desc; // Look for an unused name int n=0; string name = binfo.Name; bool found; do { found = false; foreach (Binding bi in desc.Bindings) if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; } } while (found); // Create the binding binding = new Binding (); binding.Name = name; binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace); portType = new PortType (); portType.Name = binding.Name; BeginClass (); foreach (MethodStubInfo method in typeInfo.Methods) { methodStubInfo = method; string metBinding = ReflectMethodBinding (); if (typeInfo.GetBinding (metBinding) != binfo) continue; operation = new Operation (); operation.Name = method.OperationName; operation.Documentation = method.MethodAttribute.Description; inputMessage = new Message (); inputMessage.Name = method.Name + ProtocolName + "In"; ServiceDescription.Messages.Add (inputMessage); outputMessage = new Message (); outputMessage.Name = method.Name + ProtocolName + "Out"; ServiceDescription.Messages.Add (outputMessage); OperationInput inOp = new OperationInput (); if (method.Name != method.OperationName) inOp.Name = method.Name; Operation.Messages.Add (inOp); inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace); OperationOutput outOp = new OperationOutput (); if (method.Name != method.OperationName) outOp.Name = method.Name; Operation.Messages.Add (outOp); outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace); portType.Operations.Add (operation); ImportOperationBinding (); ReflectMethod (); foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectMethod (); } } EndClass (); if (portType.Operations.Count > 0) { desc.Bindings.Add (binding); desc.PortTypes.Add (portType); return true; } else return false; }