Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 77766 invoked from network); 2 Apr 2008 02:03:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 02:03:26 -0000 Received: (qmail 78111 invoked by uid 500); 2 Apr 2008 02:03:25 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 77992 invoked by uid 500); 2 Apr 2008 02:03:25 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 77981 invoked by uid 500); 2 Apr 2008 02:03:25 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 77978 invoked by uid 99); 2 Apr 2008 02:03:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2008 19:03:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 02:02:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AC5C31A9832; Tue, 1 Apr 2008 19:03:04 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r643684 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Date: Wed, 02 Apr 2008 02:03:04 -0000 To: axis2-cvs@ws.apache.org From: keithc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080402020304.AC5C31A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: keithc Date: Tue Apr 1 19:03:02 2008 New Revision: 643684 URL: http://svn.apache.org/viewvc?rev=643684&view=rev Log: Moving the WSDLReader logic to a common place. They were in two places before. Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?rev=643684&r1=643683&r2=643684&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Tue Apr 1 19:03:02 2008 @@ -88,12 +88,15 @@ import org.apache.ws.commons.schema.utils.NamespaceMap; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.xml.sax.SAXException; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.InputStream; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -149,6 +152,7 @@ File file = new File(wsdlUri); fullPath = file.getAbsolutePath(); } + setBaseUri(fullPath); Description description = readInTheWSDLFile(fullPath); DescriptionElement descriptionElement = description.toElement(); @@ -466,25 +470,7 @@ description = readInTheWSDLFile(wsdlURI); descriptionElement = description.toElement(); } else if (in != null) { - - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory - .newInstance(); - documentBuilderFactory.setNamespaceAware(true); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document document = documentBuilder.parse(in); - - WSDLReader reader = DOMWSDLFactory.newInstance().newWSDLReader(); - if (customWSDLResolver != null) { - reader.setURIResolver(customWSDLResolver); - } - // This turns on WSDL validation which is set off by default. - reader.setFeature(WSDLReader.FEATURE_VALIDATION, true); - WSDLSource wsdlSource = reader.createWSDLSource(); - wsdlSource.setSource(document.getDocumentElement()); - if (getBaseUri() != null && !"".equals(getBaseUri())) { - wsdlSource.setBaseURI(new URI(getBaseUri())); - } - description = reader.readWSDL(wsdlSource); + description = readInTheWSDLFile(in); descriptionElement = description.toElement(); } else { throw new AxisFault("No resources found to read the wsdl"); @@ -1168,20 +1154,65 @@ } private Description readInTheWSDLFile(String wsdlURI) throws WSDLException { + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory + .newInstance(); + documentBuilderFactory.setNamespaceAware(true); + DocumentBuilder documentBuilder; + Document document = null; + try { + documentBuilder = documentBuilderFactory.newDocumentBuilder(); + document = documentBuilder.parse(wsdlURI); + } catch (ParserConfigurationException e) { + AxisFault.makeFault(e); + } catch (IOException e) { + AxisFault.makeFault(e); + } catch (SAXException e) { + AxisFault.makeFault(e); + } + return readInTheWSDLFile(document); + } + + private Description readInTheWSDLFile(InputStream inputStream) throws WSDLException { + + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory + .newInstance(); + documentBuilderFactory.setNamespaceAware(true); + DocumentBuilder documentBuilder; + Document document = null; + try { + documentBuilder = documentBuilderFactory.newDocumentBuilder(); + document = documentBuilder.parse(inputStream); + } catch (ParserConfigurationException e) { + AxisFault.makeFault(e); + } catch (IOException e) { + AxisFault.makeFault(e); + } catch (SAXException e) { + AxisFault.makeFault(e); + } + return readInTheWSDLFile(document); + } - WSDLReader reader = WSDLFactory.newInstance().newWSDLReader(); + private Description readInTheWSDLFile(Document document) throws WSDLException { + WSDLReader reader = DOMWSDLFactory.newInstance().newWSDLReader(); if (customWSDLResolver != null) { reader.setURIResolver(customWSDLResolver); } // This turns on WSDL validation which is set off by default. reader.setFeature(WSDLReader.FEATURE_VALIDATION, true); - -// Log when and from where the WSDL is loaded. + WSDLSource wsdlSource = reader.createWSDLSource(); + wsdlSource.setSource(document.getDocumentElement()); + if (getBaseUri() != null && !"".equals(getBaseUri())) { + try { + wsdlSource.setBaseURI(new URI(getBaseUri())); + } catch (URISyntaxException e) { + AxisFault.makeFault(e); + } + } if (log.isDebugEnabled()) { log.debug("Reading 2.0 WSDL with wsdl uri = " + wsdlURI); log.debug(" the stack at this point is: " + stackToString()); } - return reader.readWSDL(wsdlURI); + return reader.readWSDL(wsdlSource); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org