1 29 30 package com.caucho.soa.encoding; 31 32 import com.caucho.soap.reflect.WebServiceIntrospector; 33 import com.caucho.soap.skeleton.DirectSkeleton; 34 35 import javax.annotation.PostConstruct; 36 import javax.xml.bind.JAXBException; 37 import javax.xml.stream.XMLInputFactory; 38 import javax.xml.stream.XMLOutputFactory; 39 import javax.xml.stream.XMLStreamReader; 40 import javax.xml.stream.XMLStreamWriter; 41 import java.io.IOException ; 42 import java.io.InputStream ; 43 import java.io.OutputStream ; 44 import java.util.logging.Logger ; 45 46 49 public class SoapEncoding implements ServiceEncoding { 50 private static final Logger log = 51 Logger.getLogger(SoapEncoding.class.getName()); 52 53 private Object _object; 54 private Class _class; 55 private DirectSkeleton _skeleton; 56 private String _wsdlLocation; 57 58 public void setService(Object service) 59 { 60 _object = service; 61 62 if (_class == null) 63 _class = service.getClass(); 64 } 65 66 public void setInterface(Class cl) 67 { 68 _class = cl; 69 } 70 71 @PostConstruct 72 public void init() 73 { 74 } 75 76 public void invoke(InputStream is, OutputStream os) 77 throws Throwable 78 { 79 XMLInputFactory inputFactory = XMLInputFactory.newInstance(); 80 XMLStreamReader in = inputFactory.createXMLStreamReader(is); 81 82 XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); 83 XMLStreamWriter out = outputFactory.createXMLStreamWriter(os); 84 85 getSkeleton().invoke(_object, in, out); 86 87 out.flush(); 88 } 89 90 private DirectSkeleton getSkeleton() 91 throws JAXBException, IOException 92 { 93 if (_skeleton == null) { 94 _skeleton = 95 new WebServiceIntrospector().introspect(_class, _wsdlLocation); 96 } 97 98 return _skeleton; 99 } 100 } 101 | Popular Tags |