Exemplo n.º 1
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);
        }
        XmlTypeMapping ImportOutMembersMapping(Message msg)
        {
            if (msg.Parts.Count == 0)
            {
                return(null);
            }

            if (msg.Parts[0].Name == "Body" && msg.Parts[0].Element == XmlQualifiedName.Empty)
            {
                return(xmlReflectionImporter.ImportTypeMapping(typeof(XmlNode)));
            }
            else
            {
                // This is a bit hacky. The issue is that types such as string[] are to be imported
                // as such, not as ArrayOfString class. ImportTypeMapping will return a
                // class if the type has not been imported as an array before, hence the
                // call to ImportMembersMapping.
                xmlImporter.ImportMembersMapping(new XmlQualifiedName[] { msg.Parts[0].Element });
                return(xmlImporter.ImportTypeMapping(msg.Parts[0].Element));
            }
        }
Exemplo n.º 3
0
        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));
                    }
                }
            }
        }