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; }
internal void SetParent(System.Web.Services.Description.Binding parent) { this.parent = parent; }
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(); }
public ServiceEndpointCollection ImportEndpoints(System.Web.Services.Description.Binding wsdlBinding) { Contract.Ensures(Contract.Result <System.ServiceModel.Description.ServiceEndpointCollection>() != null); return(default(ServiceEndpointCollection)); }
public System.ServiceModel.Channels.Binding ImportBinding(System.Web.Services.Description.Binding wsdlBinding) { return(default(System.ServiceModel.Channels.Binding)); }
private string GenerateSOAP(string stringNodeName, string url) { XmlTextReader xmlr = null; string returnval = null; string headerval = null; int indexOfOp = -1; int indexOfPort = -1; System.Web.Services.Description.ServiceDescription servdesc = null; System.Xml.Serialization.XmlSchemas schemas = null; XmlGenerator xmlGen = new XmlGenerator(); try { //xmlr = new XmlTextReader(urltext.Text); xmlr = new XmlTextReader(url); xmlr.WhitespaceHandling = WhitespaceHandling.None; servdesc = System.Web.Services.Description.ServiceDescription.Read(xmlr); schemas = servdesc.Types.Schemas; //Find operation matching the selected row for (int i = 0; i < servdesc.PortTypes.Count && indexOfPort == -1 && indexOfOp == -1; i++) { for (int j = 0; j < servdesc.PortTypes[i].Operations.Count && indexOfPort == -1 && indexOfOp == -1; j++) { if (servdesc.PortTypes[i].Operations[j].Name == stringNodeName) { indexOfOp = j; indexOfPort = i; } } } System.Web.Services.Description.Operation SelectedOp = null; if (indexOfPort != -1 && indexOfOp != -1) { SelectedOp = servdesc.PortTypes[indexOfPort].Operations[indexOfOp]; } else { Logger.Text += " Element not found in selected Operations \r\n"; return(""); } //Get the URL for the particular method int serviceno = -1; int portno = -1; int extno = -1; string urltosend = null; System.Web.Services.Description.Port SelectedPort = null; System.Web.Services.Description.ServiceCollection serviceColl = servdesc.Services; Logger.Text += "\r\nSelected port index: " + portlist.SelectedNode.Index + "\r\n"; bool found = false; for (int i = 0; i < serviceColl.Count && !found; i++) { for (int j = 0; j < serviceColl[i].Ports.Count && !found; j++) { if (serviceColl[i].Ports[j].Name == portlist.SelectedNode.Text) { found = true; serviceno = i; portno = j; } } } if (serviceno != -1 && portno != -1) { SelectedPort = serviceColl[serviceno].Ports[portno]; for (int k = 0; k < SelectedPort.Extensions.Count; k++) { System.Web.Services.Description.Binding basebinding = SelectedPort.Extensions[k] as System.Web.Services.Description.Binding; System.Web.Services.Description.SoapAddressBinding sab = SelectedPort.Extensions[k] as System.Web.Services.Description.SoapAddressBinding; System.Web.Services.Description.Soap12AddressBinding s12ab = SelectedPort.Extensions[k] as System.Web.Services.Description.Soap12AddressBinding; System.Web.Services.Description.HttpAddressBinding hab = SelectedPort.Extensions[k] as System.Web.Services.Description.HttpAddressBinding; if (sab != null) { urltosend = sab.Location; //Logger.Text += urltosend; } else if (s12ab != null) { urltosend = s12ab.Location; //Logger.Text += urltosend; } else { urltosend = hab.Location; //Logger.Text += urltosend; } } int bindingno = -1; int opno = -1; found = false; for (int i = 0; i < servdesc.Bindings.Count && !found; i++) { for (int j = 0; j < servdesc.Bindings[i].Operations.Count && !found; j++) { if (servdesc.Bindings[i].Operations[j].Name == stringNodeName) { bindingno = i; opno = j; found = true; } } } if (bindingno != -1 && opno != -1) { for (int k = 0; k < servdesc.Bindings[bindingno].Operations[opno].Extensions.Count; k++) { System.Web.Services.Description.Binding basebinding = servdesc.Bindings[bindingno].Operations[opno].Extensions[k] as System.Web.Services.Description.Binding; System.Web.Services.Description.SoapOperationBinding sob = servdesc.Bindings[bindingno].Operations[opno].Extensions[k] as System.Web.Services.Description.SoapOperationBinding; System.Web.Services.Description.Soap12OperationBinding s12ob = servdesc.Bindings[bindingno].Operations[opno].Extensions[k] as System.Web.Services.Description.Soap12OperationBinding; System.Web.Services.Description.HttpOperationBinding hob = servdesc.Bindings[bindingno].Operations[opno].Extensions[k] as System.Web.Services.Description.HttpOperationBinding; if (sob != null) { //urltosend += sob.SoapAction; ListViewItem item = new ListViewItem(); item.Text = "SoapAction: \"" + sob.SoapAction + "\""; httpheaderlist.Items.Add(item); for (int index = 0; index < servdesc.Bindings[bindingno].Operations[opno].Input.Extensions.Count; index++) { System.Web.Services.Description.SoapHeaderBinding shb = servdesc.Bindings[bindingno].Operations[opno].Input.Extensions[index] as System.Web.Services.Description.SoapHeaderBinding; if (shb != null) { //SoapHeader is defined //returnval += SchemaSearching(servdesc.Types.Schemas[0], shb.Message.Name); Logger.Text += "Name of header " + shb.Message.Name + "\r\n"; string headerType; //returnval += SchemaSearching(servdesc.Types.Schemas[0], servdesc.Messages[shb.Message.Name].Parts[0].Element.Name); if (servdesc.Messages[shb.Message.Name].Parts[0].Type.IsEmpty) { headerType = servdesc.Messages[shb.Message.Name].Parts[0].Element.Name; headerval += SchemaSearching(servdesc.Types.Schemas[0], headerType); } else { //Currently takes care of only one part in each message if (shb.Message.Name != null) { headerval += '<' + shb.Message.Name + '>'; for (int i = 0; i < servdesc.Messages[shb.Message.Name].Parts.Count; i++) { headerType = servdesc.Messages[shb.Message.Name].Parts[i].Type.Name; headerval += '<' + servdesc.Messages[shb.Message.Name].Parts[i].Name + '>'; headerval += SchemaSearching(servdesc.Types.Schemas[0], headerType); headerval += "</" + servdesc.Messages[shb.Message.Name].Parts[i].Name + ">"; } headerval += "</" + shb.Message.Name + '>'; } } } } break; //Logger.Text += urltosend; } else if (s12ob != null) { ListViewItem item = new ListViewItem(); item.Text = "SoapAction: \"" + sob.SoapAction + "\""; httpheaderlist.Items.Add(item); for (int index = 0; index < servdesc.Bindings[bindingno].Operations[opno].Input.Extensions.Count; index++) { System.Web.Services.Description.Soap12HeaderBinding s12hb = servdesc.Bindings[bindingno].Operations[opno].Input.Extensions[index] as System.Web.Services.Description.Soap12HeaderBinding; if (s12hb != null) { //SoapHeader is defined //returnval += SchemaSearching(servdesc.Types.Schemas[0], shb.Message.Name); Logger.Text += "Name of header " + s12hb.Message.Name + "\r\n"; string headerType; //returnval += SchemaSearching(servdesc.Types.Schemas[0], servdesc.Messages[shb.Message.Name].Parts[0].Element.Name); if (servdesc.Messages[s12hb.Message.Name].Parts[0].Type.IsEmpty) { headerType = servdesc.Messages[s12hb.Message.Name].Parts[0].Element.Name; headerval += SchemaSearching(servdesc.Types.Schemas[0], headerType); } else { //Currently takes care of only one part in each message if (s12hb.Message.Name != null) { headerval += '<' + s12hb.Message.Name + '>'; for (int i = 0; i < servdesc.Messages[s12hb.Message.Name].Parts.Count; i++) { headerType = servdesc.Messages[s12hb.Message.Name].Parts[i].Type.Name; headerval += '<' + servdesc.Messages[s12hb.Message.Name].Parts[i].Name + '>'; headerval += SchemaSearching(servdesc.Types.Schemas[0], headerType); headerval += "</" + servdesc.Messages[s12hb.Message.Name].Parts[i].Name + ">"; } headerval += "</" + s12hb.Message.Name + '>'; } } } } urltosend += s12ob.SoapAction; break; //Logger.Text += urltosend; } else if (hob != null) { urltosend += hob.Location; break; //Logger.Text += urltosend; } } } //Find the right binding Logger.Text += urltosend; Logger.Text += "\r\n"; targeturl.Text = urltosend; } //Path to XML schema definition from Operation Name //portType -> Operation:Name -> input:message // input:message == Message:Name //Message:Name -> Part:element //Types -> Schema -> Element:Name //Part:Element == Element:Name Logger.Text += " searching for " + stringNodeName + "\r\n"; //Logger.Text += " ****** " + SelectedOp.Messages.Count + " ****** "; /*for (int i = 0; i < SelectedOp.PortType.Operations.Count; i++) * { * for (int j = 0; j < SelectedOp.PortType.Operations[i].Messages.Count; j++)// +", "; * { * Logger.Text += SelectedOp.PortType.Operations[i].Messages[j].GetType() + " == "; * Logger.Text += SelectedOp.PortType.Operations[i].Messages[j].Name + "\r\n"; * } * }*/ string inputParameterType = null; string inputMessageType = SelectedOp.Messages.Input.Message.Name; // TODO: What if there are more than one service descriptions? System.Xml.Schema.XmlSchema xmlSchema = servdesc.Types.Schemas[0]; //What if there are more than one Parts if (servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[0].Type.IsEmpty) { inputParameterType = servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[0].Element.Name; returnval += SchemaSearching(xmlSchema, inputParameterType); } else { //Currently takes care of only one part in each message if (SelectedOp.Messages.Input.Message.Name != null) { returnval += '<' + SelectedOp.Messages.Input.Message.Name + '>'; for (int i = 0; i < servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts.Count; i++) { inputParameterType = servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[i].Type.Name; returnval += '<' + servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[i].Name + '>'; returnval += SchemaSearching(xmlSchema, inputParameterType); returnval += "</" + servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[i].Name + ">"; } returnval += "</" + SelectedOp.Messages.Input.Message.Name + '>'; } } Logger.Text += "Selected the method : " + inputMessageType + " that needs " + inputParameterType + " as the param\r\n"; //Logger.Text += servdesc.Messages[SelectedOp.Messages.Input.Message.Name].Parts[0].Type.Name + " as the param\r\n" ; //Logger.Text += "\r\n"; /* * System.Xml.Schema.XmlSchema xmlSchema = servdesc.Types.Schemas[0]; * * foreach (object item in xmlSchema.Items) * { * * System.Xml.Schema.XmlSchemaElement schemaElement = item as System.Xml.Schema.XmlSchemaElement; * //Logger.Text += "Ref name = " + schemaElement.RefName + "\r\n"; * //Logger.Text += " -------- " + item.GetType() + "\r\n"; * if (schemaElement != null) * { * //Logger.Text += "Ref name = " + schemaElement.RefName + "\r\n"; * if (schemaElement.Name == inputParameterType) * { * Logger.Text += "\r\n1. ******************\r\n"; * returnval = xmlGen.GenerateXmlString(schemaElement, xmlSchema); * Logger.Text += returnval+"\r\n"; * Logger.Text += "\r\n******************\r\n";*/ /*Logger.Text += "Schema Element Name : " + schemaElement.Name + "\r\n" ; * System.Xml.Schema.XmlSchemaType schemaType = schemaElement.SchemaType; * Logger.Text += "Type of " + schemaElement.Name + " is " + schemaElement.SchemaTypeName + "\r\n"; * System.Xml.Schema.XmlSchemaComplexType complexType = schemaType as System.Xml.Schema.XmlSchemaComplexType; * if (complexType != null) * { * System.Xml.Schema.XmlSchemaParticle particle = complexType.Particle; * Logger.Text += "Annot : " + particle.Annotation + "\r\n" ; * if (particle != null) * { //TraverseParticle(complexType.Particle); * Logger.Text += '<' + complexType.Name + '>' + xmlGen.GenerateXmlString(complexType.Particle) + "</" + complexType.Name + '>'; * } * } * else * { * //If it's not a Complex Type element * System.Xml.Schema.XmlSchemaSimpleType simpleType = schemaType as System.Xml.Schema.XmlSchemaSimpleType; * //simpleType. * }*//* * } * } * else * { //This is a complex Type * System.Xml.Schema.XmlSchemaComplexType complexType = item as System.Xml.Schema.XmlSchemaComplexType; * if (complexType != null) * { * //Logger.Text += "Name : " + complexType.Name + "\r\n" ; * if (complexType.Name == inputParameterType) * { * Logger.Text += "Complex Type Name : " + complexType.Name + "\r\n"; * System.Xml.Schema.XmlSchemaParticle particle = complexType.Particle; * System.Xml.Schema.XmlSchemaSequence sequence = particle as System.Xml.Schema.XmlSchemaSequence; * System.Xml.Schema.XmlSchemaAll schemaall = particle as System.Xml.Schema.XmlSchemaAll; * if (sequence != null) * { * foreach (System.Xml.Schema.XmlSchemaElement childElement in sequence.Items) * { * string parameterName = childElement.Name; * string parameterType = childElement.SchemaTypeName.Name; * Logger.Text += parameterName + " is a " + parameterType; * Logger.Text += "\r\n2. ************************************\r\n"; * returnval = '<' + complexType.Name + '>' + xmlGen.GenerateXmlString(childElement, xmlSchema) + "</" + complexType.Name + '>'; * Logger.Text += returnval; * Logger.Text += "\r\n************************************\r\n"; * } * } * else * { * if (schemaall != null) * { * Logger.Text += "\r\n3. ************************************\r\n"; * returnval = '<' + complexType.Name + '>' + xmlGen.GenerateXmlString(schemaall, xmlSchema) + "</" + complexType.Name + '>'; * Logger.Text += returnval; * Logger.Text += "\r\n************************************\r\n"; * //TraverseParticle(schemaall); * } * else * { * System.Xml.Schema.XmlSchemaComplexContent cmplxContent = null; * * if (cmplxContent != null) * { * Logger.Text += cmplxContent.GetType(); * Logger.Text += "\r\n4. ************************************\r\n"; * returnval = '<' + complexType.Name + '>' + xmlGen.GenerateXmlString(cmplxContent, xmlSchema) + "</" + complexType.Name + '>'; ; * Logger.Text += returnval; * Logger.Text += "\r\n************************************\r\n"; * } * } * } * } * } * else * { * System.Xml.Schema.XmlSchemaSimpleType simpleType = item as System.Xml.Schema.XmlSchemaSimpleType; * * } * } * }*/ returnval = Encapsulate("xmlns=\"" + servdesc.TargetNamespace + "\"", headerval, returnval); return(returnval); /* * for (int k = 0; k < schemas.Count; k++) * { * XmlSchemaObjectCollection xmlelem = schemas[k].Items; * XmlSchemaObjectEnumerator enumerator = xmlelem.GetEnumerator(); * while (enumerator.MoveNext()) * { * Logger.Text += " Type of " +enumerator.Current.GetType() + "\r\n" ; * * if (enumerator.Current is XmlSchemaElement) * { * XmlSchemaElement xse = (XmlSchemaElement)enumerator.Current; * Logger.Text += xse.Name + '=' + xse.SchemaType + ", "; * //if * TraverseParticle(xse); * } * else * { * if (enumerator.Current is XmlSchemaComplexType) * { * XmlSchemaComplexType xsct = (XmlSchemaComplexType)enumerator.Current; * Logger.Text += '\'' + xsct.Name + ": "; * TraverseParticle(xsct.Particle); * if (xsct.ContentModel is XmlSchemaSimpleContent) * { * Logger.Text += "Simple; "; * } * else * { * //XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)xsct.ContentModel; * if (xsct.ContentModel is XmlSchemaComplexContent) * { * Logger.Text += "Complex; "; * } * } * Logger.Text += "\',"; * } * } * } * Logger.Text += "\r\n"; * }*/ //Path to URL from Operation Name // Operation ^ Binding:Name //Service -> Port:Binding // Binding:Name == Port:Binding // Port:Name -> (Soapaddressbinding/HttpAddressBinding/Soap12AddressBinding).Location } catch (XmlException xe) { Logger.Text += xe.ToString(); } returnval = Encapsulate("xmlns=\"" + servdesc.TargetNamespace + "\"", headerval, returnval); return(returnval); }
private string GenerateSOAP() { XmlTextReader xmlr = null; try { xmlr = new XmlTextReader(urltext.Text); } catch (XmlException xe) { Logger.Text += xe.ToString(); } System.Web.Services.Description.ServiceDescription servdesc = null; servdesc = System.Web.Services.Description.ServiceDescription.Read(xmlr); System.Web.Services.Description.ServiceCollection serviceColl = servdesc.Services; string returnurl = null; Logger.Text += "\r\n **** Service(s) Found : " + serviceColl.Count + " ****\r\n"; //string returnurl = null; //How to select from more than one WSDL Ports??? TreeNode root = null; TreeNode porttn = null; for (int i = 0; i < serviceColl.Count; i++) { //Logger.Text += "For service : " + serviceColl[i].Name + " " + serviceColl[i].Ports.Count + " port(s) discovered: --> "; root = new TreeNode(serviceColl[i].Name); portlist.Nodes.Add(root); for (int j = 0; j < serviceColl[i].Ports.Count; j++) { //Logger.Text += serviceColl[i].Ports[j].Name + ", "; //if (serviceColl[i].Ports[j].Name == stringNodeName) //{ //int j = 0; // temp //serviceno = i; //portno = j; //} porttn = new TreeNode(serviceColl[i].Ports[j].Name); root.Nodes.Add(porttn); } } portlist.SelectedNode = portlist.Nodes[0]; for (int i = 0; i < serviceColl.Count; i++) { Logger.Text += "For service : " + serviceColl[i].Name + " " + serviceColl[i].Ports.Count + " port(s) discovered: --> "; for (int j = 0; j < serviceColl[i].Ports.Count; j++) { Logger.Text += serviceColl[i].Ports[j].Name + ", "; for (int k = 0; k < serviceColl[i].Ports[j].Extensions.Count; k++) { System.Web.Services.Description.Binding basebinding = serviceColl[i].Ports[j].Extensions[k] as System.Web.Services.Description.Binding; System.Web.Services.Description.SoapAddressBinding sab = serviceColl[i].Ports[j].Extensions[k] as System.Web.Services.Description.SoapAddressBinding; System.Web.Services.Description.Soap12AddressBinding s12ab = serviceColl[i].Ports[j].Extensions[k] as System.Web.Services.Description.Soap12AddressBinding; System.Web.Services.Description.HttpAddressBinding hab = serviceColl[i].Ports[j].Extensions[k] as System.Web.Services.Description.HttpAddressBinding; if (sab != null) { returnurl = sab.Location; Logger.Text += returnurl; targeturl.Text = returnurl; } else if (s12ab != null) { returnurl = s12ab.Location; Logger.Text += returnurl; targeturl.Text = returnurl; } else { returnurl = hab.Location; Logger.Text += returnurl; targeturl.Text = returnurl; } } } Logger.Text += "\r\n"; } return(returnurl); }
private void MoveToBinding(System.Web.Services.Description.Binding binding, System.Web.Services.Description.PortType portType) { this.MoveToBinding(null, null, binding, portType); }
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); }
public System.Web.Services.Description.Binding ReadObject_Binding (bool isNullable, bool checkType) { System.Web.Services.Description.Binding ob = null; if (isNullable && ReadNull()) return null; if (checkType) { System.Xml.XmlQualifiedName t = GetXsiType(); if (t != null) { if (t.Name != "Binding" || t.Namespace != "http://schemas.xmlsoap.org/wsdl/") throw CreateUnknownTypeException(t); } } ob = new System.Web.Services.Description.Binding (); Reader.MoveToElement(); while (Reader.MoveToNextAttribute()) { if (Reader.LocalName == "name" && Reader.NamespaceURI == "") { ob.Name = XmlConvert.DecodeName(Reader.Value); } else if (Reader.LocalName == "type" && Reader.NamespaceURI == "") { ob.Type = ToXmlQualifiedName (Reader.Value); } else if (IsXmlnsAttribute (Reader.Name)) { } else { UnknownNode (ob); } } Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); return ob; } Reader.ReadStartElement(); Reader.MoveToContent(); bool b17=false, b18=false; System.Web.Services.Description.OperationBindingCollection o20 = ob.Operations; int n19=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/" && !b17) { if (o20 == null) throw CreateReadOnlyCollectionException ("System.Web.Services.Description.OperationBindingCollection"); o20.Add (ReadObject_OperationBinding (false, true)); n19++; } else if (Reader.LocalName == "documentation" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b18) { b18 = true; ob.Documentation = Reader.ReadElementString (); } else { ServiceDescription.ReadExtension (Reader, ob); } } else UnknownNode(ob); Reader.MoveToContent(); } ReadEndElement(); return ob; }
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(); }