internal override bool ReflectReturn() { MessagePart part = new MessagePart(); part.Name = "Body"; ReflectionContext.OutputMessage.Parts.Add(part); if (typeof(XmlNode).IsAssignableFrom(ReflectionContext.Method.ReturnType)) { MimeContentBinding mimeContentBinding = new MimeContentBinding(); mimeContentBinding.Type = "text/xml"; mimeContentBinding.Part = part.Name; ReflectionContext.OperationBinding.Output.Extensions.Add(mimeContentBinding); } else { MimeXmlBinding mimeXmlBinding = new MimeXmlBinding(); mimeXmlBinding.Part = part.Name; LogicalMethodInfo methodInfo = ReflectionContext.Method; XmlAttributes a = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = ReflectionContext.ReflectionImporter.ImportTypeMapping(methodInfo.ReturnType, a.XmlRoot); xmlTypeMapping.SetKey(methodInfo.GetKey() + ":Return"); ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); part.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); ReflectionContext.OperationBinding.Output.Extensions.Add(mimeXmlBinding); } return true; }
internal override bool ReflectReturn() { MessagePart part = new MessagePart(); part.Name = "Body"; ReflectionContext.OutputMessage.Parts.Add(part); if (typeof(XmlNode).IsAssignableFrom(ReflectionContext.Method.ReturnType)) { MimeContentBinding mimeContentBinding = new MimeContentBinding(); mimeContentBinding.Type = "text/xml"; mimeContentBinding.Part = part.Name; ReflectionContext.OperationBinding.Output.Extensions.Add(mimeContentBinding); } else { MimeXmlBinding mimeXmlBinding = new MimeXmlBinding(); mimeXmlBinding.Part = part.Name; LogicalMethodInfo methodInfo = ReflectionContext.Method; XmlAttributes a = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = ReflectionContext.ReflectionImporter.ImportTypeMapping(methodInfo.ReturnType, a.XmlRoot); xmlTypeMapping.SetKey(methodInfo.GetKey() + ":Return"); ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); part.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); ReflectionContext.OperationBinding.Output.Extensions.Add(mimeXmlBinding); } return(true); }
internal override bool ReflectReturn() { MessagePart messagePart = new MessagePart { Name = "Body" }; base.ReflectionContext.OutputMessage.Parts.Add(messagePart); if (typeof(XmlNode).IsAssignableFrom(base.ReflectionContext.Method.ReturnType)) { MimeContentBinding extension = new MimeContentBinding { Type = "text/xml", Part = messagePart.Name }; base.ReflectionContext.OperationBinding.Output.Extensions.Add(extension); } else { MimeXmlBinding binding2 = new MimeXmlBinding { Part = messagePart.Name }; LogicalMethodInfo method = base.ReflectionContext.Method; XmlAttributes attributes = new XmlAttributes(method.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = base.ReflectionContext.ReflectionImporter.ImportTypeMapping(method.ReturnType, attributes.XmlRoot); xmlTypeMapping.SetKey(method.GetKey() + ":Return"); base.ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); messagePart.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); base.ReflectionContext.OperationBinding.Output.Extensions.Add(binding2); } return(true); }
internal override bool ReflectReturn() { MessagePart messagePart = new MessagePart { Name = "Body" }; base.ReflectionContext.OutputMessage.Parts.Add(messagePart); if (typeof(XmlNode).IsAssignableFrom(base.ReflectionContext.Method.ReturnType)) { MimeContentBinding extension = new MimeContentBinding { Type = "text/xml", Part = messagePart.Name }; base.ReflectionContext.OperationBinding.Output.Extensions.Add(extension); } else { MimeXmlBinding binding2 = new MimeXmlBinding { Part = messagePart.Name }; LogicalMethodInfo method = base.ReflectionContext.Method; XmlAttributes attributes = new XmlAttributes(method.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = base.ReflectionContext.ReflectionImporter.ImportTypeMapping(method.ReturnType, attributes.XmlRoot); xmlTypeMapping.SetKey(method.GetKey() + ":Return"); base.ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); messagePart.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); base.ReflectionContext.OperationBinding.Output.Extensions.Add(binding2); } return true; }
internal override MimeReturn ImportReturn() { MimeContentBinding mimeContentBinding = (MimeContentBinding)ImportContext.OperationBinding.Output.Extensions.Find(typeof(MimeContentBinding)); if (mimeContentBinding != null) { if (!ContentType.MatchesBase(mimeContentBinding.Type, ContentType.TextXml)) { return(null); } MimeReturn importedReturn = new MimeReturn(); importedReturn.TypeName = typeof(XmlElement).FullName; importedReturn.ReaderType = typeof(XmlReturnReader); return(importedReturn); } MimeXmlBinding mimeXmlBinding = (MimeXmlBinding)ImportContext.OperationBinding.Output.Extensions.Find(typeof(MimeXmlBinding)); if (mimeXmlBinding != null) { MimeXmlReturn importedReturn = new MimeXmlReturn(); MessagePart part; switch (ImportContext.OutputMessage.Parts.Count) { case 0: throw new InvalidOperationException(Res.GetString(Res.MessageHasNoParts1, ImportContext.InputMessage.Name)); case 1: if (mimeXmlBinding.Part == null || mimeXmlBinding.Part.Length == 0) { part = ImportContext.OutputMessage.Parts[0]; } else { part = ImportContext.OutputMessage.FindPartByName(mimeXmlBinding.Part); } break; default: part = ImportContext.OutputMessage.FindPartByName(mimeXmlBinding.Part); break; } importedReturn.TypeMapping = Importer.ImportTypeMapping(part.Element); importedReturn.TypeName = importedReturn.TypeMapping.TypeFullName; importedReturn.ReaderType = typeof(XmlReturnReader); Exporter.AddMappingMetadata(importedReturn.Attributes, importedReturn.TypeMapping, string.Empty); return(importedReturn); } return(null); }
internal override MimeReturn ImportReturn() { MessagePart part; MimeContentBinding binding = (MimeContentBinding)base.ImportContext.OperationBinding.Output.Extensions.Find(typeof(MimeContentBinding)); if (binding != null) { if (!ContentType.MatchesBase(binding.Type, "text/xml")) { return(null); } return(new MimeReturn { TypeName = typeof(XmlElement).FullName, ReaderType = typeof(XmlReturnReader) }); } MimeXmlBinding binding2 = (MimeXmlBinding)base.ImportContext.OperationBinding.Output.Extensions.Find(typeof(MimeXmlBinding)); if (binding2 == null) { return(null); } MimeXmlReturn return3 = new MimeXmlReturn(); switch (base.ImportContext.OutputMessage.Parts.Count) { case 0: throw new InvalidOperationException(System.Web.Services.Res.GetString("MessageHasNoParts1", new object[] { base.ImportContext.InputMessage.Name })); case 1: if ((binding2.Part != null) && (binding2.Part.Length != 0)) { part = base.ImportContext.OutputMessage.FindPartByName(binding2.Part); break; } part = base.ImportContext.OutputMessage.Parts[0]; break; default: part = base.ImportContext.OutputMessage.FindPartByName(binding2.Part); break; } return3.TypeMapping = this.Importer.ImportTypeMapping(part.Element); return3.TypeName = return3.TypeMapping.TypeFullName; return3.ReaderType = typeof(XmlReturnReader); this.Exporter.AddMappingMetadata(return3.Attributes, return3.TypeMapping, string.Empty); return(return3); }
protected override bool ReflectMethod() { LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo(ServiceType); HttpOperationBinding sob = new HttpOperationBinding(); sob.Location = "/" + MethodStubInfo.Name; OperationBinding.Extensions.Add(sob); if (!Method.IsVoid) { MimeXmlBinding mxb = new MimeXmlBinding(); mxb.Part = "Body"; OperationBinding.Output.Extensions.Add(mxb); MessagePart part = new MessagePart(); part.Name = "Body"; XmlTypeMapping map = ReflectionImporter.ImportTypeMapping(Method.ReturnType, ti.GetWebServiceLiteralNamespace(ServiceDescription.TargetNamespace)); XmlQualifiedName qname = new XmlQualifiedName(map.ElementName, map.Namespace); part.Element = qname; OutputMessage.Parts.Add(part); SchemaExporter.ExportTypeMapping(map); } XmlReflectionMember[] mems = new XmlReflectionMember [Method.Parameters.Length]; for (int n = 0; n < Method.Parameters.Length; n++) { ParameterInfo param = Method.Parameters [n]; XmlReflectionMember mem = new XmlReflectionMember(); mem.MemberName = param.Name; Type ptype = param.ParameterType; if (ptype.IsByRef) { ptype = ptype.GetElementType(); } mem.MemberType = ptype; mems [n] = mem; } XmlMembersMapping memap = ReflectionImporter.ImportMembersMapping("", ti.WebServiceAbstractNamespace, mems, false); bool allPrimitives = true; for (int n = 0; n < memap.Count; n++) { XmlMemberMapping mem = memap[n]; MessagePart part = new MessagePart(); XmlQualifiedName pqname; if (mem.TypeNamespace == "") { pqname = new XmlQualifiedName(mem.TypeName, XmlSchema.Namespace); } else { pqname = new XmlQualifiedName(mem.TypeName, mem.TypeNamespace); allPrimitives = false; } part.Type = pqname; part.Name = mem.ElementName; InputMessage.Parts.Add(part); } if (!allPrimitives) { SoapSchemaExporter.ExportMembersMapping(memap); } return(true); }
private void Write94_MimeXmlBinding(string n, string ns, MimeXmlBinding o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } } else { if (!needType && !(o.GetType() == typeof(MimeXmlBinding))) { throw base.CreateUnknownTypeException(o); } base.WriteStartElement(n, ns, o, false, null); if (needType) { base.WriteXsiType("MimeXmlBinding", "http://schemas.xmlsoap.org/wsdl/mime/"); } if (o.Required) { base.WriteAttribute("required", "http://schemas.xmlsoap.org/wsdl/", XmlConvert.ToString(o.Required)); } base.WriteAttribute("part", "", o.Part); base.WriteEndElement(o); } }
protected override bool ReflectMethod () { LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo (ServiceType); HttpOperationBinding sob = new HttpOperationBinding(); sob.Location = "/" + MethodStubInfo.Name; OperationBinding.Extensions.Add (sob); if (!Method.IsVoid) { MimeXmlBinding mxb = new MimeXmlBinding (); mxb.Part = "Body"; OperationBinding.Output.Extensions.Add (mxb); MessagePart part = new MessagePart (); part.Name = "Body"; XmlTypeMapping map = ReflectionImporter.ImportTypeMapping (Method.ReturnType, ti.GetWebServiceLiteralNamespace (ServiceDescription.TargetNamespace)); XmlQualifiedName qname = new XmlQualifiedName (map.ElementName, map.Namespace); part.Element = qname; OutputMessage.Parts.Add (part); SchemaExporter.ExportTypeMapping (map); } XmlReflectionMember[] mems = new XmlReflectionMember [Method.Parameters.Length]; for (int n=0; n<Method.Parameters.Length; n++) { ParameterInfo param = Method.Parameters [n]; XmlReflectionMember mem = new XmlReflectionMember (); mem.MemberName = param.Name; Type ptype = param.ParameterType; if (ptype.IsByRef) ptype = ptype.GetElementType (); mem.MemberType = ptype; mems [n] = mem; } XmlMembersMapping memap = ReflectionImporter.ImportMembersMapping ("", ti.WebServiceAbstractNamespace, mems, false); bool allPrimitives = true; for (int n=0; n<memap.Count; n++) { XmlMemberMapping mem = memap[n]; MessagePart part = new MessagePart (); XmlQualifiedName pqname; if (mem.TypeNamespace == "") pqname = new XmlQualifiedName (mem.TypeName, XmlSchema.Namespace); else { pqname = new XmlQualifiedName (mem.TypeName, mem.TypeNamespace); allPrimitives = false; } part.Type = pqname; part.Name = mem.ElementName; InputMessage.Parts.Add (part); } if (!allPrimitives) SoapSchemaExporter.ExportMembersMapping (memap); return true; }