private void CreateEncodedMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped)
 {
     this.SoapExporter.ExportMembersMapping(members, wrapped);
     if (wrapped)
     {
         MessagePart messagePart = new MessagePart {
             Name = "parameters",
             Type = new XmlQualifiedName(members.TypeName, members.TypeNamespace)
         };
         message.Parts.Add(messagePart);
     }
     else
     {
         for (int i = 0; i < members.Count; i++)
         {
             XmlMemberMapping mapping = members[i];
             MessagePart part2 = new MessagePart {
                 Name = mapping.XsdElementName,
                 Type = new XmlQualifiedName(mapping.TypeName, mapping.TypeNamespace)
             };
             message.Parts.Add(part2);
         }
     }
     messageBinding.Extensions.Add(this.CreateSoapBodyBinding(SoapBindingUse.Encoded, members.Namespace));
 }
 protected static MessagePart AddMessagePart(Message message, string partName, XmlQualifiedName elementName, XmlQualifiedName typeName)
 {
     if (message.Parts[partName] != null)
     {
         if (IsNullOrEmpty(elementName))
         {
             throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("SFxPartNameMustBeUniqueInRpc", new object[] { partName })));
         }
         int num = 1;
         while (message.Parts[partName + num] != null)
         {
             if (num == 0x7fffffff)
             {
                 throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("SFxTooManyPartsWithSameName", new object[] { partName })));
             }
             num++;
         }
         partName = partName + num.ToString(CultureInfo.InvariantCulture);
     }
     MessagePart messagePart = new MessagePart {
         Name = partName,
         Element = elementName,
         Type = typeName
     };
     message.Parts.Add(messagePart);
     EnsureXsdImport(IsNullOrEmpty(elementName) ? typeName.Namespace : elementName.Namespace, message.ServiceDescription);
     return messagePart;
 }
コード例 #3
0
        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;
 }
コード例 #5
0
		public override void Check (ConformanceCheckContext ctx, MessagePart value)
		{
			CheckWsdlQName (ctx, value, value.Type);
			CheckWsdlQName (ctx, value, value.Element);
			
			if (value.DefinedByElement && value.Element.Namespace == XmlSchema.Namespace)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2206);
		}
コード例 #6
0
 public MessagePart[] FindPartsByName(string[] partNames)
 {
     MessagePart[] partArray = new MessagePart[partNames.Length];
     for (int i = 0; i < partNames.Length; i++)
     {
         partArray[i] = this.FindPartByName(partNames[i]);
     }
     return partArray;
 }
コード例 #7
0
 internal static bool Check(MessagePart part, Message message, WsdlWarningHandler warningHandler)
 {
     if (string.IsNullOrEmpty(part.Name))
     {
         string str = System.ServiceModel.SR.GetString("XsdMissingRequiredAttribute1", new object[] { "name" });
         string warning = System.ServiceModel.SR.GetString("IgnoreMessagePart3", new object[] { message.Name, message.ServiceDescription.TargetNamespace, str });
         warningHandler(warning);
         return false;
     }
     return true;
 }
コード例 #8
0
        internal void ReflectStringParametersMessage() {
            Message inputMessage = InputMessage;
            foreach (ParameterInfo parameterInfo in Method.InParameters) {
                MessagePart part = new MessagePart();
                part.Name = XmlConvert.EncodeLocalName(parameterInfo.Name);
                if (parameterInfo.ParameterType.IsArray) {
                    string typeNs = DefaultNamespace;
                    if (typeNs.EndsWith("/", StringComparison.Ordinal))
                        typeNs += "AbstractTypes";
                    else
                        typeNs += "/AbstractTypes";
                    string typeName = "StringArray";
                    if (!ServiceDescription.Types.Schemas.Contains(typeNs)) {
                        XmlSchema schema = new XmlSchema();
                        schema.TargetNamespace = typeNs;
                        ServiceDescription.Types.Schemas.Add(schema);
                       
                        XmlSchemaElement element = new XmlSchemaElement();
                        element.Name = "String";
                        element.SchemaTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
                        element.MinOccurs = decimal.Zero;
                        element.MaxOccurs = decimal.MaxValue;
                        XmlSchemaSequence all = new XmlSchemaSequence();
                        all.Items.Add(element);

                        XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
                        restriction.BaseTypeName = new XmlQualifiedName(Soap.ArrayType, Soap.Encoding);
                        restriction.Particle = all;

                        XmlSchemaImport import = new XmlSchemaImport();
                        import.Namespace = restriction.BaseTypeName.Namespace;
                        
                        XmlSchemaComplexContent model = new XmlSchemaComplexContent();
                        model.Content = restriction;

                        XmlSchemaComplexType type = new XmlSchemaComplexType();
                        type.Name = typeName;
                        type.ContentModel = model;

                        schema.Items.Add(type);
                        schema.Includes.Add(import);
                    }
                    part.Type = new XmlQualifiedName(typeName, typeNs);
                }
                else {
                    part.Type = new XmlQualifiedName("string", XmlSchema.Namespace);
                }
                inputMessage.Parts.Add(part);
            }
        }
コード例 #9
0
 void CreateLiteralMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped, bool rpc) {
     if (members.Count == 1 && members[0].Any && members[0].ElementName.Length == 0 && !wrapped) {
         string typeName = SchemaExporter.ExportAnyType(members[0].Namespace);
         MessagePart part = new MessagePart();
         part.Name = members[0].MemberName;
         part.Type = new XmlQualifiedName(typeName, members[0].Namespace);
         message.Parts.Add(part);
     }
     else {
         SchemaExporter.ExportMembersMapping(members, !rpc);
         if (wrapped) {
             MessagePart part = new MessagePart();
             part.Name = "parameters";
             part.Element = new XmlQualifiedName(members.XsdElementName, members.Namespace);
             message.Parts.Add(part);
         }
         else {
             for (int i = 0; i < members.Count; i++) {
                 XmlMemberMapping member = members[i];
                 MessagePart part = new MessagePart();
                 if (rpc) {
                     // Generate massage part with the type attribute
                     if (member.TypeName == null || member.TypeName.Length == 0) {
                         throw new InvalidOperationException(Res.GetString(Res.WsdlGenRpcLitAnonimousType, Method.DeclaringType.Name, Method.Name, member.MemberName));
                     }
                     part.Name = member.XsdElementName;
                     part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace);
                 }
                 else {
                     part.Name = XmlConvert.EncodeLocalName(member.MemberName);
                     part.Element = new XmlQualifiedName(member.XsdElementName, member.Namespace);
                 }
                 message.Parts.Add(part);
             }
         }
     }
     messageBinding.Extensions.Add(CreateSoapBodyBinding(SoapBindingUse.Literal, rpc ? members.Namespace : null));
 }
コード例 #10
0
		void ImportMessageParts ()
		{
			SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
			ImportMessage (method.InputMembersMapping, InputMessage);
			ImportMessage (method.OutputMembersMapping, OutputMessage);
				

			foreach (SoapHeaderMapping hf in method.Headers)
			{
				if (hf.Custom) continue;
				
				Message msg = new Message ();
				msg.Name = Operation.Name + hf.HeaderType.Name;
				MessagePart part = new MessagePart ();
				part.Name = hf.HeaderType.Name;
				msg.Parts.Add (part);
				ServiceDescription.Messages.Add (msg);

				if (method.Use == SoapBindingUse.Literal)
				{
					// MS.NET reflects header classes in a weird way. The root element
					// name is the CLR class name unless it is specified in an XmlRootAttribute.
					// The usual is to use the xml type name by default, but not in this case.
				
					XmlRootAttribute root;
					XmlAttributes ats = new XmlAttributes (hf.HeaderType);
					if (ats.XmlRoot != null) root = ats.XmlRoot;
					else root = new XmlRootAttribute (hf.HeaderType.Name);
					
					if (root.Namespace == null) root.Namespace = TypeInfo.LogicalType.GetWebServiceLiteralNamespace (ServiceDescription.TargetNamespace);
					if (root.ElementName == null) root.ElementName = hf.HeaderType.Name;
					
					XmlTypeMapping mapping = ReflectionImporter.ImportTypeMapping (hf.HeaderType, root);
					part.Element = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
					SchemaExporter.ExportTypeMapping (mapping);
				}
				else
				{
					XmlTypeMapping mapping = SoapReflectionImporter.ImportTypeMapping (hf.HeaderType, TypeInfo.LogicalType.GetWebServiceEncodedNamespace (ServiceDescription.TargetNamespace));
					part.Type = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
					SoapSchemaExporter.ExportTypeMapping (mapping);
				}
			}
		}
コード例 #11
0
        /// <summary>
        /// Used to determine if document/literal type is wrapped
        /// </summary>
        /// <param name="messagePart">A message part to check for wrapped style.</param>
        /// <returns>True if the first message parts name is "parameter".</returns>
        /// <remarks>
        /// Wrapped is only valid for document/literal since rpc/literal is always wrapped. Wrapped means a message
        /// must contain a single part that points to a complex element that contains the soap/body content.
        /// The name "parameter" used to identify wrapped type is defined by Microsoft but used by other. This will
        /// have to do until WS-I defines somethinf different.
        /// </remarks>
        internal static bool IsWrapped(MessagePart messagePart)
        {
            // If theres no messages this cant be wrapped
            if (messagePart == null)
                return false;

            return messagePart.Name == "parameters" ? true : false;
        }
コード例 #12
0
		protected override void ImportPartsBySchemaElement (QName qname, List<MessagePartDescription> parts, Message msg, MessagePart msgPart)
		{
			if (schema_set_cache != schema_set_in_use) {
				schema_set_cache = schema_set_in_use;
				var xss = new XmlSchemas ();
				foreach (XmlSchema xs in schema_set_cache.Schemas ())
					xss.Add (xs);
				schema_importer = new XmlSchemaImporter (xss);
				if (ccu.Namespaces.Count == 0)
					ccu.Namespaces.Add (new CodeNamespace ());
				var cns = ccu.Namespaces [0];
				code_exporter = new XmlCodeExporter (cns, ccu);
			}

			var part = new MessagePartDescription (qname.Name, qname.Namespace);
			part.XmlSerializationImporter = this;
			var mbrNS = msg.ServiceDescription.TargetNamespace;
			var xmm = schema_importer.ImportMembersMapping (qname);
			code_exporter.ExportMembersMapping (xmm);
			// FIXME: use of ElementName is a hack!
			part.CodeTypeReference = new CodeTypeReference (xmm.ElementName);
			parts.Add (part);
		}
コード例 #13
0
 public void Remove(MessagePart messagePart)
 {
     base.List.Remove(messagePart);
 }
コード例 #14
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.Contains"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public bool Contains(MessagePart messagePart) {
     return List.Contains(messagePart);
 }
コード例 #15
0
 public bool Contains(MessagePart messagePart)
 {
     return(base.List.Contains(messagePart));
 }
コード例 #16
0
 private MimeParameter ImportUrlParameter(MessagePart part)
 {
     return(new MimeParameter {
         Name = CodeIdentifier.MakeValid(XmlConvert.DecodeName(part.Name)), TypeName = this.IsRepeatingParameter(part) ? typeof(string[]).FullName : typeof(string).FullName
     });
 }
コード例 #17
0
ファイル: BasicProfileChecker.cs プロジェクト: raj581/Marvin
        void CheckMessageBinding(ConformanceCheckContext ctx, Hashtable portParts, MessageBinding value)
        {
            SoapBodyBinding sbb = (SoapBodyBinding)value.Extensions.Find(typeof(SoapBodyBinding));
            Message         msg = FindMessage(ctx, value);
            LiteralType     bt  = GetLiteralBindingType(value.OperationBinding.Binding);

            if (sbb != null)
            {
                if (bt == LiteralType.Document)
                {
                    if (sbb.Parts != null && sbb.Parts.Length > 1)
                    {
                        ctx.ReportRuleViolation(value, BasicProfileRules.R2201);
                    }

                    if (sbb.Parts == null)
                    {
                        if (msg.Parts != null && msg.Parts.Count > 1)
                        {
                            ctx.ReportRuleViolation(value, BasicProfileRules.R2210);
                        }
                        if (msg.Parts.Count == 1)
                        {
                            portParts.Remove(msg.Parts[0]);
                        }
                    }
                    else
                    {
                        if (sbb.Parts.Length == 0 && msg.Parts.Count == 1)
                        {
                            portParts.Remove(msg.Parts[0]);
                        }
                        else
                        {
                            foreach (string part in sbb.Parts)
                            {
                                MessagePart mp = msg.FindPartByName(part);
                                portParts.Remove(mp);
                                if (!mp.DefinedByElement)
                                {
                                    ctx.ReportRuleViolation(value, BasicProfileRules.R2204);
                                }
                            }
                        }
                    }
                }
                else if (bt == LiteralType.Rpc)
                {
                    if (sbb.Parts != null)
                    {
                        foreach (string part in sbb.Parts)
                        {
                            MessagePart mp = msg.FindPartByName(part);
                            portParts.Remove(mp);
                            if (!mp.DefinedByType)
                            {
                                ctx.ReportRuleViolation(value, BasicProfileRules.R2203);
                            }
                        }
                    }
                }
            }

            SoapHeaderBinding shb = (SoapHeaderBinding)value.Extensions.Find(typeof(SoapHeaderBinding));

            if (shb != null)
            {
                Message     hm = ctx.Services.GetMessage(shb.Message);
                MessagePart mp = hm.FindPartByName(shb.Part);
                portParts.Remove(mp);
                if (mp != null && !mp.DefinedByElement)
                {
                    ctx.ReportRuleViolation(value, BasicProfileRules.R2205);
                }
            }

            SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding)value.Extensions.Find(typeof(SoapHeaderFaultBinding));

            if (shfb != null)
            {
                Message     hm = ctx.Services.GetMessage(shfb.Message);
                MessagePart mp = hm.FindPartByName(shfb.Part);
                portParts.Remove(mp);
                if (mp != null && !mp.DefinedByElement)
                {
                    ctx.ReportRuleViolation(value, BasicProfileRules.R2205);
                }
            }

            // TODO: SoapFaultBinding ??
        }
コード例 #18
0
 public virtual void Check(ConformanceCheckContext ctx, MessagePart value)
 {
 }
コード例 #19
0
 public int IndexOf(MessagePart messagePart)
 {
     return(base.List.IndexOf(messagePart));
 }
コード例 #20
0
        void CreateHeaderMessages(string methodName, SoapBindingUse use, XmlMembersMapping inHeaderMappings, XmlMembersMapping outHeaderMappings, SoapReflectedHeader[] headers, bool rpc)
        {
            //
            if (use == SoapBindingUse.Encoded)
            {
                SoapExporter.ExportMembersMapping(inHeaderMappings, false);
                if (outHeaderMappings != null)
                {
                    SoapExporter.ExportMembersMapping(outHeaderMappings, false);
                }
            }
            else
            {
                SchemaExporter.ExportMembersMapping(inHeaderMappings);
                if (outHeaderMappings != null)
                {
                    SchemaExporter.ExportMembersMapping(outHeaderMappings);
                }
            }

            CodeIdentifiers identifiers = new CodeIdentifiers();
            int             inCount = 0, outCount = 0;

            for (int i = 0; i < headers.Length; i++)
            {
                SoapReflectedHeader soapHeader = headers[i];
                if (!soapHeader.custom)
                {
                    continue;
                }

                XmlMemberMapping member;
                if ((soapHeader.direction & SoapHeaderDirection.In) != 0)
                {
                    member = inHeaderMappings[inCount++];
                    if (soapHeader.direction != SoapHeaderDirection.In)
                    {
                        outCount++;
                    }
                }
                else
                {
                    member = outHeaderMappings[outCount++];
                }

                MessagePart part = new MessagePart();
                part.Name = member.XsdElementName;
                if (use == SoapBindingUse.Encoded)
                {
                    part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace);
                }
                else
                {
                    part.Element = new XmlQualifiedName(member.XsdElementName, member.Namespace);
                }
                Message message = new Message();
                message.Name = identifiers.AddUnique(methodName + part.Name, message);
                message.Parts.Add(part);
                HeaderMessages.Add(message);

                ServiceDescriptionFormatExtension soapHeaderBinding = CreateSoapHeaderBinding(new XmlQualifiedName(message.Name, Binding.ServiceDescription.TargetNamespace), part.Name, rpc ? member.Namespace : null, use);

                if ((soapHeader.direction & SoapHeaderDirection.In) != 0)
                {
                    OperationBinding.Input.Extensions.Add(soapHeaderBinding);
                }
                if ((soapHeader.direction & SoapHeaderDirection.Out) != 0)
                {
                    OperationBinding.Output.Extensions.Add(soapHeaderBinding);
                }

                if ((soapHeader.direction & SoapHeaderDirection.Fault) != 0)
                {
                    if (soapMethod.IsClaimsConformance)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.BPConformanceHeaderFault, soapMethod.methodInfo.ToString(), soapMethod.methodInfo.DeclaringType.FullName, "Direction", typeof(SoapHeaderDirection).Name, SoapHeaderDirection.Fault.ToString()));
                    }
                    OperationBinding.Output.Extensions.Add(soapHeaderBinding);
                }
            }
        }
コード例 #21
0
ファイル: Message.cs プロジェクト: Profit0004/mono
		public MessagePart[] FindPartsByName (string[] partNames) 
		{
			ArrayList searchResults = new ArrayList ();

			foreach (string partName in partNames)
				searchResults.Add (FindPartByName (partName));

			int count = searchResults.Count;

			if (count == 0)
				throw new ArgumentException ();

			MessagePart[] returnValue = new MessagePart[count];
			searchResults.CopyTo (returnValue);
			return returnValue;
		}
コード例 #22
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.Insert"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Insert(int index, MessagePart messagePart) {
     List.Insert(index, messagePart);
 }
コード例 #23
0
        internal void ReflectStringParametersMessage()
        {
            Message inputMessage = base.InputMessage;

            foreach (ParameterInfo info in base.Method.InParameters)
            {
                MessagePart messagePart = new MessagePart {
                    Name = XmlConvert.EncodeLocalName(info.Name)
                };
                if (info.ParameterType.IsArray)
                {
                    string defaultNamespace = base.DefaultNamespace;
                    if (defaultNamespace.EndsWith("/", StringComparison.Ordinal))
                    {
                        defaultNamespace = defaultNamespace + "AbstractTypes";
                    }
                    else
                    {
                        defaultNamespace = defaultNamespace + "/AbstractTypes";
                    }
                    string name = "StringArray";
                    if (!base.ServiceDescription.Types.Schemas.Contains(defaultNamespace))
                    {
                        XmlSchema schema = new XmlSchema {
                            TargetNamespace = defaultNamespace
                        };
                        base.ServiceDescription.Types.Schemas.Add(schema);
                        XmlSchemaElement item = new XmlSchemaElement {
                            Name           = "String",
                            SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"),
                            MinOccurs      = 0M,
                            MaxOccurs      = 79228162514264337593543950335M
                        };
                        XmlSchemaSequence sequence = new XmlSchemaSequence();
                        sequence.Items.Add(item);
                        XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction {
                            BaseTypeName = new XmlQualifiedName("Array", "http://schemas.xmlsoap.org/soap/encoding/"),
                            Particle     = sequence
                        };
                        XmlSchemaImport import = new XmlSchemaImport {
                            Namespace = restriction.BaseTypeName.Namespace
                        };
                        XmlSchemaComplexContent content = new XmlSchemaComplexContent {
                            Content = restriction
                        };
                        XmlSchemaComplexType type = new XmlSchemaComplexType {
                            Name         = name,
                            ContentModel = content
                        };
                        schema.Items.Add(type);
                        schema.Includes.Add(import);
                    }
                    messagePart.Type = new XmlQualifiedName(name, defaultNamespace);
                }
                else
                {
                    messagePart.Type = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
                }
                inputMessage.Parts.Add(messagePart);
            }
        }
コード例 #24
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.CopyTo"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void CopyTo(MessagePart[] array, int index) {
     List.CopyTo(array, index);
 }
        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);
        }
コード例 #26
0
		MessagePartDescription CreateMessagePart (XmlSchemaElement elem, Message msg, MessagePart msgPart)
		{
			var part = new MessagePartDescription (elem.QualifiedName.Name, elem.QualifiedName.Namespace);
			part.DataContractImporter = dc_importer;
			if (dc_importer.CanImport (schema_set_in_use, elem)) {
				var typeQName = dc_importer.Import (schema_set_in_use, elem);
				part.CodeTypeReference = dc_importer.GetCodeTypeReference (elem.ElementSchemaType.QualifiedName, elem);
			}
			return part;
		}
コード例 #27
0
 public int Add(MessagePart messagePart)
 {
     return(base.List.Add(messagePart));
 }
コード例 #28
0
        void ImportMessage(XmlMembersMapping members, Message msg)
        {
            SoapMethodStubInfo method  = (SoapMethodStubInfo)MethodStubInfo;
            bool needsEnclosingElement = (method.ParameterStyle == SoapParameterStyle.Wrapped &&
                                          method.SoapBindingStyle == SoapBindingStyle.Document);

            if (needsEnclosingElement)
            {
                MessagePart part = new MessagePart();
                part.Name = "parameters";
                XmlQualifiedName qname = new XmlQualifiedName(members.ElementName, members.Namespace);
                if (method.Use == SoapBindingUse.Literal)
                {
                    part.Element = qname;
                }
                else
                {
                    part.Type = qname;
                }
                msg.Parts.Add(part);
            }
            else
            {
                for (int n = 0; n < members.Count; n++)
                {
                    MessagePart part = new MessagePart();
                    part.Name = members[n].MemberName;

                    if (method.Use == SoapBindingUse.Literal)
                    {
                        if (members[n].Any)
                        {
                            part.Type = new XmlQualifiedName("any", members[n].Namespace);
                        }
                        else
                        {
                            part.Element = new XmlQualifiedName(members[n].ElementName, members[n].Namespace);
                        }
                    }
                    else
                    {
                        string namesp = members[n].TypeNamespace;
                        if (namesp == "")
                        {
                            namesp = members[n].Namespace;
                        }
                        part.Name = members[n].ElementName;
                        part.Type = new XmlQualifiedName(members[n].TypeName, namesp);
                    }
                    msg.Parts.Add(part);
                }
            }


            if (method.Use == SoapBindingUse.Literal)
            {
                SchemaExporter.ExportMembersMapping(members);
            }
            else
            {
                SoapSchemaExporter.ExportMembersMapping(members, needsEnclosingElement);
            }
        }
コード例 #29
0
ファイル: SoapProtocolImporter.cs プロジェクト: lsp1357/mono
        XmlMembersMapping ImportMembersMapping(Message msg, SoapBodyBinding sbb, SoapBindingStyle style, bool output, bool wrapped)
        {
            string elemName = Operation.Name;

            if (output)
            {
                elemName += "Response";
            }

            if (wrapped)
            {
                // Wrapped parameter style

                MessagePart part = msg.Parts[0];
                if (sbb.Use == SoapBindingUse.Encoded)
                {
                    SoapSchemaMember ssm = new SoapSchemaMember();
                    ssm.MemberName = part.Name;
                    ssm.MemberType = part.Type;
                    return(soapImporter.ImportMembersMapping(elemName, part.Type.Namespace, ssm));
                }
                else
                {
                    return(xmlImporter.ImportMembersMapping(part.Element));
                }
            }
            else
            {
                if (sbb.Use == SoapBindingUse.Encoded)
                {
                    SoapSchemaMember[] mems = new SoapSchemaMember [msg.Parts.Count];
                    for (int n = 0; n < mems.Length; n++)
                    {
                        SoapSchemaMember mem = new SoapSchemaMember();
                        mem.MemberName = msg.Parts[n].Name;
                        mem.MemberType = msg.Parts[n].Type;
                        mems[n]        = mem;
                    }

                    // Rpc messages always have a wrapping element
                    if (style == SoapBindingStyle.Rpc)
                    {
                        return(soapImporter.ImportMembersMapping(elemName, sbb.Namespace, mems, true));
                    }
                    else
                    {
                        return(soapImporter.ImportMembersMapping("", "", mems, false));
                    }
                }
                else
                {
                    if (style == SoapBindingStyle.Rpc)
                    {
                        throw new InvalidOperationException("The combination of style=rpc with use=literal is not supported");
                    }

                    if (msg.Parts.Count == 1 && msg.Parts[0].Type != XmlQualifiedName.Empty)
                    {
                        return(xmlImporter.ImportAnyType(msg.Parts[0].Type, null));
                    }
                    else
                    {
                        XmlQualifiedName[] pnames = new XmlQualifiedName [msg.Parts.Count];
                        for (int n = 0; n < pnames.Length; n++)
                        {
                            pnames[n] = msg.Parts[n].Element;
                        }
                        return(xmlImporter.ImportMembersMapping(pnames));
                    }
                }
            }
        }
コード例 #30
0
 static protected WsdlNS.MessagePart AddMessagePart(WsdlNS.Message message, string partName, XmlQualifiedName elementName, XmlQualifiedName typeName)
 {
     if (message.Parts[partName] != null)
     {
         if (IsNullOrEmpty(elementName))
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SFxPartNameMustBeUniqueInRpc, partName)));
         int i = 1;
         while (message.Parts[partName + i] != null)
         {
             if (i == Int32.MaxValue)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SFxTooManyPartsWithSameName, partName)));
             i++;
         }
         partName = partName + i.ToString(CultureInfo.InvariantCulture);
     }
     WsdlNS.MessagePart part = new WsdlNS.MessagePart();
     part.Name = partName;
     part.Element = elementName;
     part.Type = typeName;
     message.Parts.Add(part);
     EnsureXsdImport(IsNullOrEmpty(elementName) ? typeName.Namespace : elementName.Namespace, message.ServiceDescription);
     return part;
 }
コード例 #31
0
ファイル: SoapProtocolImporter.cs プロジェクト: lsp1357/mono
        void ImportHeader(CodeMemberMethod method, SoapHeaderBinding hb, SoapHeaderDirection direction)
        {
            Message msg = ServiceDescriptions.GetMessage(hb.Message);

            if (msg == null)
            {
                throw new InvalidOperationException("Message " + hb.Message + " not found");
            }
            MessagePart part = msg.Parts [hb.Part];

            if (part == null)
            {
                throw new InvalidOperationException("Message part " + hb.Part + " not found in message " + hb.Message);
            }

            XmlTypeMapping map;
            string         hname;

            if (hb.Use == SoapBindingUse.Literal)
            {
                map   = xmlImporter.ImportDerivedTypeMapping(part.Element, typeof(SoapHeader));
                hname = part.Element.Name;
                xmlExporter.ExportTypeMapping(map);
            }
            else
            {
                map   = soapImporter.ImportDerivedTypeMapping(part.Type, typeof(SoapHeader), true);
                hname = part.Type.Name;
                soapExporter.ExportTypeMapping(map);
            }

            string varName = headerVariables [map] as string;

            if (varName == null)
            {
                if (hname == map.TypeName)
                {
                    varName = memberIds.AddUnique(CodeIdentifier.MakeValid(hname + "Value"), hb);
                }
                else
                {
                    varName = memberIds.AddUnique(CodeIdentifier.MakeValid(hname), hb);
                }

                string propName = varName;
                varName = varName + "Field";
                headerVariables.Add(map, varName);
                CodeMemberField codeField = new CodeMemberField(map.TypeFullName, varName);
                CodeTypeDeclaration.Members.Add(codeField);

                codeField.Attributes = MemberAttributes.Private;
                CodeMemberProperty codeProperty = new CodeMemberProperty();
                codeProperty.Name       = propName;
                codeProperty.Type       = new CodeTypeReference(map.TypeFullName);
                codeProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                codeProperty.HasGet     = codeProperty.HasSet = true;
                CodeExpression ce = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), varName);
                codeProperty.SetStatements.Add(new CodeAssignStatement(ce, new CodePropertySetValueReferenceExpression()));
                codeProperty.GetStatements.Add(new CodeMethodReturnStatement(ce));
                CodeTypeDeclaration.Members.Add(codeProperty);

                varName = propName;
            }

            CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Web.Services.Protocols.SoapHeaderAttribute");

            att.Arguments.Add(GetArg(varName));
#if ONLY_1_0
            att.Arguments.Add(GetArg("Required", false));
#endif
            if (direction != SoapHeaderDirection.In)
            {
                att.Arguments.Add(GetEnumArg("Direction", "System.Web.Services.Protocols.SoapHeaderDirection", direction.ToString()));
            }
            AddCustomAttribute(method, att, true);
        }
コード例 #32
0
		void ImportMessage (XmlMembersMapping members, Message msg)
		{
			SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
			bool needsEnclosingElement = (method.ParameterStyle == SoapParameterStyle.Wrapped && 
											method.SoapBindingStyle == SoapBindingStyle.Document);

			if (needsEnclosingElement)
			{
				MessagePart part = new MessagePart ();
				part.Name = "parameters";
				XmlQualifiedName qname = new XmlQualifiedName (members.ElementName, members.Namespace);
				if (method.Use == SoapBindingUse.Literal) part.Element = qname;
				else part.Type = qname;
				msg.Parts.Add (part);
			}
			else
			{
				for (int n=0; n<members.Count; n++)
				{
					MessagePart part = new MessagePart ();
					part.Name = members[n].MemberName;
					
					if (method.Use == SoapBindingUse.Literal) {
						if (members[n].Any)
							part.Type = new XmlQualifiedName ("any", members[n].Namespace);
						else
							part.Element = new XmlQualifiedName (members[n].ElementName, members[n].Namespace);
					}
					else {
						string namesp = members[n].TypeNamespace;
						if (namesp == "") namesp = members[n].Namespace;
						part.Name = members[n].ElementName;
						part.Type = new XmlQualifiedName (members[n].TypeName, namesp);
					}
					msg.Parts.Add (part);
				}
			}
			
			
			if (method.Use == SoapBindingUse.Literal)
				SchemaExporter.ExportMembersMapping (members);
			else
				SoapSchemaExporter.ExportMembersMapping (members, needsEnclosingElement);
		}
コード例 #33
0
ファイル: MFMetadataExporter.cs プロジェクト: prabby/miniclr
        /// <summary>
        /// Generates a Wsdl Message information object for each method parameter.
        /// </summary>
        /// <param name="methodInfo">A MethodInfo object containing a reflected types method information.</param>
        /// <param name="operation">Used to gnerate a Wsdl Message name.</param>
        /// <param name="isCallback">A flag used to signal that the operation is a callback operation.
        /// Callback operations have a different operaiton nameing convension.</param>
        /// <param name="serviceDescription">A ServiceDescription object used to store the generated Message(s).</param>
        /// <returns>True if the operation contains message parameters.</returns>
        bool ProcessOperationParams(MethodInfo methodInfo, Operation operation, bool isCallback, ServiceDescription serviceDescription)
        {
            bool messageFound = false;

            // Iterate the collection or parameters
            ParameterInfo[] parameters = methodInfo.GetParameters();
            for (int i = 0; i < parameters.Length; ++i)
            {
                Logger.WriteLine("        Param " + i + " Name: " + parameters[i].Name, LogLevel.Verbose);
                Logger.WriteLine("        Param " + i + " Type: " + parameters[i].ParameterType, LogLevel.Verbose);

                Message message = new Message();
                MessagePart part = new MessagePart();

                // Create the message, part and element
                message.Name = operation.Name + (isCallback ? "Out" : "In");
                part.Name = "parameters";

                // If the type is a native type, create an element name using the method name
                string elementName;
                bool isArray = parameters[i].ParameterType.FullName.EndsWith("[]");
                if (!isArray && (elementName = CodeGenUtils.GetXmlType(parameters[i].ParameterType.FullName)) == null)
                    elementName = parameters[i].ParameterType.Name;
                else
                    elementName = parameters[i].Name;

                part.Element = new XmlQualifiedName(elementName, serviceDescription.TargetNamespace);

                // Add the new part to the message
                message.Parts.Add(part);

                // Add message to service description
                serviceDescription.Messages.Add(message);
                messageFound = true;

                // If the method returns a single native type create the element here
                // while we have all of the information. We do not forse a developer 
                // to create an element for simple types.
                string xmlTypeName = parameters[i].ParameterType.FullName;
                if (isArray)
                    xmlTypeName = xmlTypeName.Substring(0, xmlTypeName.Length - 2);
                xmlTypeName = CodeGenUtils.GetXmlType(xmlTypeName);
                if (xmlTypeName != null)
                {
                    AddNativeTypeElement(elementName, serviceDescription.TargetNamespace, xmlTypeName, isArray, serviceDescription);
                }
            }

            return messageFound;
        }
 private void FindUse(MessagePart part, out bool isEncoded, out bool isLiteral)
 {
     isEncoded = false;
     isLiteral = false;
     string name = part.Message.Name;
     Operation operation = null;
     ServiceDescription serviceDescription = part.Message.ServiceDescription;
     foreach (PortType type in serviceDescription.PortTypes)
     {
         foreach (Operation operation2 in type.Operations)
         {
             foreach (OperationMessage message in operation2.Messages)
             {
                 if (message.Message.Equals(new XmlQualifiedName(part.Message.Name, serviceDescription.TargetNamespace)))
                 {
                     operation = operation2;
                     this.FindUse(operation, serviceDescription, name, ref isEncoded, ref isLiteral);
                 }
             }
         }
     }
     if (operation == null)
     {
         this.FindUse(null, serviceDescription, name, ref isEncoded, ref isLiteral);
     }
 }
コード例 #35
0
ファイル: MFMetadataExporter.cs プロジェクト: prabby/miniclr
        /// <summary>
        /// Generate a ServiceDescription Message object from a reflected methods return type.
        /// </summary>
        /// <param name="methodInfo">A MethodInfo object containing a reflected types method information.</param>
        /// <param name="operation">Used to gnerate a Wsdl Message name.</param>
        /// <param name="isCallback">A flag used to signal that the operation is a callback operation.
        /// Callback operations have a different operaiton nameing convension.</param>
        /// <param name="serviceDescription">A ServiceDescription object used to store generated Message.</param>
        /// <remarks>Since method return types are not named. Message names are generated from the operation name plus the "Response"
        /// unless the method is a callback method.</remarks>
        void ProcessReturnType(MethodInfo methodInfo, Operation operation, bool isCallback, ServiceDescription serviceDescription)
        {
            // Create return message
            Logger.WriteLine("        Return Type: " + methodInfo.ReturnType, LogLevel.Verbose);

            // If the return type is a native type, create an element name using the method name
            string elementName;
            bool isArray = methodInfo.ReturnType.FullName.EndsWith("[]");
            elementName = methodInfo.ReturnType.FullName;
            if (isArray)
                elementName = elementName.Substring(0, elementName.Length - 2);
            if (isArray && (elementName = CodeGenUtils.GetXmlType(elementName)) != null)
                // Note: Remove "Request" if possible
                elementName = methodInfo.Name + (isCallback ? "" : "Response");
            else
                elementName = methodInfo.ReturnType.Name;

            Message message = new Message();
            MessagePart part = new MessagePart();

            // Create the message, part and element
            message.Name = operation.Name + "Out";
            if (elementName != "Void")
            {
                part.Name = "parameters";
                part.Element = new XmlQualifiedName(elementName, serviceDescription.TargetNamespace);

                // Add the new part to the message
                message.Parts.Add(part);
            }

            // Add message to service description
            serviceDescription.Messages.Add(message);

            // If the method returns a single native type create the element here
            // while we have all of the informaiton. We do not forse a developer 
            // to create an element for simple types.
            string xmlTypeName = methodInfo.ReturnType.FullName;
            if (isArray)
                xmlTypeName = xmlTypeName.Substring(0, xmlTypeName.Length - 2);
            xmlTypeName = CodeGenUtils.GetXmlType(xmlTypeName);
            if (xmlTypeName != null)
            {
                AddNativeTypeElement(elementName, serviceDescription.TargetNamespace, xmlTypeName, isArray, serviceDescription);
            }
        }
コード例 #36
0
        void CreateHeaderMessages(string methodName, SoapBindingUse use, XmlMembersMapping inHeaderMappings, XmlMembersMapping outHeaderMappings, SoapReflectedHeader[] headers, bool rpc) {
            // 
            if (use == SoapBindingUse.Encoded) {
                SoapExporter.ExportMembersMapping(inHeaderMappings, false);
                if (outHeaderMappings != null)
                    SoapExporter.ExportMembersMapping(outHeaderMappings, false);
            }
            else {
                SchemaExporter.ExportMembersMapping(inHeaderMappings);
                if (outHeaderMappings != null)
                    SchemaExporter.ExportMembersMapping(outHeaderMappings);
            }

            CodeIdentifiers identifiers = new CodeIdentifiers();
            int inCount = 0, outCount = 0;
            for (int i = 0; i < headers.Length; i++) {
                SoapReflectedHeader soapHeader = headers[i];
                if (!soapHeader.custom) continue;
                
                XmlMemberMapping member;
                if ((soapHeader.direction & SoapHeaderDirection.In) != 0) {
                    member = inHeaderMappings[inCount++];
                    if (soapHeader.direction != SoapHeaderDirection.In)
                        outCount++;
                }
                else {
                    member = outHeaderMappings[outCount++];
                }

                MessagePart part = new MessagePart();
                part.Name = member.XsdElementName;
                if (use == SoapBindingUse.Encoded)
                    part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace);
                else
                    part.Element = new XmlQualifiedName(member.XsdElementName, member.Namespace);
                Message message = new Message();
                message.Name = identifiers.AddUnique(methodName + part.Name, message);
                message.Parts.Add(part);
                HeaderMessages.Add(message);

                ServiceDescriptionFormatExtension soapHeaderBinding = CreateSoapHeaderBinding(new XmlQualifiedName(message.Name, Binding.ServiceDescription.TargetNamespace), part.Name, rpc ? member.Namespace : null, use);
                
                if ((soapHeader.direction & SoapHeaderDirection.In) != 0)
                    OperationBinding.Input.Extensions.Add(soapHeaderBinding);
                if ((soapHeader.direction & SoapHeaderDirection.Out) != 0)
                    OperationBinding.Output.Extensions.Add(soapHeaderBinding);

                if ((soapHeader.direction & SoapHeaderDirection.Fault) != 0) {
                    if (soapMethod.IsClaimsConformance) {
                        throw new InvalidOperationException(Res.GetString(Res.BPConformanceHeaderFault, soapMethod.methodInfo.ToString(), soapMethod.methodInfo.DeclaringType.FullName, "Direction", typeof(SoapHeaderDirection).Name, SoapHeaderDirection.Fault.ToString())); 
                    }
                    OperationBinding.Output.Extensions.Add(soapHeaderBinding);
                }
            }
        }
コード例 #37
0
        void ReadServiceDescription()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                XmlTextReader           reader  = new XmlTextReader(comboBox1.Text);
                Desc.ServiceDescription service =
                    Desc.ServiceDescription.Read(reader);

                //WSDLParser.WSDLParser wsdl = new EIBFormDesigner.WSDLParser.WSDLParser(service);

                comboNamespace.Items.Add(service.TargetNamespace);
                foreach (Desc.PortType pt in service.PortTypes)
                {
                    //Console.WriteLine("PortType {0}", pt.Name);

                    foreach (Desc.Operation op in pt.Operations)
                    {
                        //Console.WriteLine("\tOperation: {0}", op.Name);
                        comboBox2.Items.Add(op.Name);
                        //service.Services[service.Name].Ports[pt.Name]
                        Desc.Types types = service.Types;
                        System.Xml.Schema.XmlSchema xmlSchema = types.Schemas[0];

                        //string typeName = service.Messages[op.Messages.Input.Message.Name].FindPartByName(op.Messages.Input.Message.Name).Type.Name;
                        System.Web.Services.Description.MessagePart msgPart = service.Messages[op.Messages.Input.Message.Name].Parts["parameters"];
                        string paramElementName = null;
                        if (msgPart != null)
                        {
                            paramElementName = msgPart.Element.Name;
                            parameterMappings.Add(paramElementName, new Dictionary <string, string>());
                        }
                        foreach (object obj in xmlSchema.Items)
                        {
                            System.Xml.Schema.XmlSchemaElement sElement = obj as System.Xml.Schema.XmlSchemaElement;
                            if (sElement != null && sElement.Name == paramElementName)
                            {
                                if (sElement.SchemaType != null && sElement.SchemaType.GetType() == typeof(System.Xml.Schema.XmlSchemaComplexType))
                                {
                                    System.Xml.Schema.XmlSchemaComplexType xComplexType = sElement.SchemaType as System.Xml.Schema.XmlSchemaComplexType;
                                    TraverseParticle(xComplexType.Particle, paramElementName);
                                }
                                break;
                            }

                            /*if (obj is System.Xml.Schema.XmlSchemaComplexType)
                             * {
                             *  System.Xml.Schema.XmlSchemaComplexType xComplexType = obj as System.Xml.Schema.XmlSchemaComplexType;
                             *  if (xComplexType.Name == )
                             *  {
                             *      MessageBox.Show(xComplexType.Name + " : " + typeName);
                             *      TraverseParticle(xComplexType.ContentTypeParticle);
                             *
                             *  }
                             * }*/
                        }
                    }
                }


                //wsdl.WSDLParser parser = new wsdl.WSDLParser(service);

                //this.tvwService.Nodes.Add(parser.ServiceNode);
                //this.cboURL.Items.Add(cboURL.Text);
                //http://soap.amazon.com/schemas2/AmazonWebServices.wsdl
                //http://glkev.webs.innerhost.com/glkev_ws/weatherfetcher.asmx?wsdl
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #38
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.Add"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int Add(MessagePart messagePart) {
     return List.Add(messagePart);
 }
コード例 #39
0
ファイル: DCCodeGen.cs プロジェクト: awakegod/NETMF-LPC
        /// <summary>
        /// For a given wsdl service operation, generate an Rpc or document style wrapped data contract
        /// and data contract serializer.
        /// </summary>
        /// <param name="BindingStyle">A flag indicating the binding style.</param>
        /// <param name="operationMessage">A OperationMessage type containing an OperationInput or OperationOutput type.</param>
        /// <param name="messageParts">A collection of message parts used by the operation.</param>
        /// <param name="messageTypes">An arraylist of message elements and or types used by the operation.</param>
        private void GenerateWrappedContracts(BindingStyle bindingStyle, OperationMessage operationMessage, MessagePartCollection messageParts, ArrayList messageTypes)
        {
            if (messageTypes.Count == 0)
                return;
            
            // Rules: Rpc/Literal support only. WS-I basic profile Rpc/Literal rules apply.
            
            // Create a temporary wrapper element type that will be used to wrap the message parts.
            // As per rpc/literal spec the name of the type is the name of the operation
            // If the message is a response the name = the operation name + "Response".
            // The temporary wrapper element is stored in a new schema that will be added to the existing
            // ServiceDescription schema set and recompiled to resolve all type references.
            XmlSchema schema = operationMessage.Operation.PortType.ServiceDescription.Types.Schemas[0];
            XmlSchemaSet schemaSet = new XmlSchemaSet();
            XmlSchemaElement wrapperElement = new XmlSchemaElement();
            schema.Items.Add(wrapperElement);
            string elementName = operationMessage.Operation.Name;
            elementName = operationMessage is OperationOutput ? elementName + "Response" : elementName + "Request";
            wrapperElement.Name = elementName;

            // The element namespace is the target namespace by default else it is 
            // defined by the binding/operation/soap12Body/namespace attribute
            schema.TargetNamespace = CodeGenUtils.GetOperationNamespace(operationMessage);

            // Add a new complex type to the element
            XmlSchemaComplexType complexType = new XmlSchemaComplexType();
            wrapperElement.SchemaType = complexType;

            // Add a sequence particles to the complex type
            XmlSchemaSequence sequence = new XmlSchemaSequence();
            complexType.Particle = sequence;

            // Loop through the list of parts and add thier definitions to the sequence
            for (int i = 0; i < messageTypes.Count; ++i)
            {
                if (bindingStyle == BindingStyle.Rpc)
                {
                    XmlSchemaElement typeElement = new XmlSchemaElement();
                    typeElement.Name = messageParts[i].Name;
                    typeElement.SchemaTypeName = new XmlQualifiedName(messageParts[i].Type.Name, messageParts[i].Type.Namespace);
                    sequence.Items.Add(typeElement);
                    schema.Items.Add((XmlSchemaType)messageTypes[i]);
                }
                else
                    sequence.Items.Add((XmlSchemaElement)messageTypes[i]);
            }

            // Add the new schema containing the new element to a set and compile
            schemaSet.Add(schema);
            schemaSet.Compile();

            // Build the new element and serializer
            CodeTypeDeclaration codeType = new CodeTypeDeclaration();
            CodeNamespace codeNs = CodeGenUtils.GetDotNetNamespace(m_codeNamespaces, wrapperElement.QualifiedName.Namespace);
            BuildElementType(wrapperElement, codeType);
            if (!CodeGenUtils.TypeExists(codeNs, codeType.Name))
            {
                codeNs.Types.Add(codeType);
                m_dcsCodeGen.BuildDataContractSerializer(m_encodingType, codeType, codeNs);
            }

            // Swap the existing message parts with a new replacement part. All subsequent processing
            // will use the new single message part
            foreach (Message message in operationMessage.Operation.PortType.ServiceDescription.Messages)
            {
                if (message.Name == operationMessage.Message.Name)
                {
                    MessagePart replacementPart = new MessagePart();
                    replacementPart.Element = new XmlQualifiedName(elementName);
                    replacementPart.Type = wrapperElement.QualifiedName;
                    replacementPart.Name = operationMessage.Name;
                    replacementPart.Namespaces = operationMessage.Namespaces;
                    message.Parts.Clear();
                    message.Parts.Add(replacementPart);
                    break;
                }
            }
        }
コード例 #40
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.IndexOf"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int IndexOf(MessagePart messagePart) {
     return List.IndexOf(messagePart);
 }
コード例 #41
0
		protected abstract void ImportPartsBySchemaElement (QName qname, List<MessagePartDescription> parts, Message msg, MessagePart part);
コード例 #42
0
 /// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="MessagePartCollection.Remove"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Remove(MessagePart messagePart) {
     List.Remove(messagePart);
 }
コード例 #43
0
		protected override void ImportPartsBySchemaElement (QName qname, List<MessagePartDescription> parts, Message msg, MessagePart part)
		{
			XmlSchemaElement element = (XmlSchemaElement) schema_set_in_use.GlobalElements [qname];
			if (element == null)
				throw new InvalidOperationException ("Could not resolve : " + qname.ToString ()); // this should have been rejected by CanImportOperation().

			var ct = element.ElementSchemaType as XmlSchemaComplexType;
			if (ct == null) // simple type
				parts.Add (CreateMessagePart (element, msg, part));
			else // complex type
				foreach (var elem in GetElementsInParticle (ct.ContentTypeParticle))
					parts.Add (CreateMessagePart (elem, msg, part));
		}
コード例 #44
0
		MessagePart ExportMessageBodyDescription (MessageBodyDescription msgbody, string name, string ns)
		{
			MessagePart msgpart = new MessagePart ();
			string part_name = IsTypeMessage (msgbody);

			if (part_name != null) {
				msgpart.Name = part_name;
				msgpart.Type = ExportTypeMessage (); //FIXME: Cache this
			} else {
				msgpart.Name = "parameters";
				msgpart.Element = ExportParameters (msgbody, name, ns);
			}
			return msgpart;
		}
コード例 #45
0
 public void Insert(int index, MessagePart messagePart)
 {
     base.List.Insert(index, messagePart);
 }