1 25 package com.scalagent.ksoap.marshal; 26 27 import java.io.*; 28 import com.scalagent.ksoap.*; 29 30 public class MarshalBase64 implements Marshal { 31 32 static byte [] BA_WORKAROUND = new byte[0]; 33 public static Class BYTE_ARRAY_CLASS = BA_WORKAROUND.getClass(); 34 35 public Object readInstance(SoapReader reader, 36 String namespace, 37 String name, 38 PropertyInfo expected) throws IOException { 39 40 reader.parser.read(); 41 Object result = Base64.decode(reader.parser.readText()); 42 reader.parser.read(); 43 return result; 44 } 45 46 47 public void writeInstance(SoapWriter writer, 48 Object obj) throws IOException { 49 writer.writer.write(Base64.encode((byte[]) obj)); 50 } 51 52 public void register(ClassMap cm) { 53 cm.addMapping(cm.xsd,"base64Binary", 54 MarshalBase64.BYTE_ARRAY_CLASS,this); 55 cm.addMapping(ClassMap.enc,"base64", 56 MarshalBase64.BYTE_ARRAY_CLASS,this); 57 } 58 } 59 | Popular Tags |