1 16 package org.apache.axis2.wsdl.builder.wsdl4j; 17 18 import org.apache.axis2.wsdl.WSDLVersionWrapper; 19 import org.apache.axis2.wsdl.builder.WOMBuilder; 20 import org.apache.axis2.wsdl.builder.WSDLComponentFactory; 21 import org.apache.wsdl.WSDLDescription; 22 import org.apache.wsdl.impl.WSDLDescriptionImpl; 23 import org.apache.wsdl.util.Utils; 24 import org.w3c.dom.Document ; 25 import org.xml.sax.SAXException ; 26 27 import javax.wsdl.Definition; 28 import javax.wsdl.WSDLException; 29 import javax.wsdl.factory.WSDLFactory; 30 import javax.wsdl.xml.WSDLReader; 31 import javax.xml.parsers.ParserConfigurationException ; 32 import java.io.IOException ; 33 import java.io.InputStream ; 34 35 38 public class WSDL1ToWOMBuilder implements WOMBuilder { 39 40 public WSDLVersionWrapper build(InputStream in) throws WSDLException { 41 42 WSDLDescription wsdlDescription = new WSDLDescriptionImpl(); 43 44 Definition wsdl1Definition = this.readInTheWSDLFile(in); 45 WSDLPump pump = new WSDLPump(wsdlDescription, wsdl1Definition); 46 pump.pump(); 47 48 return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition); 49 } 50 51 public WSDLVersionWrapper build (InputStream in, WSDLComponentFactory wsdlComponentFactory) throws WSDLException{ 52 WSDLDescription wsdlDescription = wsdlComponentFactory.createDescription(); 53 54 Definition wsdl1Definition = this.readInTheWSDLFile(in); 55 WSDLPump pump = new WSDLPump(wsdlDescription, wsdl1Definition, wsdlComponentFactory); 56 pump.pump(); 57 58 return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition); 59 60 } 61 62 private Definition readInTheWSDLFile(InputStream in) throws WSDLException { 63 64 WSDLReader reader = 65 WSDLFactory.newInstance().newWSDLReader(); 66 Document doc; 67 try { 68 doc = Utils.newDocument(in); 69 } catch (ParserConfigurationException e) { 70 throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e); 71 } catch (SAXException e) { 72 throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e); 73 74 } catch (IOException e) { 75 throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e); 76 } 77 78 return reader.readWSDL(null, doc); 79 } 80 81 82 } 83 | Popular Tags |