1 25 package com.scalagent.ksoap; 26 27 import java.util.Vector ; 28 import java.io.*; 29 import org.kxml.*; 30 import org.kxml.io.*; 31 import org.kxml.parser.*; 32 33 public class SoapFault extends IOException { 34 35 public String faultcode; 36 public String faultstring; 37 public String faultactor; 38 public Vector detail; 39 40 public void parse(AbstractXmlParser parser) throws IOException { 41 if (KSoapTracing.dbg) 42 KSoapTracing.log(KSoapTracing.DEBUG, 43 "SoapFault.parse(" + parser + ")"); 44 parser.read(Xml.START_TAG,ClassMap.env,"Fault"); 45 46 while (true) { 47 parser.skip(); 48 ParseEvent event = parser.peek(); 49 switch (event.getType()) { 50 51 case Xml.START_TAG: 52 String name = event.getName(); 53 54 if (name.equals("detail")) { 55 detail = new Vector (); 56 parser.readTree(detail); 57 } 58 else { 59 parser.read(); 60 String value = parser.readText(); 61 parser.read(); 62 if (name.equals("faultcode")) 63 faultcode = value; 64 else if (name.equals("faultstring")) 65 faultstring = value; 66 else if (name.equals("faultactor")) 67 faultactor = value; 68 } 69 break; 70 71 case Xml.END_TAG: 72 parser.read(); 73 return; 74 default: 75 parser.read(); 76 } 77 } 78 } 79 80 public void write(AbstractXmlWriter xw) throws IOException { 81 if (KSoapTracing.dbg) 82 KSoapTracing.log(KSoapTracing.DEBUG, 83 "SoapFault.write(" + xw + ")"); 84 xw.startTag(ClassMap.env, "Fault"); 85 xw.startTag("faultcode"); 86 xw.write(""+ faultcode); 87 xw.endTag(); 88 xw.startTag("faultstring"); 89 xw.write(""+ faultstring); 90 xw.endTag(); 91 xw.startTag("detail"); 92 if (detail != null) 93 for (int i = 0; i < detail.size(); i++) { 94 xw.startTag("item"); 95 xw.write(""+detail.elementAt(i)); 96 xw.endTag(); 97 } 98 xw.endTag(); 99 xw.endTag(); 100 } 101 102 public String toString() { 103 return "SoapFault - faultcode: " + faultcode 104 + " faultstring: " + faultstring 105 + " faultactor: " + faultactor 106 + " detail: " + detail; 107 } 108 } 109 110 | Popular Tags |