コード例 #1
0
        public override void parseBody(XmlPullParser parser)
        {
            bodyIn = null;
            parser.nextTag();
            if (parser.getEventType() == XmlPullParser.START_TAG && parser.getNamespace().Equals(env) &&
                parser.getName().Equals("Fault"))
            {
                SoapFault fault;
                if (this.version < SoapEnvelope.VER12)
                {
                    fault = new SoapFault(this.version);
                }
                else
                {
                    fault = new SoapFault12(this.version);
                }
                fault.parse(parser);
                bodyIn = fault;
            }
            else
            {
                while (parser.getEventType() == XmlPullParser.START_TAG)
                {
                    String rootAttr = parser.getAttributeValue(enc, ROOT_LABEL);

                    Object o = read(parser, null, -1, parser.getNamespace(), parser.getName(),
                                    PropertyInfo.OBJECT_TYPE);
                    if ("1".Equals(rootAttr) || bodyIn == null)
                    {
                        bodyIn = o;
                    }
                    parser.nextTag();
                }
            }
        }
コード例 #2
0
ファイル: SoapEnvelope.cs プロジェクト: Noisyfox/fSoap
 public virtual void parseBody(XmlPullParser parser)
 {
     parser.nextTag();
     // insert fault generation code here
     if (parser.getEventType() == XmlPullParser.START_TAG &&
         parser.getNamespace().Equals(env) &&
         parser.getName().Equals("Fault"))
     {
         SoapFault fault;
         if (this.version < SoapEnvelope.VER12)
         {
             fault = new SoapFault(this.version);
         }
         else
         {
             fault = new SoapFault12(this.version);
         }
         fault.parse(parser);
         bodyIn = fault;
     }
     else
     {
         Node node = (bodyIn
                      is Node)
             ? (Node)bodyIn
             : new Node();
         node.parse(parser);
         bodyIn = node;
     }
 }
コード例 #3
0
ファイル: Node.cs プロジェクト: Noisyfox/fSoap
        /** Recursively builds the child elements from the given parser
         * until an end tag or end document is found.
         * The end tag is not consumed. */

        public virtual void parse(XmlPullParser parser)
        {
            bool leave = false;

            do
            {
                int type = parser.getEventType();

                //         System.out.println(parser.getPositionDescription());

                switch (type)
                {
                case XmlPullParser.START_TAG:
                {
                    Element child =
                        createElement(
                            parser.getNamespace(),
                            parser.getName());
                    //    child.setAttributes (event.getAttributes ());
                    addChild(ELEMENT, child);

                    // order is important here since
                    // setparent may perform some init code!

                    child.parse(parser);
                    break;
                }

                case XmlPullParser.END_DOCUMENT:
                case XmlPullParser.END_TAG:
                    leave = true;
                    break;

                default:
                    if (parser.getText() != null)
                    {
                        addChild(
                            type == XmlPullParser.ENTITY_REF ? TEXT : type,
                            parser.getText());
                    }
                    else if (
                        type == XmlPullParser.ENTITY_REF &&
                        parser.getName() != null)
                    {
                        addChild(ENTITY_REF, parser.getName());
                    }
                    parser.nextToken();
                    break;
                }
            } while (!leave);
        }
コード例 #4
0
        protected void readVector(XmlPullParser parser, List <object> v, PropertyInfo elementType)
        {
            String namespace_ = null;
            String name       = null;
            int    size       = v.Count;
            bool   dynamic    = true;
            String type       = parser.getAttributeValue(enc, ARRAY_TYPE_LABEL);

            if (type != null)
            {
                int cut0 = type.IndexOf(':');
                int cut1 = type.IndexOf("[", cut0);
                name = type.Substring(cut0 + 1, cut1 - cut0 - 1);
                String prefix = cut0 == -1 ? "" : type.Substring(0, cut0);
                namespace_ = parser.getNamespace(prefix);
                size       = getIndex(type, cut1, -1);
                if (size != -1)
                {
                    setSize(v, size);
                    dynamic = false;
                }
            }
            if (elementType == null)
            {
                elementType = PropertyInfo.OBJECT_TYPE;
            }
            parser.nextTag();
            int position = getIndex(parser.getAttributeValue(enc, "offset"), 0, 0);

            while (parser.getEventType() != XmlPullParser.END_TAG)
            {
                // handle position
                position = getIndex(parser.getAttributeValue(enc, "position"), 0, position);
                if (dynamic && position >= size)
                {
                    size = position + 1;
                    setSize(v, size);
                }
                // implicit handling of position exceeding specified size
                v[position] = read(parser, v, position, namespace_, name, elementType);
                position++;
                parser.nextTag();
            }
            parser.require(XmlPullParser.END_TAG, null, null);
        }
コード例 #5
0
ファイル: SoapEnvelope.cs プロジェクト: Noisyfox/fSoap
        /** Parses the SOAP envelope from the given parser */

        public void parse(XmlPullParser parser)
        {
            parser.nextTag();
            parser.require(XmlPullParser.START_TAG, env, "Envelope");
            encodingStyle = parser.getAttributeValue(env, "encodingStyle");
            parser.nextTag();
            if (parser.getEventType() == XmlPullParser.START_TAG &&
                parser.getNamespace().Equals(env) &&
                parser.getName().Equals("Header"))
            {
                parseHeader(parser);
                parser.require(XmlPullParser.END_TAG, env, "Header");
                parser.nextTag();
            }
            parser.require(XmlPullParser.START_TAG, env, "Body");
            encodingStyle = parser.getAttributeValue(env, "encodingStyle");
            parseBody(parser);
            parser.require(XmlPullParser.END_TAG, env, "Body");
            parser.nextTag();
            parser.require(XmlPullParser.END_TAG, env, "Envelope");
        }
コード例 #6
0
        /**
         * If the type of the object cannot be determined, and thus no Marshal class can handle the object, this
         * method is called. It will build either a SoapPrimitive or a SoapObject
         *
         * @param parser
         * @param typeNamespace
         * @param typeName
         * @return unknownObject wrapped as a SoapPrimitive or SoapObject
         * @throws IOException
         * @throws XmlPullParserException
         */

        protected Object readUnknown(XmlPullParser parser, String typeNamespace, String typeName)
        {
            String name       = parser.getName();
            String namespace_ = parser.getNamespace();

            // cache the attribute info list from the current element before we move on
            List <object> attributeInfoVector = new List <object>();

            for (int attributeCount = 0; attributeCount < parser.getAttributeCount(); attributeCount++)
            {
                AttributeInfo attributeInfo = new AttributeInfo();
                attributeInfo.setName(parser.getAttributeName(attributeCount));
                attributeInfo.setValue(parser.getAttributeValue(attributeCount));
                attributeInfo.setNamespace(parser.getAttributeNamespace(attributeCount));
                attributeInfo.setType(parser.getAttributeType(attributeCount));
                attributeInfoVector.Add(attributeInfo);
            }

            parser.next(); // move to text, inner start tag or end tag
            Object result = null;
            String text   = null;

            if (parser.getEventType() == XmlPullParser.TEXT)
            {
                text = parser.getText();
                SoapPrimitive sp = new SoapPrimitive(typeNamespace, typeName, text);
                result = sp;
                // apply all the cached attribute info list before we add the property and descend further for parsing
                for (int i = 0; i < attributeInfoVector.Count; i++)
                {
                    sp.addAttribute((AttributeInfo)attributeInfoVector[i]);
                }
                parser.next();
            }
            else if (parser.getEventType() == XmlPullParser.END_TAG)
            {
                SoapObject so = new SoapObject(typeNamespace, typeName);
                // apply all the cached attribute info list before we add the property and descend further for parsing
                for (int i = 0; i < attributeInfoVector.Count; i++)
                {
                    so.addAttribute((AttributeInfo)attributeInfoVector[i]);
                }
                result = so;
            }

            if (parser.getEventType() == XmlPullParser.START_TAG)
            {
                if (text != null && text.Trim().Length != 0)
                {
                    throw new Exception("Malformed input: Mixed content");
                }
                SoapObject so = new SoapObject(typeNamespace, typeName);
                // apply all the cached attribute info list before we add the property and descend further for parsing
                for (int i = 0; i < attributeInfoVector.Count; i++)
                {
                    so.addAttribute((AttributeInfo)attributeInfoVector[i]);
                }

                while (parser.getEventType() != XmlPullParser.END_TAG)
                {
                    so.addProperty(parser.getNamespace(), parser.getName(), read(parser, so, so.getPropertyCount(),
                                                                                 null, null, PropertyInfo.OBJECT_TYPE));
                    parser.nextTag();
                }
                result = so;
            }
            parser.require(XmlPullParser.END_TAG, namespace_, name);
            return(result);
        }