|
Parsing SOAP messages using kXML: msg#00006java.enhydra.kxml
Hi, I have got this SOAP message: <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas/xmlsoap.org/soap/envelope/" > <SOAP-ENV:Body> <SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <PatientName xmlns="" xsi:type="xsd:string">Gaurav Rana</PatientName xmlns="" xsi:type="xsd:string"> <SerialID xmlns="" xsi:type="xsd:long">343524324</SerialID xmlns="" xsi:type="xsd:long"> <RSerialID xmlns="" xsi:type="xsd:long">42365434</RSerialID xmlns="" xsi:type="xsd:long"> </SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> </SOAP-ENV:Body> </SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas/xmlsoap.org/soap/envelope/" > Now I am trying to parse it using the kXML APIs. It seems that when you parse using kXML it accepts XML elements with only one word. that is it will parse <SOAP-ENV> but not <SOAP-ENV: Envelope> XmlParser parser = new XmlParser (new InputStreamReader(input)); parser.skip(); try{ parser.read(Xml.START_TAG, "","SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas/xmlsoap.org/soap/envelope/\""); }catch (ParseException e) { System.out.println("Error : " + e.getLineNumber()); } String[] result={"","",""}; while(true){ parser.skip(); ParseEvent event=parser.peek(); if(event.getType()==Xml.START_TAG){ String name= event.getName(); parser.read(); String temp = parser.readText(); System.out.println(temp); parser.read(Xml.END_TAG,"",name); if(name.equals("PatientName xmlns=\"\" xsi:type=\"xsd:string\"")){ result[0] = temp; }else if(name.equals("SerialID xmlns=\"\" xsi:type=\"xsd:long\"")){ result[1] = temp; }else if(name.equals("RSerialID xmlns=\"\" xsi:type=\"xsd:long\"")){ result[2] = temp; } } else if (event.getType() == Xml.END_TAG){ parser.read(Xml.END_TAG, "","SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas/xmlsoap.org/soap/envelope/\""); break; } } Do you think I am doing it right? Please help me. I am new to kXML.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: How to specify OPAQUE data, Stefan Haustein |
|---|---|
| Next by Date: | Error verifying method org/kxml2/io/KXmlParser <init>()V, Thomas Sillhengst |
| Previous by Thread: | How to specify OPAQUE data, Max Stolyarov |
| Next by Thread: | Re: Parsing SOAP messages using kXML, Stefan Haustein |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |