示例#1
0
        //Exports <xs:type for SMMessage
        //FIXME: complex type for this can be made static
        QName ExportTypeMessage()
        {
            XmlSchema xs    = GetSchema("http://schemas.microsoft.com/Message");
            QName     qname = new QName("MessageBody", xs.TargetNamespace);

            foreach (XmlSchemaObject o in xs.Items)
            {
                XmlSchemaComplexType ct = o as XmlSchemaComplexType;
                if (ct == null)
                {
                    continue;
                }

                if (ct.Name == "MessageBody")
                {
                    //Already exported
                    return(qname);
                }
            }

            XmlSchemaComplexType complex_type = new XmlSchemaComplexType();

            complex_type.Name = "MessageBody";
            XmlSchemaSequence sequence = new XmlSchemaSequence();

            XmlSchemaAny any = new XmlSchemaAny();

            any.MinOccurs       = 0;
            any.MaxOccursString = "unbounded";
            any.Namespace       = "##any";

            sequence.Items.Add(any);
            complex_type.Particle = sequence;

            xs.Items.Add(complex_type);
            GeneratedXmlSchemas.Reprocess(xs);

            return(qname);
        }
示例#2
0
        QName ExportParameters(MessageBodyDescription msgbody, string name, string ns)
        {
            XmlSchema xs = GetSchema(ns);

            //FIXME: Extract to a HasElement method ?
            foreach (XmlSchemaObject o in xs.Items)
            {
                XmlSchemaElement e = o as XmlSchemaElement;
                if (e == null)
                {
                    continue;
                }

                if (e.Name == name)
                {
                    throw new InvalidOperationException(String.Format(
                                                            "Message element named '{0}:{1}' has already been exported.",
                                                            ns, name));
                }
            }

            //Create the element for "parameters"
            XmlSchemaElement schema_element = new XmlSchemaElement();

            schema_element.Name = name;

            XmlSchemaComplexType complex_type = new XmlSchemaComplexType();
            //Generate Sequence representing the message/parameters
            //FIXME: MessageContractAttribute

            XmlSchemaSequence sequence = new XmlSchemaSequence();
            XmlSchemaElement  element  = null;

            if (msgbody.ReturnValue == null)
            {
                //parameters
                foreach (MessagePartDescription part in msgbody.Parts)
                {
                    if (part.Type == null)
                    {
                        //FIXME: Eg. when WsdlImporter is used to import a wsdl
                        throw new NotImplementedException();
                    }

                    element = GetSchemaElementForPart(part, xs);
                    sequence.Items.Add(element);
                }
            }
            else
            {
                //ReturnValue
                if (msgbody.ReturnValue.Type != typeof(void))
                {
                    element = GetSchemaElementForPart(msgbody.ReturnValue, xs);
                    sequence.Items.Add(element);
                }
            }

            complex_type.Particle     = sequence;
            schema_element.SchemaType = complex_type;

            xs.Items.Add(schema_element);
            GeneratedXmlSchemas.Reprocess(xs);

            return(new QName(schema_element.Name, xs.TargetNamespace));
        }