private string ParseQName(ref string qname, URTNamespace defaultNS, out URTNamespace returnNS)
 {
     string name = null;
     returnNS = null;
     if ((qname == null) || (qname.Length == 0))
     {
         return null;
     }
     int index = qname.IndexOf(":");
     if (index == -1)
     {
         returnNS = defaultNS;
         if (defaultNS == null)
         {
             name = this._XMLReader.LookupNamespace("");
         }
         else
         {
             name = defaultNS.Name;
         }
     }
     else
     {
         string prefix = qname.Substring(0, index);
         qname = this.Atomize(qname.Substring(index + 1));
         name = this._XMLReader.LookupNamespace(prefix);
     }
     name = this.Atomize(name);
     URTNamespace namespace2 = this.LookupNamespace(name);
     if (namespace2 == null)
     {
         namespace2 = new URTNamespace(name, this);
     }
     returnNS = namespace2;
     return name;
 }
Example #2
0
        // Parses a global element declaration
        private void ParseElementDecl(URTNamespace parsingNamespace)
        {
            Util.Log("WsdlParser.ParseElementDecl");            
            // Obtain element name and its type
            String elmName = LookupAttribute(s_nameString, null, true);
            String elmNS = parsingNamespace.Name;
            String typeName = LookupAttribute(s_typeString, null, false);

            // Handle the anonymous types
            String typeNS;
            bool bEmbedded, bPrimitive;
            if (_XMLReader.IsEmptyElement == true)
            {
                // Non-anonymous type case
                // We cannot assert that the type attribute must have been present
                // due to the Object/ur-type case
                ResolveTypeAttribute(ref typeName, out typeNS, out bEmbedded, out bPrimitive);

                // Position to the next element
                ReadNextXmlElement();
            }
            else
            {
                // Anonymous type case
                typeNS = parsingNamespace.Name;
                typeName = parsingNamespace.GetNextAnonymousName();
                bEmbedded = true;
                bPrimitive = false;

                // Parse the type
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();
                String elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if (MatchingStrings(elementName, s_complexTypeString))
                    {
                        ParseComplexType(parsingNamespace, typeName);
                    }
                    else if (MatchingStrings(elementName, s_simpleTypeString))
                    {
                        ParseSimpleType(parsingNamespace, typeName);
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                }
            }

            // Create a new global element under the current namespace
            parsingNamespace.AddElementDecl(new ElementDecl(elmName, elmNS, typeName, typeNS,
                                                            bPrimitive));

            return;
        }
Example #3
0
        // Parses namespace declaration elements
        private URTNamespace ParseNamespace()
        {
            Util.Log("WsdlParser.ParseNamespace");          
            // Determine the new namespace encountered
            String name = (String) LookupAttribute(s_targetNamespaceString, null, false);
            bool bUnique = false;
            if (MatchingStrings(name, s_emptyString) &&
                MatchingStrings(_XMLReader.LocalName, s_sudsString) &&
                _parsingInput.UniqueNS == null)
            {
                name = _parsingInput.TargetNS;
                bUnique = true;
            }

            // Add the namespace being parsed to the list if neccessary
            URTNamespace parsingNamespace = LookupNamespace(name);
            if (parsingNamespace == null)
            {
                parsingNamespace = new URTNamespace(name, this);
            }
            if (bUnique)
                _parsingInput.UniqueNS = parsingNamespace;
            //_namespaceStack = NamespaceStack.Push(_namespaceStack, _parsingNamespace, _XMLReader.Depth);

            // Parse schema defaults
            //if(MatchingStrings(_XMLReader.LocalName, s_sudsString))
            //{

            //}

            // Read the next record
            ReadNextXmlElement();

            return(parsingNamespace);
        }
Example #4
0
        // Parses attribute fields
        private void ParseAttributeField(URTNamespace parsingNamespace,
                                         URTComplexType parsingComplexType)
        {
            Util.Log("WsdlParser.ParseAttributeField NS "+parsingNamespace);
            // Lookup field name
            String attrTypeName, attrTypeNS;
            String attrName = LookupAttribute(s_nameString, null, true);

            // Check if the field is optional
            bool bOptional = false;
            String minOccurs = LookupAttribute(s_minOccursString, null, false);
            if (MatchingStrings(minOccurs, s_zeroString))
                bOptional = true;

            // Handle anonymous types
            bool bEmbedded, bPrimitive;
            if (_XMLReader.IsEmptyElement == true)
            {
                // Non-anonymous type case and type has to present
                attrTypeName = LookupAttribute(s_typeString, null, true);
                ResolveTypeAttribute(ref attrTypeName, out attrTypeNS,
                                     out bEmbedded, out bPrimitive);

                // Read next element
                ReadNextXmlElement();

                // Check for xsd:ID type
                if (MatchingStrings(attrTypeName, s_idString) &&
                    MatchingSchemaStrings(attrTypeNS))
                {
                    parsingComplexType.IsStruct = false;
                    return;
                }
            }
            else
            {
                // Anonymous type case
                attrTypeNS = parsingNamespace.Namespace;
                attrTypeName = parsingNamespace.GetNextAnonymousName();
                bPrimitive = false;
                bEmbedded = true;
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if (MatchingStrings(elementName, s_simpleTypeString))
                    {
                        URTSimpleType simpleType = ParseSimpleType(parsingNamespace, attrTypeName);
                        if (simpleType.IsEmittableFieldType)
                        {
                            attrTypeNS = simpleType.FieldNamespace;
                            attrTypeName = simpleType.FieldName;
                            bPrimitive = simpleType.PrimitiveField;
                            parsingNamespace.RemoveSimpleType(simpleType);
                        }
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                }
            }

            // Add field to the type being parsed
            parsingComplexType.AddField(new URTField(attrName, attrTypeName, attrTypeNS,
                                                     this, bPrimitive, bEmbedded, true,
                                                     bOptional, false, null, parsingNamespace));
            return;
        }
Example #5
0
        // Parses RestrictionField fields
        // Now only set up to recognize arrays
        private void ParseRestrictionField(URTNamespace parsingNamespace,
                                           BaseType parsingType)
        {
            Util.Log("WsdlParser.ParseRestrictionField Enter NS "+parsingNamespace+" type "+parsingType);
            // Lookup field name

            String attrName = LookupAttribute(s_baseString, null, true);
            String baseNS = ParseQName(ref attrName, parsingNamespace);
            //if (MatchingStrings(baseNS, s_soapEncodingString) && MatchingStrings(attrName, s_arrayString))
            {
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                String arrayNS;
                String arrayType;
                int enumFacetNum = 0;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    Util.Log("WsdlParser.ParseRestrictionField elementName "+elementName);
                    if (MatchingStrings(elementName, s_attributeString))
                    {
                        String refValue = LookupAttribute(s_refString, null, true);
                        String refNS = ParseQName(ref refValue, parsingNamespace);
                        if (MatchingStrings(refNS, s_soapEncodingString) && MatchingStrings(refValue, s_arrayTypeString))
                        {
                            URTComplexType parsingComplexType = (URTComplexType)parsingType;
                            arrayType = LookupAttribute(s_arrayTypeString, s_wsdlNamespaceString, true);
                            Util.Log("WsdlParser.ParseRestrictionField arrayType "+arrayType);
                            URTNamespace arrayNamespace = null;
                            arrayNS = ParseQName(ref arrayType, null, out arrayNamespace);

                            parsingComplexType.AddArray(arrayType, arrayNamespace);
                            //Add array to the array namespace
                            arrayNamespace.AddComplexType(parsingComplexType); 
                            parsingComplexType.IsPrint = false;
                        }
                    }
                    else if (MatchingStrings(elementName, s_enumerationString))
                    {
                        URTSimpleType parsingSimpleType = (URTSimpleType)parsingType;
                        ParseEnumeration(parsingSimpleType, enumFacetNum);
                        ++enumFacetNum;
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                    ReadNextXmlElement();
                }
            }
            // else
            // SkipXmlElement();

            Util.Log("WsdlParser.ParseRestrictionField Exit NS "+parsingNamespace+" type "+parsingType);
            return;
        }
Example #6
0
 internal void AddNamespace(URTNamespace xns)
 {
     //Util.Log("WsdlParser.AddNamespace "+xns.GetHashCode()+" "+xns.Namespace);
     _URTNamespaces.Add(xns);
 }       
Example #7
0
            internal URTParam(String name, String typeName, String typeNS, String encodedNS,
                              URTParamType pType, bool bEmbedded, WsdlParser parser, URTNamespace urtNamespace)
            {
                Util.Log("URTParam.URTParam name "+name+" typeName "+typeName+" typeNS "+typeNS+" ecodedNS "+encodedNS+" pType "+pType+" bEmbedded "+bEmbedded);
                _name = name;
                _typeName = typeName;
                _typeNS = typeNS;
                _encodedNS = encodedNS;
                _pType = pType;
                _embeddedParam = bEmbedded;
                _parser = parser;
                _urtNamespace = urtNamespace;

            }
 internal string GetTypeString(string curNS, bool bNS, URTNamespace urtNS, string typeName, string typeNS)
 {
     string str;
     URTComplexType complexType = urtNS.LookupComplexType(typeName);
     if ((complexType != null) && complexType.IsArray())
     {
         if (complexType.GetArray() == null)
         {
             complexType.ResolveArray();
         }
         string array = complexType.GetArray();
         URTNamespace arrayNS = complexType.GetArrayNS();
         StringBuilder builder = new StringBuilder(50);
         if ((arrayNS.EncodedNS != null) && this.Qualify(urtNS.EncodedNS, arrayNS.EncodedNS))
         {
             builder.Append(IsValidCSAttr(arrayNS.EncodedNS));
             builder.Append('.');
         }
         builder.Append(IsValidCSAttr(array));
         str = builder.ToString();
     }
     else
     {
         string encodedNS = null;
         if (urtNS.UrtType == UrtType.Interop)
         {
             encodedNS = urtNS.EncodedNS;
         }
         else
         {
             encodedNS = typeNS;
         }
         if (bNS && this.Qualify(encodedNS, curNS))
         {
             StringBuilder builder2 = new StringBuilder(50);
             if (encodedNS != null)
             {
                 builder2.Append(IsValidCSAttr(encodedNS));
                 builder2.Append('.');
             }
             builder2.Append(IsValidCSAttr(typeName));
             str = builder2.ToString();
         }
         else
         {
             str = typeName;
         }
     }
     int index = str.IndexOf('+');
     if (index <= 0)
     {
         return str;
     }
     if (bNS)
     {
         return str.Replace('+', '.');
     }
     return str.Substring(0, index);
 }
 private void ParseAttributeField(URTNamespace parsingNamespace, URTComplexType parsingComplexType)
 {
     string nextAnonymousName;
     string fieldNamespace;
     bool flag2;
     bool primitiveField;
     string name = this.LookupAttribute(s_nameString, null, true);
     bool bOptional = false;
     if (MatchingStrings(this.LookupAttribute(s_minOccursString, null, false), s_zeroString))
     {
         bOptional = true;
     }
     if (this._XMLReader.IsEmptyElement)
     {
         nextAnonymousName = this.LookupAttribute(s_typeString, null, true);
         this.ResolveTypeAttribute(ref nextAnonymousName, out fieldNamespace, out flag2, out primitiveField);
         this.ReadNextXmlElement();
         if (MatchingStrings(nextAnonymousName, s_idString) && this.MatchingSchemaStrings(fieldNamespace))
         {
             parsingComplexType.IsStruct = false;
             return;
         }
     }
     else
     {
         fieldNamespace = parsingNamespace.Namespace;
         nextAnonymousName = parsingNamespace.GetNextAnonymousName();
         primitiveField = false;
         flag2 = true;
         int depth = this._XMLReader.Depth;
         this.ReadNextXmlElement();
         while (this._XMLReader.Depth > depth)
         {
             if (MatchingStrings(this._XMLReader.LocalName, s_simpleTypeString))
             {
                 URTSimpleType type = this.ParseSimpleType(parsingNamespace, nextAnonymousName);
                 if (type.IsEmittableFieldType)
                 {
                     fieldNamespace = type.FieldNamespace;
                     nextAnonymousName = type.FieldName;
                     primitiveField = type.PrimitiveField;
                     parsingNamespace.RemoveSimpleType(type);
                 }
             }
             else
             {
                 this.SkipXmlElement();
             }
         }
     }
     parsingComplexType.AddField(new URTField(name, nextAnonymousName, fieldNamespace, this, primitiveField, flag2, true, bOptional, false, null, parsingNamespace));
 }
 internal void AddNamespace(URTNamespace xns)
 {
     this._URTNamespaces.Add(xns);
 }
 internal URTNamespace AddNewNamespace(string ns)
 {
     if (ns == null)
     {
         return null;
     }
     URTNamespace namespace2 = this.LookupNamespace(ns);
     if (namespace2 == null)
     {
         namespace2 = new URTNamespace(ns, this);
     }
     if (!namespace2.IsSystem)
     {
         namespace2.bReferenced = true;
     }
     return namespace2;
 }
 private void ParseWsdlBinding(URTNamespace inparsingNamespace)
 {
     WsdlBinding binding;
     binding = new WsdlBinding {
         name = this.LookupAttribute(s_nameString, null, true),
         type = this.LookupAttribute(s_typeString, null, true),
         typeNs = this.ParseQName(ref binding.type)
     };
     URTNamespace namespace2 = this.LookupNamespace(binding.typeNs);
     if (namespace2 == null)
     {
         namespace2 = new URTNamespace(binding.typeNs, this);
     }
     binding.parsingNamespace = namespace2;
     bool flag = false;
     bool bRpcBinding = false;
     bool bSoapEncoded = false;
     bool flag4 = false;
     int depth = this._XMLReader.Depth;
     this.ReadNextXmlElement();
     while (this._XMLReader.Depth > depth)
     {
         string localName = this._XMLReader.LocalName;
         if (this.MatchingNamespace(s_wsdlSoapNamespaceString) && MatchingStrings(localName, s_bindingString))
         {
             flag = true;
             WsdlBindingSoapBinding binding2 = new WsdlBindingSoapBinding {
                 style = this.LookupAttribute(s_styleString, null, true)
             };
             if (binding2.style == "rpc")
             {
                 bRpcBinding = true;
             }
             binding2.transport = this.LookupAttribute(s_transportString, null, true);
             binding.soapBinding = binding2;
             this.ReadNextXmlElement();
             continue;
         }
         if (this.MatchingNamespace(s_wsdlSudsNamespaceString))
         {
             flag4 = true;
             if (MatchingStrings(localName, s_classString) || MatchingStrings(localName, s_structString))
             {
                 WsdlBindingSuds suds;
                 suds = new WsdlBindingSuds {
                     elementName = localName,
                     typeName = this.LookupAttribute(s_typeString, null, true),
                     ns = this.ParseQName(ref suds.typeName),
                     extendsTypeName = this.LookupAttribute(s_extendsString, null, false)
                 };
                 string use = this.LookupAttribute(s_rootTypeString, null, false);
                 suds.sudsUse = this.ProcessSudsUse(use, localName);
                 if (!MatchingStrings(suds.extendsTypeName, s_emptyString))
                 {
                     suds.extendsNs = this.ParseQName(ref suds.extendsTypeName);
                 }
                 this.ParseWsdlBindingSuds(suds);
                 binding.suds.Add(suds);
             }
             else
             {
                 WsdlBindingSuds suds2;
                 if (!MatchingStrings(localName, s_interfaceString))
                 {
                     goto Label_02CC;
                 }
                 suds2 = new WsdlBindingSuds {
                     elementName = localName,
                     typeName = this.LookupAttribute(s_typeString, null, true),
                     ns = this.ParseQName(ref suds2.typeName)
                 };
                 string str3 = this.LookupAttribute(s_rootTypeString, null, false);
                 suds2.sudsUse = this.ProcessSudsUse(str3, localName);
                 this.ParseWsdlBindingSuds(suds2);
                 binding.suds.Add(suds2);
             }
             continue;
         }
         if (this.MatchingNamespace(s_wsdlNamespaceString) && MatchingStrings(localName, s_operationString))
         {
             WsdlBindingOperation op = new WsdlBindingOperation {
                 name = this.LookupAttribute(s_nameString, null, true),
                 nameNs = this._parsingInput.TargetNS
             };
             this.ParseWsdlBindingOperation(op, ref bRpcBinding, ref bSoapEncoded);
             binding.operations.Add(op);
             continue;
         }
     Label_02CC:
         this.SkipXmlElement();
     }
     if (((flag && bRpcBinding) && bSoapEncoded) || flag4)
     {
         this.wsdlBindings.Add(binding);
     }
 }
 private URTSimpleType ParseSimpleType(URTNamespace parsingNamespace, string typeName)
 {
     if (typeName == null)
     {
         typeName = this.LookupAttribute(s_nameString, null, true);
     }
     string str = this.LookupAttribute(s_enumTypeString, s_wsdlSudsNamespaceString, false);
     URTSimpleType simpleType = parsingNamespace.LookupSimpleType(typeName);
     if (simpleType == null)
     {
         simpleType = new URTSimpleType(typeName, parsingNamespace.Name, parsingNamespace.Namespace, parsingNamespace.EncodedNS, typeName != null, this);
         string left = this.LookupAttribute(s_baseString, null, false);
         if (!MatchingStrings(left, s_emptyString))
         {
             string baseTypeNS = this.ParseQName(ref left, parsingNamespace);
             simpleType.Extends(left, baseTypeNS);
         }
         parsingNamespace.AddSimpleType(simpleType);
         int depth = this._XMLReader.Depth;
         this.ReadNextXmlElement();
         while (this._XMLReader.Depth > depth)
         {
             if (MatchingStrings(this._XMLReader.LocalName, s_restrictionString))
             {
                 this.ParseRestrictionField(parsingNamespace, simpleType);
             }
             else
             {
                 this.SkipXmlElement();
             }
         }
     }
     else
     {
         this.SkipXmlElement();
     }
     if (str != null)
     {
         simpleType.EnumType = str;
     }
     return simpleType;
 }
 private void ParseRestrictionField(URTNamespace parsingNamespace, BaseType parsingType)
 {
     string qname = this.LookupAttribute(s_baseString, null, true);
     this.ParseQName(ref qname, parsingNamespace);
     int depth = this._XMLReader.Depth;
     this.ReadNextXmlElement();
     int enumFacetNum = 0;
     while (this._XMLReader.Depth > depth)
     {
         string localName = this._XMLReader.LocalName;
         if (MatchingStrings(localName, s_attributeString))
         {
             string str4 = this.LookupAttribute(s_refString, null, true);
             if (MatchingStrings(this.ParseQName(ref str4, parsingNamespace), s_soapEncodingString) && MatchingStrings(str4, s_arrayTypeString))
             {
                 URTComplexType type = (URTComplexType) parsingType;
                 string str3 = this.LookupAttribute(s_arrayTypeString, s_wsdlNamespaceString, true);
                 URTNamespace returnNS = null;
                 this.ParseQName(ref str3, null, out returnNS);
                 type.AddArray(str3, returnNS);
                 returnNS.AddComplexType(type);
                 type.IsPrint = false;
             }
         }
         else if (MatchingStrings(localName, s_enumerationString))
         {
             URTSimpleType parsingSimpleType = (URTSimpleType) parsingType;
             this.ParseEnumeration(parsingSimpleType, enumFacetNum);
             enumFacetNum++;
         }
         else
         {
             this.SkipXmlElement();
         }
         this.ReadNextXmlElement();
     }
 }
Example #15
0
        // Parses simple types
        private URTSimpleType ParseSimpleType(URTNamespace parsingNamespace, String typeName)
        {
            Util.Log("WsdlParser.ParseSimpleType NS "+parsingNamespace+" typeName "+typeName);                                              
            // Lookup the name of the type and the base type from which it derives
            if (typeName == null)
                typeName = LookupAttribute(s_nameString, null, true);
            String enumType = LookupAttribute(s_enumTypeString, s_wsdlSudsNamespaceString, false);
            URTSimpleType parsingSimpleType = parsingNamespace.LookupSimpleType(typeName);
            if (parsingSimpleType == null)
            {
                parsingSimpleType = new URTSimpleType(typeName, parsingNamespace.Name, parsingNamespace.Namespace,
                                                      parsingNamespace.EncodedNS, typeName != null, this);
                String baseType = LookupAttribute(s_baseString, null, false);
                if (!MatchingStrings(baseType, s_emptyString))
                {
                    String baseNS = ParseQName(ref baseType, parsingNamespace);
                    parsingSimpleType.Extends(baseType, baseNS);
                }
                parsingNamespace.AddSimpleType(parsingSimpleType);

                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                //int enumFacetNum = 0;
                string elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;

                    if (MatchingStrings(elementName, s_restrictionString))
                    {
                        ParseRestrictionField(parsingNamespace, parsingSimpleType);
                    }
                    /*
                    else if (MatchingStrings(elementName, s_encodingString))
                    {
                        ParseEncoding(parsingSimpleType);
                    }
                    */
                    else
                    {
                        SkipXmlElement();
                    }
                }
            }
            else
            {
                SkipXmlElement();
            }
            if (enumType != null)
                parsingSimpleType.EnumType = enumType;

            return(parsingSimpleType);
        }
 private URTComplexType ParseComplexType(URTNamespace parsingNamespace, string typeName)
 {
     if (typeName == null)
     {
         typeName = this.LookupAttribute(s_nameString, null, true);
     }
     URTNamespace returnNS = null;
     this.ParseQName(ref typeName, parsingNamespace, out returnNS);
     URTComplexType complexType = returnNS.LookupComplexType(typeName);
     if (complexType == null)
     {
         complexType = new URTComplexType(typeName, returnNS.Name, returnNS.Namespace, returnNS.EncodedNS, this._blockDefault, false, typeName != null, this, returnNS);
         returnNS.AddComplexType(complexType);
     }
     string left = this.LookupAttribute(s_baseString, null, false);
     if (!MatchingStrings(left, s_emptyString))
     {
         string baseTypeNS = this.ParseQName(ref left, parsingNamespace);
         complexType.Extends(left, baseTypeNS);
     }
     if (complexType.Fields.Count > 0)
     {
         this.SkipXmlElement();
         return complexType;
     }
     int depth = this._XMLReader.Depth;
     this.ReadNextXmlElement();
     int fieldNum = 0;
     while (this._XMLReader.Depth > depth)
     {
         string localName = this._XMLReader.LocalName;
         if (MatchingStrings(localName, s_elementString))
         {
             this.ParseElementField(returnNS, complexType, fieldNum);
             fieldNum++;
         }
         else
         {
             if (MatchingStrings(localName, s_attributeString))
             {
                 this.ParseAttributeField(returnNS, complexType);
                 continue;
             }
             if (MatchingStrings(localName, s_allString))
             {
                 complexType.BlockType = SchemaBlockType.ALL;
             }
             else if (MatchingStrings(localName, s_sequenceString))
             {
                 complexType.BlockType = SchemaBlockType.SEQUENCE;
             }
             else if (MatchingStrings(localName, s_choiceString))
             {
                 complexType.BlockType = SchemaBlockType.CHOICE;
             }
             else if (MatchingStrings(localName, s_complexContentString))
             {
                 complexType.BlockType = SchemaBlockType.ComplexContent;
             }
             else
             {
                 if (MatchingStrings(localName, s_restrictionString))
                 {
                     this.ParseRestrictionField(returnNS, complexType);
                 }
                 else
                 {
                     this.SkipXmlElement();
                 }
                 continue;
             }
             this.ReadNextXmlElement();
         }
     }
     return complexType;
 }
Example #17
0
        // This routine is used when finding and creating namespaces during the resolve phase.
        // These references are from binding section which support encoded rpc. Any namespace
        // not referenced during this phase will be pruned before creating proxy. This will
        // prevent Types not used from being placed in the proxy.
        
        internal URTNamespace AddNewNamespace(String ns)
        {
            Util.Log("WsdlParser.AddNewNamespace name "+ns); 
            if (ns == null)
            return null;

            URTNamespace xns = LookupNamespace(ns);
            if (xns == null)
            {
            xns = new URTNamespace(ns, this);
            Util.Log("WsdlParser.AddNewNamespace new namespace "+ns);            
            }
            else
            {
            Util.Log("WsdlParser.AddNewNamespace existing namespace "+ns);            
            }
            if (!xns.IsSystem)
                xns.bReferenced= true;
            return xns;
        }
 private void ParseElementDecl(URTNamespace parsingNamespace)
 {
     string str4;
     bool flag;
     bool flag2;
     string elmName = this.LookupAttribute(s_nameString, null, true);
     string name = parsingNamespace.Name;
     string typeName = this.LookupAttribute(s_typeString, null, false);
     if (this._XMLReader.IsEmptyElement)
     {
         this.ResolveTypeAttribute(ref typeName, out str4, out flag, out flag2);
         this.ReadNextXmlElement();
     }
     else
     {
         str4 = parsingNamespace.Name;
         typeName = parsingNamespace.GetNextAnonymousName();
         flag = true;
         flag2 = false;
         int depth = this._XMLReader.Depth;
         this.ReadNextXmlElement();
         while (this._XMLReader.Depth > depth)
         {
             string localName = this._XMLReader.LocalName;
             if (MatchingStrings(localName, s_complexTypeString))
             {
                 this.ParseComplexType(parsingNamespace, typeName);
             }
             else
             {
                 if (MatchingStrings(localName, s_simpleTypeString))
                 {
                     this.ParseSimpleType(parsingNamespace, typeName);
                     continue;
                 }
                 this.SkipXmlElement();
             }
         }
     }
     parsingNamespace.AddElementDecl(new ElementDecl(elmName, name, typeName, str4, flag2));
 }
Example #19
0
        internal String GetTypeString(String curNS, bool bNS, URTNamespace urtNS, String typeName, String typeNS) 
        {
            Util.Log("WsdlParser.GetTypeString Entry curNS "+curNS+" bNS "+bNS+" URTNamespace "+urtNS.Name+" typeName "+typeName+" typeNS "+typeNS);
            String type;

            URTComplexType ct = urtNS.LookupComplexType(typeName);
            if (ct != null && ct.IsArray())
            {
                if (ct.GetArray() == null)
                    ct.ResolveArray();
                String arrayName = ct.GetArray();
                URTNamespace arrayNS = ct.GetArrayNS();
                StringBuilder sb = new StringBuilder(50);
                if (arrayNS.EncodedNS != null && Qualify(urtNS.EncodedNS, arrayNS.EncodedNS))
                {
                    sb.Append(WsdlParser.IsValidCSAttr(arrayNS.EncodedNS));
                    sb.Append('.');
                }
                sb.Append(WsdlParser.IsValidCSAttr(arrayName));
                type = sb.ToString();
            }
            else
            {
                String encodedNS = null;
                if (urtNS.UrtType == UrtType.Interop)
                    encodedNS = urtNS.EncodedNS;
                else
                    encodedNS = typeNS;

                if (bNS && Qualify(encodedNS, curNS))
                {
                    StringBuilder sb = new StringBuilder(50);
                    if (encodedNS != null)
                    {
                        sb.Append(WsdlParser.IsValidCSAttr(encodedNS));
                        sb.Append('.');
                    }
                    sb.Append(WsdlParser.IsValidCSAttr(typeName));
                    type = sb.ToString();
                }
                else
                {
                    type = typeName;
                }

            }

            int index = type.IndexOf('+');
            if (index > 0)
            {
                // nested type, replace + with . Should be done earlier when forming names
                if (bNS)
                    type = type.Replace('+', '.');
                else
                    type = type.Substring(0,index);
            }


            Util.Log("WsdlParser.GetTypeString Exit type "+type);              
            return(type);
        }
 private void ParseElementField(URTNamespace parsingNamespace, URTComplexType parsingComplexType, int fieldNum)
 {
     string nextAnonymousName;
     string fieldNamespace;
     bool flag3;
     bool primitiveField;
     string name = this.LookupAttribute(s_nameString, null, true);
     string left = this.LookupAttribute(s_minOccursString, null, false);
     string str5 = this.LookupAttribute(s_maxOccursString, null, false);
     bool bOptional = false;
     if (MatchingStrings(left, s_zeroString))
     {
         bOptional = true;
     }
     bool bArray = false;
     string arraySize = null;
     if (!MatchingStrings(str5, s_emptyString) && !MatchingStrings(str5, s_oneString))
     {
         if (MatchingStrings(str5, s_unboundedString))
         {
             arraySize = string.Empty;
         }
         else
         {
             arraySize = str5;
         }
         bArray = true;
     }
     if (this._XMLReader.IsEmptyElement)
     {
         nextAnonymousName = this.LookupAttribute(s_typeString, null, false);
         this.ResolveTypeAttribute(ref nextAnonymousName, out fieldNamespace, out flag3, out primitiveField);
         this.ReadNextXmlElement();
     }
     else
     {
         fieldNamespace = parsingNamespace.Namespace;
         nextAnonymousName = parsingNamespace.GetNextAnonymousName();
         primitiveField = false;
         flag3 = true;
         int depth = this._XMLReader.Depth;
         this.ReadNextXmlElement();
         while (this._XMLReader.Depth > depth)
         {
             string localName = this._XMLReader.LocalName;
             if (MatchingStrings(localName, s_complexTypeString))
             {
                 URTComplexType type = this.ParseComplexType(parsingNamespace, nextAnonymousName);
                 if (type.IsEmittableFieldType)
                 {
                     fieldNamespace = type.FieldNamespace;
                     nextAnonymousName = type.FieldName;
                     primitiveField = type.PrimitiveField;
                     parsingNamespace.RemoveComplexType(type);
                 }
             }
             else
             {
                 if (MatchingStrings(localName, s_simpleTypeString))
                 {
                     URTSimpleType type2 = this.ParseSimpleType(parsingNamespace, nextAnonymousName);
                     if (type2.IsEmittableFieldType)
                     {
                         fieldNamespace = type2.FieldNamespace;
                         nextAnonymousName = type2.FieldName;
                         primitiveField = type2.PrimitiveField;
                         parsingNamespace.RemoveSimpleType(type2);
                     }
                     continue;
                 }
                 this.SkipXmlElement();
             }
         }
     }
     parsingComplexType.AddField(new URTField(name, nextAnonymousName, fieldNamespace, this, primitiveField, flag3, false, bOptional, bArray, arraySize, parsingNamespace));
 }
Example #21
0
        // Parses element fields
        private void ParseElementField(URTNamespace parsingNamespace,
                                       URTComplexType parsingComplexType,
                                       int fieldNum)
        {
            Util.Log("WsdlParser.ParseElementField NS "+parsingNamespace+" fieldNum "+fieldNum);            
            // Determine the field name
            String fieldTypeName, fieldTypeXmlNS;
            String fieldName = LookupAttribute(s_nameString, null, true);

            // Look for array bounds
            String minOccurs = LookupAttribute(s_minOccursString, null, false);
            String maxOccurs = LookupAttribute(s_maxOccursString, null, false);

            // Check if the field is optional
            bool bOptional = false;
            if (MatchingStrings(minOccurs, s_zeroString))
                bOptional = true;

            // Check if the field is an inline array
            bool bArray = false;
            String arraySize = null;
            if (!MatchingStrings(maxOccurs, s_emptyString) &&
                !MatchingStrings(maxOccurs, s_oneString))
            {
                if (MatchingStrings(maxOccurs, s_unboundedString))
                    arraySize = String.Empty;
                else
                    arraySize = maxOccurs;
                bArray = true;
            }

            // Handle anonymous types
            bool bEmbedded, bPrimitive;
            if (_XMLReader.IsEmptyElement == true)
            {
                // Non-anonymous type case
                fieldTypeName = LookupAttribute(s_typeString, null, false);

                // Handle the absense of type attribute (Object case)
                ResolveTypeAttribute(ref fieldTypeName, out fieldTypeXmlNS,
                                     out bEmbedded, out bPrimitive);

                // Read next element
                ReadNextXmlElement();
            }
            else
            {
                // Anonymous type case
                fieldTypeXmlNS = parsingNamespace.Namespace;
                fieldTypeName = parsingNamespace.GetNextAnonymousName();
                bPrimitive = false;
                bEmbedded = true;
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if (MatchingStrings(elementName, s_complexTypeString))
                    {
                        URTComplexType complexType = ParseComplexType(parsingNamespace, fieldTypeName);
                        if (complexType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = complexType.FieldNamespace;
                            fieldTypeName = complexType.FieldName;
                            bPrimitive = complexType.PrimitiveField;
                            parsingNamespace.RemoveComplexType(complexType);
                        }
                    }
                    else if (MatchingStrings(elementName, s_simpleTypeString))
                    {
                        URTSimpleType simpleType = ParseSimpleType(parsingNamespace, fieldTypeName);
                        if (simpleType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = simpleType.FieldNamespace;
                            fieldTypeName = simpleType.FieldName;
                            bPrimitive = simpleType.PrimitiveField;
                            parsingNamespace.RemoveSimpleType(simpleType);
                        }
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                }
            }

            // Add field to the type being parsed
            parsingComplexType.AddField(new URTField(fieldName, fieldTypeName, fieldTypeXmlNS,
                                                     this, bPrimitive, bEmbedded, false,
                                                     bOptional, bArray, arraySize, parsingNamespace));
            return;
        }
Example #22
0
        private void ParseWsdlBinding(URTNamespace inparsingNamespace)
        {
            Util.Log("WsdlParser.ParseWsdlBinding");
            WsdlBinding binding = new WsdlBinding();
            binding.name = LookupAttribute(s_nameString, null, true);
            //binding.nameNs = ParseQName(ref binding.name);
            binding.type = LookupAttribute(s_typeString, null, true);
            binding.typeNs = ParseQName(ref binding.type);
            URTNamespace parsingNamespace = LookupNamespace(binding.typeNs);
            if (parsingNamespace == null)
            {
                parsingNamespace = new URTNamespace(binding.typeNs, this); 
            }
            binding.parsingNamespace = parsingNamespace;
            bool bSoapBinding = false;
            bool bRpcBinding = false;
            bool bSoapEncoded = false;
            bool bSoapSuds = false;
            int curDepth = _XMLReader.Depth; 
            ReadNextXmlElement();               
            while (_XMLReader.Depth > curDepth)
            {
                String elementName = _XMLReader.LocalName;
                if (MatchingNamespace(s_wsdlSoapNamespaceString) &&
                    MatchingStrings(elementName, s_bindingString))
                {
                    bSoapBinding = true;
                    WsdlBindingSoapBinding sb = new WsdlBindingSoapBinding();
                    sb.style = LookupAttribute(s_styleString, null, true);
                    if (sb.style == "rpc")
                        bRpcBinding = true;

                    /*
                    if (sb.style == "document")
                    {
                        throw new SUDSParserException(
                            String.Format(CoreChannel.GetResourceString("Remoting_Suds_SoapStyleNotSupported"),
                                          sb.style));
                    }
                    */

                    sb.transport = LookupAttribute(s_transportString, null, true);
                    binding.soapBinding = sb;
                    ReadNextXmlElement();
                    continue;                   
                }
                else if (MatchingNamespace(s_wsdlSudsNamespaceString))
                {
                    bSoapSuds = true;
                    if (MatchingStrings(elementName, s_classString) || MatchingStrings(elementName, s_structString))
                    {
                        WsdlBindingSuds suds = new WsdlBindingSuds();
                        suds.elementName = elementName;
                        suds.typeName = LookupAttribute(s_typeString, null, true);
                        suds.ns = ParseQName(ref suds.typeName);
                        suds.extendsTypeName = LookupAttribute(s_extendsString, null, false);
                        String use = LookupAttribute(s_rootTypeString, null, false);
                        suds.sudsUse = ProcessSudsUse(use, elementName);
                        if (!MatchingStrings(suds.extendsTypeName, s_emptyString))
                            suds.extendsNs = ParseQName(ref suds.extendsTypeName);
                        ParseWsdlBindingSuds(suds);
                        binding.suds.Add(suds);
                        continue;                       
                    }
                    else if (MatchingStrings(elementName, s_interfaceString))
                    {
                        WsdlBindingSuds suds = new WsdlBindingSuds();                       
                        suds.elementName = elementName; //Atomize("interface");
                        suds.typeName = LookupAttribute(s_typeString, null, true);
                        suds.ns = ParseQName(ref suds.typeName);        
                        String use = LookupAttribute(s_rootTypeString, null, false);
                        suds.sudsUse = ProcessSudsUse(use, elementName);
                        ParseWsdlBindingSuds(suds);
                        binding.suds.Add(suds);
                        continue;                       
                    }
                }
                else if (MatchingNamespace(s_wsdlNamespaceString) &&
                         MatchingStrings(elementName, s_operationString))
                {
                    WsdlBindingOperation op = new WsdlBindingOperation();
                    op.name = LookupAttribute(s_nameString, null, true); 
                    op.nameNs = _parsingInput.TargetNS;
                    ParseWsdlBindingOperation(op, ref bRpcBinding, ref bSoapEncoded);
                    binding.operations.Add(op);
                    continue;                   
                }

                // Ignore others elements such as annotations
                SkipXmlElement();
            }
            if (bSoapBinding && bRpcBinding && bSoapEncoded || bSoapSuds)
                wsdlBindings.Add(binding);
        }
Example #23
0
            internal URTField(String name, String typeName, String xmlNS, WsdlParser parser,
                              bool bPrimitive, bool bEmbedded, bool bAttribute, bool bOptional,
                              bool bArray, String arraySize, URTNamespace urtNamespace)
            {
                Util.Log("URTField.URTField "+name+" typeName "+typeName+" xmlNS "+xmlNS+" bPrimitive "+bPrimitive+" bEmbedded "+bEmbedded+" bAttribute "+bAttribute);
                _name = name;
                _typeName = typeName;
                _parser = parser;
                String typeAssemName;

                UrtType urtType = parser.IsURTExportedType(xmlNS, out _typeNS, out typeAssemName);
                if (urtType == UrtType.Interop)
                    _encodedNS = urtNamespace.EncodedNS;
                else
                    _encodedNS = _typeNS;
                _primitiveField = bPrimitive;
                _embeddedField = bEmbedded;
                _attributeField = bAttribute;
                _optionalField = bOptional;
                _arrayField = bArray;
                _arraySize = arraySize;
                _urtNamespace = urtNamespace;
            }
Example #24
0
        // Parses complex types
        private URTComplexType ParseComplexType(URTNamespace parsingNamespace, String typeName)
        {
            Util.Log("WsdlParser.ParseComplexType NS "+parsingNamespace.Name+" typeName "+typeName);                                 
            // Lookup the name of the type and the base type from which it derives
            if (typeName == null)
                typeName = LookupAttribute(s_nameString, null, true);

            URTNamespace xns = null;
            String typeNS = ParseQName(ref typeName, parsingNamespace, out xns);            

            Util.Log("WsdlParser.ParseComplexType actualNS 1 "+xns);
            Util.Log("WsdlParser.ParseComplexType actualNS 2 "+xns.Name);
            URTComplexType parsingComplexType = xns.LookupComplexType(typeName);
            if (parsingComplexType == null)
            {
                parsingComplexType = new URTComplexType(typeName, xns.Name, xns.Namespace,
                                                        xns.EncodedNS, _blockDefault,
                                                        false, typeName != null, this, xns);
                xns.AddComplexType(parsingComplexType);
            }

            String baseType = LookupAttribute(s_baseString, null, false);

            if (!MatchingStrings(baseType, s_emptyString))
            {
                String baseNS = ParseQName(ref baseType, parsingNamespace);
                parsingComplexType.Extends(baseType, baseNS);
            }

            if (parsingComplexType.Fields.Count > 0)
            {
                SkipXmlElement();
            }
            else
            {
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                int fieldNum = 0;
                String elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if (MatchingStrings(elementName, s_elementString))
                    {
                        ParseElementField(xns, parsingComplexType, fieldNum);
                        ++fieldNum;
                        continue;
                    }
                    else if (MatchingStrings(elementName, s_attributeString))
                    {
                        ParseAttributeField(xns, parsingComplexType);
                        continue;
                    }
                    else if (MatchingStrings(elementName, s_allString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.ALL;
                    }
                    else if (MatchingStrings(elementName, s_sequenceString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.SEQUENCE;
                    }
                    else if (MatchingStrings(elementName, s_choiceString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.CHOICE;
                    }
                    else if (MatchingStrings(elementName, s_complexContentString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.ComplexContent; 
                    }
                    else if (MatchingStrings(elementName, s_restrictionString))
                    {
                        ParseRestrictionField(xns, parsingComplexType);
                        //++fieldNum;
                        continue;
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                        continue;
                    }

                    // Read next element
                    ReadNextXmlElement();
                }
            }

            return(parsingComplexType);
        }
Example #25
0
            internal URTComplexType(String name, String urlNS, String ns, String encodedNS,
                                    SchemaBlockType blockDefault, bool bSUDSType, bool bAnonymous, WsdlParser parser, URTNamespace xns)
            : base(name, urlNS, ns, encodedNS)
            {
                Util.Log("URTComplexType.URTComplexType name "+this.GetHashCode()+" "+name+" urlNS "+urlNS+" ns "+ns+" encodedNS "+encodedNS+" bSUDStype "+bSUDSType+" bAnonymous "+bAnonymous);
                _baseTypeName = null;
                _baseTypeXmlNS = null;
                _baseType = null;
                _connectURLs = null;
                _bStruct = !bSUDSType;
                _blockType = blockDefault;
                _bSUDSType = bSUDSType;
                _bAnonymous = bAnonymous;
                Debug.Assert(bAnonymous == false || _bSUDSType == false);
                _fieldString = null;
                _fields = new ArrayList();
                _methods = new ArrayList();
                _implIFaces = new ArrayList();
                _implIFaceNames = new ArrayList();
                _sudsType = SUDSType.None;              
                _parser = parser;

                int index = name.IndexOf('+');
                if (index > 0)
                {
                    // Nested type see if outer type has been added to namespace
                    String outerType = parser.Atomize(name.Substring(0,index));
                    URTComplexType cs = xns.LookupComplexType(outerType);
                    if (cs == null)
                    {
                        URTComplexType newCs = new URTComplexType(outerType, urlNS, ns, encodedNS, blockDefault, bSUDSType, bAnonymous, parser, xns);
                        Util.Log("URTComplexType.URTComplexType add outerType to namespace "+outerType+" nestedname "+name);
                        xns.AddComplexType(newCs);
                    }
                }


                if (xns.UrtType == UrtType.Interop)
                {
                    // Interop class names can have '.', replace these with '_', and set wire name to original type name.
                    index = name.LastIndexOf('.');
                    if (index > -1)
                    {
                        // class names can't have '.' so replace with '$'. Use xmlType attribute to send original name on wire.
                        _wireType = name;
                        Name = name.Replace(".", "_");
                        SearchName = name;
                    }
                }

            }
Example #26
0
 private String ParseQName(ref String qname, URTNamespace defaultNS)
 {
     URTNamespace returnNS = null;
     return ParseQName( ref qname, defaultNS, out returnNS);
 }
Example #27
0
            internal void AddArray(String arrayType, URTNamespace arrayNS)
            {
                Util.Log("URTComplexType.ResolveArray Entry "+this.GetHashCode()+" "+_arrayType+" ns "+_arrayNS);
                _arrayType = arrayType;

                /*
                int index = arrayType.IndexOf('+');
                if (index > 0)
                {
                    // Nested Type
                    String outerTypeName = arrayType.Substring(0, index);
                    String nestedTypeName = arrayType.Substring(index+1);
                    _arrayType = outerTypeName+"."+nestedTypeName;
                }
                */
                _arrayNS = arrayNS;
                Util.Log("URTComplexType.AddArray "+arrayType+" ns "+(arrayNS == null?"null":arrayNS.Namespace)+" finalName "+_arrayType);
            }
Example #28
0
        private String ParseQName(ref String qname, URTNamespace defaultNS, out URTNamespace returnNS)
        {
            Util.Log("WsdlParser.ParseQName Enter qname "+qname+" default xmlns NS "+_XMLReader.LookupNamespace(""));

            String ns = null;
            returnNS = null;
            if ((qname == null) || (qname.Length == 0))
            {
                Util.Log("WsdlParser.ParseQName Exit null");
                return null;
            }

            int colonIndex = qname.IndexOf(":");
            if (colonIndex == -1)
            {
                // The default namespace is the s_empty string (this will need to change)
                //textWriter.WriteLine("DefaultNS: " + _XMLReader.LookupNamespace(s_emptyString) + '\n' +
                //                     "ElementNS: " + _XMLReader.Namespace);
                // Should this be element namespace or default namespace
                // For attributes names, element namespace makes more sense
                // For QName values, default namespace makes more sense
                // I am currently returning default namespace

                returnNS = defaultNS;
                if (defaultNS == null)
                {
                    Util.Log("WsdlParser.ParseQName Exit defaultNS qname "+qname);          
                    ns = _XMLReader.LookupNamespace("");
                }
                else
                {
                    Util.Log("WsdlParser.ParseQName Exit defaultNS qname "+qname+" default "+defaultNS.Name);          
                    ns = defaultNS.Name;
                }

            }
            else
            {
                // Get the suffix and atmoize it
                String prefix = qname.Substring(0, colonIndex);
                qname = Atomize(qname.Substring(colonIndex+1));
                ns = _XMLReader.LookupNamespace(prefix);
            }

            ns = Atomize(ns);

            URTNamespace xns = LookupNamespace(ns);

            if (xns == null)
            {
                xns = new URTNamespace(ns, this);
            }


            returnNS = xns;

            Util.Log("WsdlParser.ParseQName Exit qname "+qname+" typeString "+ns+" returnNS "+(returnNS == null?"null":returnNS.Name));          
            return(ns);
        }
Example #29
0
 private void AddToNamespace(String name)
 {
 URTNamespace parsingNamespace = LookupNamespace(name);
 if(parsingNamespace == null)
 {
 parsingNamespace = new URTNamespace(name, this);
 _URTNamespaces.Add(parsingNamespace);
 }
 }
 private URTNamespace ParseNamespace()
 {
     string left = this.LookupAttribute(s_targetNamespaceString, null, false);
     bool flag = false;
     if ((MatchingStrings(left, s_emptyString) && MatchingStrings(this._XMLReader.LocalName, s_sudsString)) && (this._parsingInput.UniqueNS == null))
     {
         left = this._parsingInput.TargetNS;
         flag = true;
     }
     URTNamespace namespace2 = this.LookupNamespace(left);
     if (namespace2 == null)
     {
         namespace2 = new URTNamespace(left, this);
     }
     if (flag)
     {
         this._parsingInput.UniqueNS = namespace2;
     }
     this.ReadNextXmlElement();
     return namespace2;
 }